2 from PyQt4 import QtGui
3 from PyQt4 import QtCore
4 from PyQt4.QtWebKit import QWebView
8 def __init__(self, url):
9 self.feed=feedparser.parse(url)
12 return self.feed["entries"]
14 def getItem(self, index):
15 return self.feed["entries"][index]
17 def getArticle(self,index):
18 entry = self.feed["entries"][index]
19 #text = "<h4><a href=\"" + entry["link"] + "\">" + entry["title"] + "</a></h4>"
20 text = "<small>" + entry["title"] + "</small>"
21 text = text + "<BR />"
22 text = text + entry["summary"]
26 listOfFeeds = ["http://rss.slashdot.org/Slashdot/slashdot",]
28 def downloadFeeds(self):
30 for item in self.listOfFeeds:
31 self.feeds.append(Feed(item))
33 def getFeed(self, index):
34 return self.feeds[index]
36 def getListOfFeeds(self):
37 return self.listOfFeeds
40 class ArticleDisplay(QtGui.QMainWindow):
41 def __init__(self, parent, feed, index):
42 QtGui.QMainWindow.__init__(self, parent)
43 #self.setWindowTitle('Feeding It')
45 text = feed.getArticle(index)
52 class ListingDisplay(QtGui.QMainWindow):
53 def __init__(self, parent, feed):
54 QtGui.QMainWindow.__init__(self, parent)
56 listWidget = QtGui.QListWidget(self)
58 for item in feed.getTitles():
59 QtGui.QListWidgetItem(item["title"], listWidget)
61 #button.connect("clicked", self.button_clicked, self, self.window, currentfeed, index)
67 class FeedingIt(QtGui.QMainWindow):
69 def __init__(self, parent=None):
70 QtGui.QMainWindow.__init__(self, parent)
71 self.setWindowTitle('Feeding It')
73 exit = QtGui.QAction(None, 'Exit', self)
74 exit.setStatusTip('Exit application')
75 self.connect(exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
77 self.mainWidget=QtGui.QWidget(self) # dummy widget to contain the
79 self.setCentralWidget(self.mainWidget)
80 self.mainLayout=QtGui.QVBoxLayout(self.mainWidget)
83 exitAction = QtGui.QAction('Exit', self)
84 self.connect(exitAction, QtCore.SIGNAL('triggered()'), self.close)
85 menubar = self.menuBar()
86 file = menubar.addAction(exitAction)
88 self.listing=Listing()
91 listOfFeeds = QtGui.QListWidget(self.mainWidget)
93 tmp = ["test","test1", "test2"]
94 #for item in self.listing.getListOfFeeds():
96 QtGui.QListWidgetItem(item, listOfFeeds)
98 #layout = QtGui.QVBoxLayout()
99 #layout.addWidget(listOfFeeds)
100 #self.setLayout(layout)
102 def displayListing(self):
104 # self.window.remove(self.pannableListing)
107 #self.vboxListing = gtk.VBox(False,10)
108 #self.pannableListing = hildon.PannableArea()
109 #self.pannableListing.add_with_viewport(self.vboxListing)
111 for key in self.listing.getListOfFeeds():
112 #button = gtk.Button(item)
113 #button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
114 # hildon.BUTTON_ARRANGEMENT_VERTICAL)
115 #button.set_text(self.listing.getFeedTitle(key), self.listing.getFeedUpdateTime(key))
116 #button.set_alignment(0,0,1,1)
117 #button.connect("clicked", self.buttonFeedClicked, self, self.window, key)
118 #self.vboxListing.pack_start(button, expand=False)
120 #self.window.add(self.pannableListing)
121 #self.window.show_all()
123 if __name__ == '__main__':
125 # Checking the configuration directory does exist
126 if not isdir(CONFIGDIR):
130 print "Error: Can't create configuration directory"
133 #Creating Qt application
134 app = QtGui.QApplication(sys.argv)
136 feedingIt = FeedingIt()
139 #Starting the application's main loop
140 sys.exit(app.exec_())