本文整理汇总了Python中Session.Session.isLogged方法的典型用法代码示例。如果您正苦于以下问题:Python Session.isLogged方法的具体用法?Python Session.isLogged怎么用?Python Session.isLogged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session.Session
的用法示例。
在下文中一共展示了Session.isLogged方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AuthDialog
# 需要导入模块: from Session import Session [as 别名]
# 或者: from Session.Session import isLogged [as 别名]
class AuthDialog (gtk.Dialog):
"""
@summary: Class that manage google data authentication dialog.
"""
__DEFAULT_WINDOW_WIDTH__ = 400
__DEFAULT_WINDOW_HEIGHT__ = 250
def __init__(self, parent=None, callback=None):
"""
@summary: Create new authentication dialog.
@param parent: GtkWindow parent.
"""
super(AuthDialog, self).__init__()
self.__session__ = Session()
super(AuthDialog, self).set_title(self.__trans__("Google Authentication"))
super(AuthDialog, self).set_flags(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
super(AuthDialog, self).add_buttons(gtk.STOCK_OK, gtk.RESPONSE_OK)
super(AuthDialog, self).set_transient_for(parent)
if (parent != None):
super(AuthDialog, self).set_position(gtk.WIN_POS_CENTER_ON_PARENT)
else:
super(AuthDialog, self).set_position(gtk.WIN_POS_CENTER)
# Add signals
super(AuthDialog, self).connect("response", self.__closeEvent__)
super(AuthDialog, self).set_size_request(self.__DEFAULT_WINDOW_WIDTH__, self.__DEFAULT_WINDOW_HEIGHT__)
self.__initUI__()
self.__callback__ = callback
def __trans__(self, msg):
"""
@summary: Translate msg.
@param msg: str within message.
@return: str translated.
"""
return gettext.translation(camimgplugin.camimgpluginName, __LOCALE_FOLDER__,
languages=[__LANGKEY__], fallback=True).gettext(msg)
def __initUI__(self):
"""
@summary: Initialize ui.
"""
self.__tbUserName__ = gtk.Entry()
self.__tbUserName__.set_editable(False)
self.__tbState__ = gtk.Entry()
self.__tbState__.set_editable(False)
self.__btAuthentication__ = gtk.Button()
self.__btAuthentication__.connect("activate", self.__loginEvent__)
self.__btAuthentication__.connect("clicked", self.__loginEvent__)
self.__btRevoke__ = gtk.Button(label=self.__trans__("Revoke"))
self.__btRevoke__.connect("activate", self.__revokeEvent__)
self.__btRevoke__.connect("clicked", self.__revokeEvent__)
tData = gtk.Table(rows=3, columns=2)
tData.attach(gtk.Label(self.__trans__("Username")), 0, 1, 0, 1, xoptions=0, yoptions=0, xpadding=1, ypadding=1)
tData.attach(self.__tbUserName__, 1, 2, 0, 1, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0, xpadding=1, ypadding=1)
tData.attach(gtk.Label(self.__trans__("State")), 0, 1, 1, 2, xoptions=0, yoptions=0, xpadding=1, ypadding=1)
tData.attach(self.__tbState__, 1, 2, 1, 2, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0, xpadding=1, ypadding=1)
self.__imgLogin__ = gtk.Image()
self.__imgLogin__.set_from_file(os.path.join(__ICONS_FOLDER__, "picasaweblogo.gif"))
hbButton = gtk.HBox()
# hbButton.pack_start(self.__imgLogin__, False, False)
self.__btAuthentication__.set_image(self.__imgLogin__)
hbButton.pack_start(self.__btAuthentication__, False, False)
hbButton.pack_start(self.__btRevoke__, False, False)
hAlign = gtk.Alignment(xalign=1, yalign=0.5)
hAlign.add(hbButton)
tData.attach(hAlign, 1, 2, 2, 3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=gtk.FILL, xpadding=0, ypadding=0)
vBox = gtk.VBox()
vBox.pack_start(tData, True, True)
self.get_child().pack_start(vBox, True, True)
vBox.show_all()
def __initData__(self, gtkLock=False):
"""
@summary: Set data to dialog.
"""
if (self.__session__.isLogged()):
self.__tbState__.set_text(self.__trans__("Authenticated"))
self.__tbUserName__.set_text(self.__session__.getUsername())
else:
self.__tbState__.set_text(self.__trans__("No Authenticated"))
self.__tbUserName__.set_text("")
#.........这里部分代码省略.........