def __kdeGetText(parent, title, label, mode = QLineEdit.Normal, text = QString(),
                  f = Qt.WindowFlags(Qt.Widget)):
     """
     Function to get some text from the user.
     
     @param parent parent widget of the dialog (QWidget)
     @param title window title of the dialog (QString)
     @param label text of the label for the line edit (QString)
     @param mode mode of the line edit (QLineEdit.EchoMode)
     @param text initial text of the line edit (QString)
     @param f window flags for the dialog (Qt.WindowFlags)
     @return tuple of (text, ok). text contains the text entered by the
         user, ok indicates a valid input. (QString, boolean)
     """
     if mode == QLineEdit.Normal:
         return KInputDialog.getText(title, label, text, parent)
     else:
         dlg = KPasswordDialog(parent)
         dlg.setWindowTitle(title)
         dlg.setPrompt(label)
         if not text.isEmpty():
             dlg.setPassword(text)
         if dlg.exec_() == KPasswordDialog.Accepted:
             ok = True
             password = dlg.password()
         else:
             ok = False
             password = QString()
         return password, ok
예제 #2
0
파일: main.py 프로젝트: selam/ublog
    def authenticate(self, loop_count):
        if loop_count >= 5:
            return self.quit()
        loop_count += 1
        resp, content = self.client.request("https://twitter.com/oauth/request_token", "GET")
        if resp['status'] != '200':
            raise Exception("Invalid response %s." % resp['status'])
        request_token = dict(urlparse.parse_qsl(content))

        KToolInvocation.invokeBrowser("https://twitter.com/oauth/authorize?oauth_token=%s&oauth_callback=oob" % (
                                                                                request_token['oauth_token']))

        dialog = KInputDialog.getText(self.trUtf8("PIN"), self.trUtf8("Enter the PIN received from Twitter:"))
        if dialog[1] is True and not dialog[0].isEmpty():
            token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
            token.set_verifier(str(dialog[0]))
            client = oauth.Client(self.consumer, token)
            resp, content = client.request("https://twitter.com/oauth/access_token", "POST")
            if resp['status'] == '200':
                access_token = dict(urlparse.parse_qsl(content))
                self.oauth_secret = access_token['oauth_token_secret']
                self.oauth_key = access_token['oauth_token']
                self.pm.writePassword("twitter_secret", self.oauth_secret)
                self.pm.writePassword("twitter_token", self.oauth_key)
            else:
                self.authenticate(loop_count)
        else:
            self.quit()
예제 #3
0
파일: netkut.py 프로젝트: go2n/Netkut
 def onChangeMAC(self):
     text, ok = KInputDialog.getText(i18n("MAC Address Changer"), 
                                     i18n("Enter your new MAC Address: "))
     if ok:
         newMac = str(text)
         pipe = os.popen("ifconfig " + self.icard +" down hw ether " + newMAC,'r')
         pipe.close()
         pipe = os.popen("ifconfig " + self.icard +" up",'r')
         pipe.close()
 def __kdeGetItem(parent, title, label, slist, current = 0, editable = True, 
                  f = Qt.WindowFlags(Qt.Widget)):
     """
     Function to get an item of a list from the user.
     
     @param parent parent widget of the dialog (QWidget)
     @param title window title of the dialog (QString)
     @param label text of the label for the line edit (QString)
     @param slist list of strings to select from (QStringList)
     @param current number of item, that should be selected as a default (integer)
     @param editable indicates whether the user can input their own text (boolean)
     @param f window flags for the dialog (Qt.WindowFlags)
     @return tuple of (value, ok). value contains the double entered by the
         user, ok indicates a valid input. (QString, boolean)
     """
     return KInputDialog.getItem(title, label, slist, current, editable, parent)
 def __kdeGetInt(parent, title, label, value = 0, minValue = -2147483647, 
                     maxValue = 2147483647, step = 1, f = Qt.WindowFlags(Qt.Widget)):
     """
     Function to get an integer value from the user.
     
     @param parent parent widget of the dialog (QWidget)
     @param title window title of the dialog (QString)
     @param label text of the label for the line edit (QString)
     @param value initial value of the spin box (integer)
     @param minValue minimal value of the spin box (integer)
     @param maxValue maximal value of the spin box (integer)
     @param step step size of the spin box (integer)
     @param f window flags for the dialog (Qt.WindowFlags)
     @return tuple of (value, ok). value contains the integer entered by the
         user, ok indicates a valid input. (integer, boolean)
     """
     return KInputDialog.getInteger(title, label, value, minValue, maxValue, step,
                                    10, parent)
 def __kdeGetDouble(parent, title, label, value = 0.0, 
                    minValue = -2147483647.0, maxValue = 2147483647.0, decimals = 1, 
                    f = Qt.WindowFlags(Qt.Widget)):
     """
     Function to get a double value from the user.
     
     @param parent parent widget of the dialog (QWidget)
     @param title window title of the dialog (QString)
     @param label text of the label for the line edit (QString)
     @param value initial value of the spin box (double)
     @param minValue minimal value of the spin box (double)
     @param maxValue maximal value of the spin box (double)
     @param decimals maximum number of decimals the value may have (integer)
     @param f window flags for the dialog (Qt.WindowFlags)
     @return tuple of (value, ok). value contains the double entered by the
         user, ok indicates a valid input. (double, boolean)
     """
     return KInputDialog.getDouble(title, label, value, minValue, maxValue, decimals,
                                   parent)