我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.main_quit()。
def __init__(self): Gtk.Window.__init__(self) self.get_settings().set_property( "gtk-application-prefer-dark-theme", True) self.connect('destroy', lambda x: Gtk.main_quit()) # Layout self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) self.add(self.box) self.abar = Gtk.ActionBar() self.box.pack_end(self.abar, False, False, 0) self.build_contents() # Finalize the window itself self.set_titlebar(self.headerbar()) self.set_title("Foreign Package Installer") self.set_icon_name("system-software-install") self.set_size_request(600, 450) self.set_position(Gtk.WindowPosition.CENTER) self.show_all()
def _quit(self, *args): if len(self.filesObject) > 0: unsaved = False unsavedFile = '' for i,f in enumerate(self.filesObject): if not f['curText'] == f['originalText']: unsaved = True unsavedFile = os.path.basename(f['path']) break if unsaved: res = self.confirm('{} is not saved, are you sure you want to exit without saving?'.format(os.path.basename(f['path']))) if res: self.linter.do_deactivate() Gtk.main_quit() else: return True else: self.linter.do_deactivate() Gtk.main_quit() else: self.linter.do_deactivate() Gtk.main_quit()
def __init__(self): Gtk.Window.__init__(self, title="BTC Widget") self._ticker_labels = {} self._tickers_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._create_ticker_labels() self._graph = btcwidget.graph.Graph(config['dark_theme']) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox.pack_start(self._tickers_vbox, False, False, 5) vbox.pack_start(self._graph, True, True, 0) self.set_icon_from_file(self._ICON_PATH) self.connect('delete-event', Gtk.main_quit) self.add(vbox) self.show_all() self._indicator = Indicator(self) # self.open_options()
def _create_menu(self): menu = Gtk.Menu() self._menu_item = Gtk.MenuItem("Bitcoin") self._menu_item.connect('activate', self._on_show_item_activate) menu.append(self._menu_item) options_menu_item = Gtk.MenuItem("Options...") options_menu_item.connect('activate', self._on_options_item_activate) menu.append(options_menu_item) alarm_menu_item = Gtk.MenuItem("Alarms...") alarm_menu_item.connect('activate', self._on_alarm_item_activate) menu.append(alarm_menu_item) quit_menu_item = Gtk.MenuItem("Quit") quit_menu_item.connect('activate', Gtk.main_quit) menu.append(quit_menu_item) menu.show_all() return menu
def __init__(self, datadir): Gtk.Window.__init__(self) self.icons = stock.EditorIconFactory(self, datadir) self.connect('destroy', lambda w: Gtk.main_quit()) self.g_help_window = None # toplevel_vbox: # -menubar # -toolbar # -notebook # -statusbar self.toplevel_vbox = Gtk.VBox() self.add(self.toplevel_vbox) self.create_menu_and_toolbar() self.g_notebook = Gtk.Notebook() self.toplevel_vbox.pack_start(self.g_notebook, True, True, 0) self.vbox = Gtk.VBox() self.toplevel_vbox.pack_start(self.vbox, True, True, 0) self.create_mainwin_ui() self.show_all()
def quit_program(self, *w): can_quit = True for dlg in gu.EditorDialogBase.instance_dict.values(): if dlg.close_window(): dlg.destroy() else: can_quit = False break if can_quit: solfege.app.quit_program() Gtk.main_quit() else: return True
def main(): win = Gtk.Window() win.connect('destroy', Gtk.main_quit) win.set_default_size(Width, Height) global drawingarea drawingarea = Gtk.DrawingArea() drawingarea.connect('draw', draw) drawing_event_box = Gtk.EventBox() drawing_event_box.add(drawingarea) drawing_event_box.connect('button-press-event', mouse_pressed) drawing_event_box.connect('motion-notify-event', mouse_dragged) check_useIk = Gtk.CheckButton("Lock Forearm & Hand") check_useIk.set_active(True) check_useIk.connect("toggled", check_toggled) box = Gtk.VBox() box.pack_start(check_useIk, False, True, 0) box.pack_start(drawing_event_box, True, True, 0) win.add(box) win.show_all() Gtk.main()
def quit(self, widget, event=None, data=None): '''Main quit. @param widget: who sent the signal. @param event: the event that happened @param data: optional data to receive. ''' msg = ("Do you really want to quit?") dlg = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg) dlg.set_default_response(Gtk.ResponseType.YES) opt = dlg.run() dlg.destroy() if opt != Gtk.ResponseType.YES: return True Gtk.main_quit() if self.dasm_process: self.dasm_process.terminate() return True
def __init__(self): window = Gtk.Window(Gtk.WindowType.TOPLEVEL) window.set_title("Audio-Player") window.set_default_size(300, -1) window.connect("destroy", Gtk.main_quit, "WM destroy") vbox = Gtk.VBox() window.add(vbox) self.entry = Gtk.Entry() vbox.pack_start(self.entry, False, True, 0) self.button = Gtk.Button("Start") self.button.connect("clicked", self.start_stop) vbox.add(self.button) window.show_all() self.player = Gst.ElementFactory.make("playbin", "player") fakesink = Gst.ElementFactory.make("fakesink", "fakesink") self.player.set_property("video-sink", fakesink) bus = self.player.get_bus() bus.add_signal_watch() bus.connect("message", self.on_message)
def __init__(self): Gtk.Window.__init__(self,title="Ghetto OMR") self.set_resizable(True) self.connect("configure-event",self.new_dim) self.connect("delete-event",Gtk.main_quit) self.win_width = 200 self.win_height = 200 something = Gtk.Label("SOMETHING") self.maximize() self.count =0 self.main = MainGrid(self) self.add(self.main) # # self.main.destroy() # self.main = Gtk.Label("SOMETHING") # self.add(self.main)
def make_menu(self, event_button, event_time): menu = gtk.Menu() # show about dialog about = gtk.MenuItem("About") about.show() menu.append(about) about.connect('activate', self.show_about_dialog) # add quit item quit = gtk.MenuItem("Quit") quit.show() menu.append(quit) quit.connect('activate', gtk.main_quit) menu.popup(None, None, None, None, event_button, event_time)
def __init__(self): Gtk.Window.__init__(self, title = "Choose a method of Sculpture Generation") self.set_border_width(10) self.set_default_size(400, 50) #initiates Gtk box window self.box = Gtk.Box(spacing = 6) self.add(self.box) #Initializes Vector Animation Button, places in box self.VectorButton = Gtk.Button(label = "Vector Animation") self.VectorButton.connect("clicked", self.on_VectorButton_clicked) self.VectorButton.connect("clicked", Gtk.main_quit) self.box.pack_start(self.VectorButton, True, True, 0) #Initializes Perlin Noise Button, places in box self.PerlinButton = Gtk.Button(label = "Perlin Noise") self.PerlinButton.connect("clicked", self.on_PerlinButton_clicked) self.PerlinButton.connect("clicked", Gtk.main_quit) self.box.pack_start(self.PerlinButton, True, True, 0) #when VectorButton clicked, toggles to new GUI
def __init__(self, tracker, url, tab_id): self.alive = True self.tracker = tracker self.uuid = tab_id self.plug = Gtk.Plug() self.plug.connect("destroy", Gtk.main_quit) self.webview = WebKit.WebView() settings = self.webview.get_settings() settings.set_property("enable-developer-extras", True) #settings.set_property("enable-webgl", True) self.webview.connect("load-started", self.load_start_event) self.webview.connect("notify::title", self.push_title_change) scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(self.webview) self.plug.set_default_size(800, 600) self.plug.add(scrolled_window) self.plug.show_all() self.send("attach_event", plug_id = str(self.plug.get_id())) self.navigate_event(url)
def watch_process(self, io, condition, process_name): if condition is GLib.IO_HUP: os.system('rm ' + current_dir + '/game/cache') os.system('mkdir -p ' + current_dir + '/game/cache') self.config_save() Gtk.main_quit() return False print io.readline().strip('\n') self.progressbar.pulse() return True
def cb_button_save(self, button): config_file = current_dir + '/settings.ini' config_parser = ConfigParser.ConfigParser() config_parser.read(config_file) config_parser.set('Settings', 'exe', self.exe) config_parser.set('Settings', 'width', self.width) config_parser.set('Settings', 'height', self.height) new_config_file = open(config_file, 'w') config_parser.write(new_config_file) new_config_file.close() self.modify_start_file() self.modify_registry() Gtk.main_quit()
def cb_button_save(self, button): config_file = current_dir + '/settings.ini' config_parser = ConfigParser.ConfigParser() config_parser.read(config_file) if not os.path.exists(game_dir + '/Konung2.exe.original'): os.system('mv ' + game_dir + '/Konung2.exe ' + game_dir + '/Konung2.exe.original') selected_resolution = self.combobox_resolution.get_active_text() os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/* ' + game_dir) config_parser.set('Settings', 'resolution', self.resolution) new_config_file = open(config_file, 'w') config_parser.write(new_config_file) new_config_file.close() Gtk.main_quit()
def cb_button_save(self, button): if not os.path.exists(game_dir + '/Nosferatu.exe.original'): os.system('mv ' + game_dir + '/Nosferatu.exe ' + game_dir + '/Nosferatu.exe.original') selected_resolution = self.combobox_resolution.get_active_text() os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/Nosferatu.exe ' + game_dir) config_file = current_dir + '/settings.ini' config_parser = ConfigParser.ConfigParser() config_parser.read(config_file) config_parser.set('Settings', 'resolution', self.resolution) new_config_file = open(config_file, 'w') config_parser.write(new_config_file) new_config_file.close() Gtk.main_quit()
def cb_button_save(self, button): if (self.custom_width == '') or (self.custom_height == ''): message_dialog = Gtk.MessageDialog( self.main_window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Error") ) message_dialog.format_secondary_text(_("You have to set width and height.")) content_area = message_dialog.get_content_area() content_area.set_property('margin-left', 10) content_area.set_property('margin-right', 10) content_area.set_property('margin-top', 10) content_area.set_property('margin-bottom', 10) message_dialog.run() message_dialog.destroy() return self.config_save() Gtk.main_quit()
def cb_button_save(self, button): if not os.path.exists(game_dir + '/Game/game.exe.original'): os.system('mv ' + game_dir + '/Game/game.exe ' + game_dir + '/Game/game.exe.original') selected_resolution = self.combobox_resolution.get_active_text() os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/game.exe ' + game_dir + '/Game') config_file = current_dir + '/settings.ini' config_parser = ConfigParser.ConfigParser() config_parser.read(config_file) config_parser.set('Settings', 'resolution', self.resolution) new_config_file = open(config_file, 'w') config_parser.write(new_config_file) new_config_file.close() Gtk.main_quit()
def cb_button_save(self, button): config_file = current_dir + '/settings.ini' config_parser = ConfigParser.ConfigParser() config_parser.read(config_file) if is_english_version: self.modify_start_file() config_parser.set('Settings', 'exe', self.exe) else: if not os.path.exists(game_dir + '/konung.exe.original'): os.system('mv ' + game_dir + '/konung.exe ' + game_dir + '/konung.exe.original') selected_resolution = self.combobox_resolution.get_active_text() os.system('cp ' + game_dir + '/res_patch/' + selected_resolution + '/* ' + game_dir) config_parser.set('Settings', 'resolution', self.resolution) new_config_file = open(config_file, 'w') config_parser.write(new_config_file) new_config_file.close() Gtk.main_quit()
def on_delete_window(*args): Gtk.main_quit(*args)
def quit_app(self, window, event): self.config_save() Gtk.main_quit()
def quit_app(self, window, event): Gtk.main_quit()
def cb_button_save(self, button): self.dosbox_config_save() Gtk.main_quit()
def watch_process(self, io, condition, process_name): if condition is GLib.IO_HUP: self.progressbar.pulse() self.n_files_to_copy -= 1 if self.n_files_to_copy == 0: message_dialog = Gtk.MessageDialog( self.main_window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Done!"), width_request = 360 ) content_area = message_dialog.get_content_area() content_area.set_property('margin-left', 10) content_area.set_property('margin-right', 10) content_area.set_property('margin-top', 10) content_area.set_property('margin-bottom', 10) action_area = message_dialog.get_action_area() action_area.set_property('spacing', 10) self.main_window.hide() message_dialog.run() message_dialog.destroy() Gtk.main_quit() return False while Gtk.events_pending(): Gtk.main_iteration_do(False) return True
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) store = Gtk.ListStore(str, str, str, str) self.populate_store(store) self.treeview = Gtk.TreeView(model=store) renderer = Gtk.CellRendererText() column_catalog = Gtk.TreeViewColumn('Catalog Name', renderer, text=0) column_catalog.set_sort_column_id(0) self.treeview.append_column(column_catalog) column_dbname = Gtk.TreeViewColumn('Database Name', renderer, text=1) column_dbname.set_sort_column_id(1) self.treeview.append_column(column_dbname) column_charset = Gtk.TreeViewColumn('Character Set', renderer, text=2) column_charset.set_sort_column_id(2) self.treeview.append_column(column_charset) column_collation = Gtk.TreeViewColumn('Collation', renderer, text=3) column_collation.set_sort_column_id(3) self.treeview.append_column(column_collation) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.set_min_content_height(200) self.add(scrolled_window) self.show_all() # Add data to ListStore
def on_window_close(self, widget, what): Gtk.main_quit()
def quit(self): # Reset everything: set_onscreen_keyboard(False) set_keyboard(True) set_touchpad(True) set_rotation("normal") Gtk.main_quit()
def onDeleteWindow(self, *args): Gtk.main_quit(*args)
def exit_window(self): self.window.destroy() Gtk.main_quit()
def stop(self, *args): self.pm.close() Gtk.main_quit()
def on_stage_destroy(self, x): gtk.main_quit()
def quit(self, *arg): print('Quitting Gtk.') Gtk.main_quit()
def signalInterrupt(self, selfnum, frame): self.dataThread.stop() io.savemat('p300Data_jct_2_17_10.mat', {'data' : self.dataThread.data, 'timestamps' : self.timestamps, 'markers' : self.markers}) gtk.main_quit()
def __init__(self): super(WelcomeWindow, self).__init__() self.hb = Gtk.HeaderBar() self.hb.set_show_close_button(True) self.hb.set_title("Py IDE") self.set_titlebar(self.hb) self.currentPage = None self.hbButtons = [] self.language = '' self.showHome() ################################################################## self.set_size_request(800, 400) self.set_resizable(False) self.loadSettings() self.connect('destroy', Gtk.main_quit) self.show_all() Gtk.main()
def quit(self): self.stopped = True self.quitting = True #engine.movenow() self.save_settings() gv.ucib.stop_engine() gv.uciw.stop_engine() Gtk.main_quit() return False
def __destroy(self,*args): from gi.repository import Gtk Gtk.main_quit(*args)
def quit(self, widget): if self.services['timeout']: GObject.source_remove(self.services['timeout']) os.unlink(self.cfg_cls.LOCKFILE) Gtk.main_quit()
def on_window_delete_event(self, *args): Gtk.main_quit(*args)
def decorate_gtk_mainfunc(function): def decorated_function(*args, **kwargs): run_mainloop(function, Gtk.main_quit, None, *args, **kwargs) return decorated_function # We could override Gtk.main_iteration and Gtk.main_iteration_do too, # but that does not seem to be necessary (because they don't dispatch # our event handler, but instead return; this means that the exception # is raised anyways).
def on_delete_window(self, *args): for ch in self.notebook.get_children(): ch.disconnect_sbrick() Gtk.main_quit(*args)
def quit(self): """Exit the UI event loop.""" GObject.idle_add(Gtk.main_quit)
def __init__(self): """setup UI thingies, don't do any fetching or DBus communication yet""" # minimal global state to pass around data between steps where otherwise difficult self.selected_meta = None self.prefix = get_prefix() self.builder = Gtk.Builder() for b in builder_files: p = os.path.join(self.prefix, 'share/eduvpn/builder', b) if not os.access(p, os.R_OK): logger.error("Can't find {}! That is quite an important file.".format(p)) raise Exception self.builder.add_from_file(p) # the signals coming from the GTK ui handlers = { "delete_window": Gtk.main_quit, "add_config": self.add, "del_config": self.delete, "select_config": self.select, "connect_set": self.switched, } self.builder.connect_signals(handlers) self.window = self.builder.get_object('eduvpn-window') self.verifier = make_verifier(verify_key) self.window.set_position(Gtk.WindowPosition.CENTER)