Tuesday, 15 May 2012

python - Passing a String to A pyqt Application -


I am writing a pyqt application that will take a wifi password behind a password protected site, I have to write a QT The application that will use the form to provide my Pyro script with the username and password, then return all that information and it will be inserted into the previously left empty label. Here's Qt code:

  from PyQt4.QtGui import QApplication, QWidget, QLabel, QComboBox, QLineEdit, QPushButton import sys import wifiRetriever qt_app = QApplication (sys.argv) class pyGui (QWidget): def __init __ (self): # Start the object as a QWidget QWidget .__ init __ (self) # We, main window of # to set ourselves size, since we control the whole layout self.setMinimumSize (400 , 185) self.setWindowTitle ('some public WiFi') # With this effect, make the control as their guardian and #make your status personal Set as default; Each line has a label labeled for # other control # user name field labeled self.username_lbl = QLabel ('username', manually) self.username_lbl.move (5, 5) self.username = QLineEdit (self) self.username Set Placeholder Text ("Some Usernames") Allow labeling between # Label and blankbox-box for 100px and # 5px each for left borders, and #smart #smartself.username.setMinimumWidth (285) # this five Keep the pixels labeled for self.username.move (110, 5) # for the label self.password_lbl = QLabel ('Pa Word: 'Self) # 5 pixel indent, the last pair is less than 25 pixels widgets self.password_lbl.move (5, 50) # recipient control is an entry text box self.password = QLineEdit (self) # Add some ghost text to enter self.password.setPlaceholderText the sort of thing ( "a password") Greetings self.password.setMinimumWidth (285) as the salutation # the same indent but 25 pixels at self.password.move (110, 50) As the same width # then it decreases 45 pixels: (self, 'guest wifi password is') # Costs as well as indent others, but the # character self.password.setEchoMode (QLineEdit.Password) # Greeting widget indicates self.guestWifi_lbl = QLabel labeled Hide # by physical separation, function self.guestWifi_lbl.move (5, 100) # Greeting widget also has a label self.greeting = QLabel ('', itself) # The same indent is in the form of other self-control. Self.greeting.move (175, 100) # Build button is a push button self Build_button = QPushButton ('submit', manually) # Keep it on the bottom right, # other interactive widgets from the sync itself. Build_button.setMinimumWidth (145) self.build_button.move (250, 150) def run (manually): # Show form self.show () # qt_app run qt application. Exec_ () app = pygui () app.run () ` 

And here is the Python script, (I know that it works because I already print it from the value of the script Instead of returning it in the form of a.)

  #! BeautifulSoup import BeautifulSoup import re def /usr/bin/python2.7 import getWifiPassword (username, password) Urllib2 Getpass: URL = 'someurl' # username = getpass._raw_input ( 'What's your username? " ) # password = getpass.unix_getpass ( 'password') P = urllib2.HTTPPasswordMgrWithDefaultRealm () p.add_password (No, URL, username, password) handler = urllib2.HTTPBasicAuthHandler (P) opener = urllib2.build_opener (handler ) Urllib2.install_opener (opener) page = urllib2.urlopen (url) .read () soup = BeautifulSoup (page) data = date Soup.findAll ('Strong') for D in A: value = re.sub (".? & Lt; * & gt;" "", str (d)) return value  
< P> Any help would be greatly appreciated as Qt and GTK actually kick my butt. Thanks!


No comments:

Post a Comment