hosts-switch/usr/lib/hosts-switch/hosts-switch.py

65 lines
1.1 KiB
Python
Executable File

#!/usr/bin/python3
import gi, os, sys
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib, Gio, GObject, GdkPixbuf
from webengine.gtk3 import WebEngine, create_setting, create_hmr_server
from window import Window
APP_ID = 'fun.wkit.hosts-switch'
__dir__ = os.path.dirname(os.path.realpath(__file__))
web_root = os.path.join(__dir__, './webapp')
class Application(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self, application_id = APP_ID)
self.window = Window()
web = WebEngine(self.window)
setting = create_setting({"devtools": True})
hmr = create_hmr_server()
web.set_root(web_root)
web.use(setting).use(hmr)
web.connect('quit', self.quit_all)
web.load()
self.window.add(web)
def do_activate(self):
self.set_app_menu(None)
self.set_menubar(None)
self.add_window(self.window)
self.window.show_all()
def quit_all(self):
self.remove_window(self.window)
if __name__ == "__main__":
try:
app = Application()
app.run(sys.argv)
except Exception as err:
print(err)
pass
伪域名解析工具。
JavaScript 77.1%
CSS 10.9%
Python 6.2%
HTML 3%
Shell 2.8%