コード例 #1
0
class Main(QMainWindow):
    """Main Window Class
    Define
    """

    def __init__(self):
        QMainWindow.__init__(self, parent=None)
        # Setup pyuic generated code
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #Parse RSS feed
        ad = feedparser.parse("http://www.appuntidigitali.it/feed")
        #Create article parser
        self.ap = ArticleParser()
        #Populate TreeWiget with feed elements
        for entry in ad.entries:
            item = QTreeWidgetItem([
                entry.title,
                entry.author,
                entry.slash_comments,
                entry.link,
                ])
            self.ui.treeWidget.addTopLevelItem(item)

    def on_treeWidget_itemDoubleClicked(self):
        """ Load feed item URL in the webview on doubleclick
        Show article's title in a text label
        """
        url = str(self.ui.treeWidget.currentItem().text(3))
        self.ui.webView.setHtml(self.ap.get_article(url))
        self.ui.title.setText(self.ui.treeWidget.currentItem().text(0))

    def on_actionQuit_triggered(self):
        """Exit from main window when actionQuit is triggered"""
        self.close()
コード例 #2
0
 def __init__(self):
     QMainWindow.__init__(self, parent=None)
     # Setup pyuic generated code
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     #Parse RSS feed
     ad = feedparser.parse("http://www.appuntidigitali.it/feed")
     #Create article parser
     self.ap = ArticleParser()
     #Populate TreeWiget with feed elements
     for entry in ad.entries:
         item = QTreeWidgetItem([
             entry.title,
             entry.author,
             entry.slash_comments,
             entry.link,
             ])
         self.ui.treeWidget.addTopLevelItem(item)