當前位置: 首頁>>代碼示例>>Python>>正文


Python Session.isLogged方法代碼示例

本文整理匯總了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("")
    
#.........這裏部分代碼省略.........
開發者ID:babytux,項目名稱:PyCamimg,代碼行數:103,代碼來源:AuthDialog.py


注:本文中的Session.Session.isLogged方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。