├── .gitignore ├── LICENSE ├── README.md ├── gtwitterk ├── requirements.txt ├── screenshot.png ├── window.py └── window.ui /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .idea/ 3 | *.pyc 4 | *~ 5 | .cache 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GTwitterK 2 | 3 | ![screenshot](screenshot.png?raw=true) 4 | 5 | A simple example of a Twitter app using GTK, Webkit2GTK and Python 3. 6 | 7 | Launch this by running the following command: 8 | ``` 9 | ./gtwitterk 10 | ``` 11 | -------------------------------------------------------------------------------- /gtwitterk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os 3 | import sys 4 | import gi 5 | gi.require_version('Gtk', '3.0') 6 | from gi.repository import Gtk 7 | 8 | # Make sure we're always in the right directory 9 | LAUNCH_PATH = os.path.dirname(os.path.realpath(__file__)) 10 | sys.path.insert(0, LAUNCH_PATH) 11 | os.chdir(LAUNCH_PATH) 12 | from window import Window 13 | 14 | # Create the window 15 | main_window = Window() 16 | main_window.connect("destroy", Gtk.main_quit) 17 | 18 | # Launch the application 19 | Gtk.main() 20 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyGObject -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharkwouter/GTwitterK/db40644509148d7e8dc7fb89ae8a206f16dea605/screenshot.png -------------------------------------------------------------------------------- /window.py: -------------------------------------------------------------------------------- 1 | import gi 2 | gi.require_version('Gtk', '3.0') 3 | gi.require_version('WebKit2', '4.0') 4 | from gi.repository import Gtk, WebKit2 5 | 6 | 7 | @Gtk.Template.from_file("window.ui") 8 | class Window(Gtk.ApplicationWindow): 9 | # Load the Window class from the ui file 10 | __gtype_name__ = "Window" 11 | 12 | # Load widgets from ui file 13 | button_back = Gtk.Template.Child() 14 | button_forward = Gtk.Template.Child() 15 | webview_container = Gtk.Template.Child() 16 | 17 | def __init__(self, name="GTwitterK"): 18 | Gtk.ApplicationWindow.__init__(self, title=name) 19 | 20 | # Create webview which will show twitter 21 | context = WebKit2.WebContext.new() 22 | self.webview = WebKit2.WebView.new_with_context(context) 23 | 24 | # Set persistent cookies 25 | self.cookie_manager = context.get_cookie_manager() 26 | self.cookie_manager.set_persistent_storage(".cache", WebKit2.CookiePersistentStorage.SQLITE) 27 | 28 | self.webview.load_uri("https://mobile.twitter.com/") 29 | 30 | self.webview_container.add(self.webview) 31 | self.show_all() 32 | 33 | @Gtk.Template.Callback("on_button_back_clicked") 34 | def back(self, widget): 35 | self.webview.go_back() 36 | 37 | @Gtk.Template.Callback("on_button_forward_clicked") 38 | def forward(self, widget): 39 | self.webview.go_forward() 40 | 41 | @Gtk.Template.Callback("on_button_compose_clicked") 42 | def compose(self, widget): 43 | self.webview.load_uri("https://mobile.twitter.com/compose/tweet") 44 | 45 | -------------------------------------------------------------------------------- /window.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 78 | 79 | --------------------------------------------------------------------------------