limit=1".format(subreddit) headers = request = urllib2. Request(url, headers=headers) response = urllib2.urlopen(request) data = json.load(response) top_post = data['data']['children']['data'] return "'' by in ".format(**top_post) def run(self): for subreddit in self.subreddits: top_post = self._get_top_post(subreddit) self.sleep(2) objects which we can use.It's pretty self explanatory and the way we'd use that is by first making a list of subreddit names to pass to the thread and then calling it from the main UI code like this: That's it.
from Py Qt4 import Qt Gui import sys import design class Threading Tutorial(Qt Gui. Ui_Main Window): def __init__(self): super(self.__class__, self).__init__() self.setup Ui(self) def main(): app = Qt Gui.
QApplication(sys.argv) form = Threading Tutorial() form.show() app.exec_() if __name__ == '__main__': main() So if you haven't worked with Py Qt or threading before you might be thinking: "Ok, I've got the reddit code, and I've got the GUI - I just call the reddit function and populate the data and it'll work" Well, it will technically work, but since the whole thing is one one main GUI thread your whole app will be frozen while the application/function executes.
The GUI code will be set up just like in the previous tutorial I wrote.
If you don't understand what some parts of it are doing check out that blog post before continuing.
Note that whether or not the text is drawn is dependent on the style. This function will check the version of the QStyle Option Progress Bar and fill in the additional values for a QStyle Option Progress Bar V2. If maximum is smaller than minimum, minimum becomes the only legal value.