class Zaguan(object): def __init__(self, uri, controller=None): if controller is None: controller = WebContainerController() self.controller = controller self.uri = uri self.on_close = None def run(self, settings=None, window=None, debug=False, on_close=None): self.on_close = on_close threads_init() if window is None: self.window = Window(WindowType.TOPLEVEL) self.window.set_position(WindowPosition.CENTER_ALWAYS) else: self.window = window browser = self.controller.get_browser(self.uri, debug=debug, settings=settings) self.window.connect("delete-event", self.quit) self.window.set_border_width(0) self.window.add(browser) sleep(1) self.window.show_all() self.window.show() main() def quit(self, widget, event): if self.on_close is not None: self.on_close(widget, event)
def load_tlp_config(_, window: Gtk.Window, reloadtlpconfig: bool) -> None: """Load TLP configuration to UI.""" if reloadtlpconfig: init_tlp_file_config() newmainbox = create_main_box(window) children = window.get_children() for child in children: window.remove(child) window.add(newmainbox) window.show_all()
def load_tlp_config(self, window: Gtk.Window, reloadtlpconfig: bool): if reloadtlpconfig: settings.tlpconfig = read_tlp_file_config(settings.tlpconfigfile) settings.tlpconfig_original = copy.deepcopy(settings.tlpconfig) newmainbox = create_main_box(window) children = window.get_children() for child in children: window.remove(child) window.add(newmainbox) window.show_all()
def load_tlp_config(_, window: Gtk.Window, reloadtlpconfig: bool) -> None: """Load TLP configuration to UI""" if reloadtlpconfig: settings.tlpconfig = read_tlp_file_config(settings.tlpconfigfile) settings.tlpconfig_original = copy.deepcopy(settings.tlpconfig) newmainbox = create_main_box(window) children = window.get_children() for child in children: window.remove(child) window.add(newmainbox) window.show_all()
def add_source(self, source_list_widget: Gtk.ListBox, window: Gtk.Window): dialog = Gtk.FileChooserDialog( "Wybierz plik z przykładowymi tekstami", window, Gtk.FileChooserAction.OPEN, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK, ), ) response = dialog.run() if response == Gtk.ResponseType.OK: print(dialog.get_filename()) lines = open(dialog.get_filename(), encoding='utf8').read().splitlines() self.__marcow_chain.feed(lines) source_list_widget.add(Gtk.Label(dialog.get_filename())) window.show_all() dialog.destroy()