Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Feed reader with Gtk , python 3 and webkit
from gi.repository import Gtk
from gi.repository import WebKit
import feedparser
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Hello World")
# self.set_size_request(1000, 700)
self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,spacing=2)
self.add(self.vbox)
self.hbox = Gtk.Box(spacing=2)
self.hbox2 = Gtk.Box(spacing=2)
self.vbox.pack_start(self.hbox, True, True, 0)
self.vbox.pack_start(self.hbox2, True, True, 0)
self.liststore = Gtk.ListStore(str, str)
self.treeview = Gtk.TreeView(self.liststore)
self.txtrenderer = Gtk.CellRendererText()
self.column1 = Gtk.TreeViewColumn('Feed summary', self.txtrenderer,text=1)
self.treeview.append_column(self.column1)
self.treeview.connect("row-activated", self.tree_doubleclick)
self.hbox.pack_start(self.treeview, True, True, 0)
self.liststore.append(["The Art of Computer Programming","R"])
self.liststore.append(["The Art","ARss"])
self.liststore.append(["Theing","Hossein"])
self.webview = WebKit.WebView()
self.set_title("Really Simple RSS feed thing")
self.webview.open('http://127.0.0.1')
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_hexpand(True)
scrolledwindow.set_vexpand(True)
scrolledwindow.add(self.webview)
self.entry = Gtk.Entry(text='Enter Adress Here')
self.hbox2.pack_start(self.entry, True, True, 0)
self.button = Gtk.Button("Import")
self.button.connect("clicked", self.on_button_clicked)
self.hbox2.pack_start(self.button, True, True, 0)
self.hbox.pack_start(scrolledwindow, True, True, 0)
def tree_doubleclick(self, tree, path, column):
url = self.liststore[path[0]][0]
print(url)
def on_button_clicked(self):
print(self.entry.get_text())
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.