( endi123 | 2020. 02. 10., h - 07:20 )

Szerkesztve: 2020. 02. 10., h - 07:22

GTK3 + WebKit böngésző, ablakkeret nélkül

Telepítendő csomagok (Ubuntu 18.04.latest elnevezések):

  • python3-gi
  • gir1.2-webkit2-4.0
  • libwebkit2gtk-4.0-37  (ezt Ubuntu-n behúzza a előző, talán más rendszeren nem)
#!/usr/bin/env python3

import sys
import os

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('WebKit2', '4.0')
from gi.repository import Gtk, Gdk, WebKit2


class Browser(Gtk.Window):
    def __init__(self, *args, **kwargs):
        super(Browser, self).__init__(*args, **kwargs)
        self.set_title("Bongeszo")
        
        self.connect("destroy", Gtk.main_quit)
        self.connect("map", self.on_map)
        self.set_size_request(800, 600) # set minimum size allowed
        
        self.webview = WebKit2.WebView()
        self.webview.load_uri("https://hup.hu/node/167808#comment-2437556")
        
        self.set_decorated(False)
        self.add(self.webview)
        self.show_all()
        
    def on_map(self, *args): # to be called when the window is shown
#    	screen = Gdk.Screen.get_default()
        screen = self.get_window().get_screen()
        x = screen.get_width() - self.get_size().width
        y = 0
        self.move(x, y)
        self.set_keep_above(True)
#        self.fullscreen() # uncomment if you want fullscreen browser
#        self.resize(width, height) # use resize() here if you need screen-size dependent window-size

        
if __name__ == "__main__":
    Gtk.init(sys.argv)
    browser = Browser()
    Gtk.main()