Created
December 12, 2016 04:33
-
-
Save AnishN/c1293820966d934abdba167079ef3f81 to your computer and use it in GitHub Desktop.
Custom Webpage Desktop using Python + Gtk3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gi | |
gi.require_version('WebKit', '3.0') | |
from gi.repository import WebKit, Gtk, Gdk | |
import os, urllib | |
class App: | |
def __init__(self): | |
win = Gtk.Window() | |
screen = win.get_screen() | |
rgba = screen.get_rgba_visual() | |
win.set_visual(rgba) | |
win.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0,0,0,0)) | |
win.connect('delete-event', Gtk.main_quit) | |
win.set_type_hint(Gdk.WindowTypeHint.DESKTOP) | |
win.set_title("MyAwesomeDesktop") | |
win.set_skip_taskbar_hint(True) | |
win.set_decorated(False) | |
win.set_keep_below(True) | |
win.stick() | |
view = self.createWebApp() | |
win.add(view) | |
win.move(0,0) | |
win.resize(1366, 768) | |
win.show_all() | |
def createWebApp(self): | |
view = WebKit.WebView() | |
view.set_transparent(True) | |
settings = view.get_settings() | |
#settings.set_property('enable-file-access-from-file-uris', 1) | |
view.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0,0,0,0)) | |
htmlStr = "http://www.google.com" | |
htmlURL = urllib.urlopen(htmlStr) | |
#print os.path.abspath(htmlStr) | |
#htmlPath = "file://" + os.path.abspath(htmlStr) | |
#view.load_html_string(htmlURL.read(), htmlPath) | |
view.load_html_string(htmlURL.read(), htmlStr) | |
return view | |
if __name__ == "__main__": | |
App() | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the commented-out lines if you are working with a local .html file.