我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gtk.main_quit()。
def apply_settings(self, widget, data=None): # ???????? ????, ???? ?? ?????? self.window.hide() if self.white_bg_check.get_active(): self.data['properties']['white_bg'] = True else: self.data['properties']['white_bg'] = False if self.auto_levels_check.get_active(): self.data['properties']['auto_levels'] = True else: self.data['properties']['auto_levels'] = False self.data['properties']['resolution'] = int(self.resolution_cb.get_active_text()) config = open(self.path, 'wb') json.dump(self.data, config, indent=3) config.close() gtk.main_quit() # ??? ??????? ???????????? ?????????????? ?????????? ???????
def main_window(type, title, width, height): if type == 'toplevel': window = gtk.Window(gtk.WINDOW_TOPLEVEL) elif type == 'popup': window = gtk.Window(gtk.WINDOW_POPUP) window.set_position(gtk.WIN_POS_CENTER) window.connect('destroy', lambda x: gtk.main_quit()) window.set_size_request(width, height) window.set_resizable(True) if title == False: window.set_decorated(False) else: window.set_title(title) return window
def run(self, graphic): window = gtk.Window() self.__window = window window.set_default_size(200, 200) vbox = gtk.VBox() window.add(vbox) render = GtkGraphicRenderer(graphic) self.__render = render vbox.pack_end(render, True, True, 0) hbox = gtk.HBox() vbox.pack_start(hbox, False, False, 0) smaller_zoom = gtk.Button("Zoom Out") smaller_zoom.connect("clicked", self.__set_smaller_cb) hbox.pack_start(smaller_zoom) bigger_zoom = gtk.Button("Zoom In") bigger_zoom.connect("clicked", self.__set_bigger_cb) hbox.pack_start(bigger_zoom) output_png = gtk.Button("Output Png") output_png.connect("clicked", self.__output_png_cb) hbox.pack_start(output_png) window.connect('destroy', gtk.main_quit) window.show_all() #gtk.bindings_activate(gtk.main_quit, 'q', 0) gtk.main()
def __init__(self): super(PyApp, self).__init__() self.set_title("Web Stalker Browser") self.set_size_request(1000,600) self.set_position(gtk.WIN_POS_CENTER) vbox = gtk.VBox(False, 5) scw = gtk.ScrolledWindow(None, None) web = webkit.WebView() url = sys.argv[1] web.open(url) scw.add(web) vbox.add(scw) gobject.threads_init() self.add(vbox) self.connect("destroy", gtk.main_quit) self.show_all()
def quit(self, widget, event=None): """Asks if user would like to save file before quitting, then quits the program.""" if self.toSave: if self.oneConfigFile: response = gtk.RESPONSE_YES else: dialog = gtk.Dialog("Save config?", self, gtk.DIALOG_MODAL, (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.get_content_area().add(gtk.Label("Save config before quitting?")) dialog.get_content_area().set_size_request(300, 100) dialog.show_all() response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_CANCEL: return True # Return True to stop it quitting when we hit "Cancel" elif response == gtk.RESPONSE_NO: gtk.main_quit() elif response == gtk.RESPONSE_YES: self.save() gtk.main_quit() else: gtk.main_quit()
def __init__(self, ttrss): self.ttrss = ttrss self.menu = gtk.Menu() quitter = gtk.ImageMenuItem(gtk.STOCK_QUIT) quitter.set_always_show_image(True) self.menu.append(quitter) quitter.show() quitter.connect("activate", gtk.main_quit) self.viewer = ArticleViewer() self.viewer.on_hide = self.update_articles self.status_icon = gtk.StatusIcon() self.status_icon.set_from_icon_name("mail-read") self.update_headlines() self.to = gtk.timeout_add(1000 * 60, self.update_headlines) self.status_icon.connect("activate", self.toggle_viewer) self.status_icon.connect("popup-menu", self.show_menu)
def lienInAmelia(): import gtk import webkit import gobject gobject.threads_init() window = gtk.Window() window.set_default_size(1100, 680) window.connect("destroy", lambda a: gtk.main_quit()) browser = webkit.WebView() browser.open("http://alfred-ia.org/essaye-moi/") window.add(browser) window.show_all() gtk.main()
def leave_app(self,widget=None,data=None): self.controller.camara_off() self.done = True self.win.destroy() gtk.main_quit()
def quit(self): self.done = True self.win.destroy() gtk.main_quit()
def _delete_event(self, widget, event, data=None): gtk.main_quit() return False
def compose_or_print(self, widget, data=None): # ???????? ????, ???? ?? ?????? self.window.hide() gimp.context_push() # ????????? ?????? ?????????? UNDO self.image.undo_group_start() # ?????? ??????? self.image.scale(self.mm_in_px(shelf['format']['width'], shelf['format']['resolution']), self.mm_in_px(shelf['format']['height'], shelf['format']['resolution'])) if self.oval_check.get_active(): self.oval(self.image, self.drawable) if self.gray_check.get_active(): self.to_grayscale(self.image, self.drawable) if self.border_check.get_active(): self.gray_frame(self.image) if self.angle_right_circular_radio.get_active(): self.angle(self.image, self.drawable, 'right_circular') elif self.angle_left_circular_radio.get_active(): self.angle(self.image, self.drawable, 'left_circular') elif self.angle_right_direct_radio.get_active(): self.angle(self.image, self.drawable, 'right_direct') elif self.angle_left_direct_radio.get_active(): self.angle(self.image, self.drawable, 'left_direct') copys = self.copys_spin.get_value_as_int() paper = self.paper_cb.get_active_text() if data == 'print_it': print_photo = True else: print_photo = False self.print_functon(self.image, self.drawable, paper, copys, print_photo) # ????????? ???????????? ?? ??????? gimp.displays_flush() # ????????? ?????? ?????????? UNDO self.image.undo_group_end() gimp.context_pop() gtk.main_quit() # ??? ??????? ???????????? ?????????????? ????????
def destroy(self, widget, data=None): gtk.main_quit() ######################################################### #-------- ??? ? ?????? ?????, ? ??? ??????? ??????? ----# #########################################################
def quit(self, *args): self.win32ext.remove_notify_icon() gtk.main_quit()
def create_webview(): webview = webkit.WebView() webview.connect('close-web-view', lambda x: gtk.main_quit()) webview.connect("navigation-policy-decision-requested", script_action) settings = webview.get_settings() settings.set_property('enable_plugins', True) settings.set_property('enable-scripts', True) return webview
def save_screenshot(window, output): width, height = window.get_size() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) screenshot = pixbuf.get_from_drawable(window.window, window.get_colormap(), 0, 0, 0, 0, width, height) screenshot.save(output, 'png') gtk.main_quit()
def destroy(self, widget, data=None): if self.xww: os.system("kill {}".format(self.xww.pid + 1)) gtk.main_quit()
def destroy(self, widget, data=None): gtk.main_quit()
def _our_mainquit(): # XXX: gtk.main_quit() (which is used for crash()) raises an exception if # gtk.main_level() == 0; however, all the tests freeze if we use this # function to stop the reactor. what gives? (I believe this may have been # a stupid mistake where I forgot to import gtk here... I will remove this # comment if the tests pass) import gtk if gtk.main_level(): gtk.main_quit()
def crash(self): import gtk # mainquit is deprecated in newer versions if hasattr(gtk, 'main_quit'): gtk.main_quit() else: gtk.mainquit()
def crash(self): gtk.main_quit()
def _quit(self, *dummy_args): if self._update_timeout_id is not None: gobject.source_remove(self._update_timeout_id) self._update_timeout_id = None self.simulation.quit = True self.simulation.go.set() self.simulation.join() gtk.main_quit()
def _test(): from enchant.checker import SpellChecker text = "This is sme text with a fw speling errors in it. Here are a fw more to tst it ut." printf(["BEFORE:", text]) chk_dlg = GtkSpellCheckerDialog() chk_dlg.show() chk_dlg.connect('delete_event', gtk.main_quit) chkr = SpellChecker("en_US",text) chk_dlg.setSpellChecker(chkr) chk_dlg.updateUI() gtk.main()
def on_quit(self, widget, data=None): module_init.stop_all() os._exit(0) gtk.main_quit()
def _main_quit(*args, **kwargs): gtk.main_quit() return False
def inputhook(context): """ When the eventloop of prompt-toolkit is idle, call this inputhook. This will run the GTK main loop until the file descriptor `context.fileno()` becomes ready. :param context: An `InputHookContext` instance. """ def _main_quit(*a, **kw): gtk.main_quit() return False gobject.io_add_watch(context.fileno(), gobject.IO_IN, _main_quit) gtk.main()
def destroy(self, widget, data=None): print "destroy" gtk.main_quit()
def destroy(self, *args): if (not self.getModified()) or self.ask("There are unsaved files.\nContinue?"): self.active = False self.window.hide() kill = True for i in OPENWINDOWS: if i.active: kill = False OPENWINDOWS.remove(self) if kill: gtk.main_quit() return False return True
def destroy(self, *args): if not self.indep: self.window.hide() self.shown = False return True else: self.window.destroy() gtk.main_quit()
def copy_url(url): """Copy the url into the clipboard.""" # try windows first try: import win32clipboard except ImportError: # then give pbcopy a try. do that before gtk because # gtk might be installed on os x but nobody is interested # in the X11 clipboard there. from subprocess import Popen, PIPE try: client = Popen(['pbcopy'], stdin=PIPE) except OSError: try: import pygtk pygtk.require('2.0') import gtk import gobject except ImportError: return gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(url) gobject.idle_add(gtk.main_quit) gtk.main() else: client.stdin.write(url) client.stdin.close() client.wait() else: win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(url) win32clipboard.CloseClipboard()
def destroy(self, widget, data=None): self.zarj_comm.stop() gtk.main_quit()
def run( Widget, w, h, speed ): window = gtk.Window( ) window.connect( "delete-event", gtk.main_quit ) widget = Widget( w, h, speed ) widget.show( ) window.add( widget ) window.present( ) gtk.main( )
def destroy(self, widget): gtk.main_quit()
def destroy_cb(self, widget, data=None): gtk.main_quit()
def run(Widget): window = gtk.Window() window.connect("delete-event", gtk.main_quit) widget = Widget() widget.show() window.add(widget) window.present() gtk.main()
def delete_handler(self, *args): gtk.main_quit()
def quit(self, *ignored): if self.current_engine.playing: self.current_engine.stop() self._save_settings() gtk.main_quit() # quit()
def __init__(self): global args super(PyApp, self).__init__() self.set_title("Lasersaur") self.resize(1220, 610) self.set_position(gtk.WIN_POS_CENTER) self.connect("destroy", gtk.main_quit) # exit with ctr-q accel_group = gtk.AccelGroup() accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, gtk.main_quit) self.add_accel_group(accel_group) self.darea = gtk.DrawingArea() self.darea.connect("expose-event", self.expose) self.add(self.darea) if args.animate: self.timer = True if args.fast: glib.timeout_add(10, self.on_timer) #100fps self.inc = 8 else: glib.timeout_add(40, self.on_timer) #25fps self.inc = 4 self.todraw = self.inc self.show_all()
def show(self): """Opens a GTK window and puts the heatmap in it. Intelligent enough to work with the GUI as well.""" window_only = 1 #What needs to be destroyed when the window is destroyed? if HMAP_ENABLED and DISPLAY_ENABLED: def destroy(): if window_only: window.destroy() else: gtk.main_quit() gtk.gdk.threads_enter() window = gtk.Window() window.set_title("Showing heatmap...") window.set_border_width(10) window.set_resizable(False) window.connect("delete_event", lambda w, e: destroy()) backbone = gtk.HBox(True) image = gtk.Image() image.set_from_pixbuf(self._image_to_pixbuf(self.im)) backbone.pack_start(image) window.add(backbone) window.show_all() gtk.gdk.threads_leave() if gtk.main_level() == 0: window_only = 0 gtk.main() else: raise "HmapError", "Error loading modules or unable to display"
def destroy(self, w): if MPI_ENABLED: if mpi.rank == 0: if self.thread is None: wake_nodes(1) mpi.bcast(None) else: wake_nodes(3) gobject.source_remove(self.pbar_timer) gtk.main_quit()
def destroy(widget, data=None): gtk.main_quit()
def _quit(self, *args): gtk.main_quit()
def __init__(self): super(PyApp, self).__init__() self.connect("destroy", gtk.main_quit) self.set_size_request(250, 150) self.set_position(gtk.WIN_POS_CENTER) self.show()
def _showTrayIconMenu(self, event_button, event_time, icon): menu = gtk.Menu() if not self.get_property('visible'): showItem = gtk.MenuItem('Show main window') showItem.connect('activate', self._trayIconClick) showItem.show() menu.append(showItem) item = gtk.MenuItem('Quit') item.connect('activate', gtk.main_quit) item.show() menu.append(item) menu.popup(None, None, gtk.status_icon_position_menu, event_button,event_time, icon)
def cb_delete_event(self, widget, event, data=None): gtk.main_quit() return False
def gui_quit(self, data): self.quit() gtk.main_quit()