Python gtk 模块,main_quit() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gtk.main_quit()

项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
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()

  # ??? ??????? ???????????? ?????????????? ?????????? ???????
项目:flashplayer-pygtk    作者:nanpuyue    | 项目源码 | 文件源码
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
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
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()
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
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()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
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()
项目:pyttrss    作者:balanceofcowards    | 项目源码 | 文件源码
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)
项目:projet_IA    作者:dogmotion    | 项目源码 | 文件源码
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()
项目:robik    作者:RecunchoMaker    | 项目源码 | 文件源码
def leave_app(self,widget=None,data=None):
        self.controller.camara_off()
        self.done = True
        self.win.destroy()
        gtk.main_quit()
项目:robik    作者:RecunchoMaker    | 项目源码 | 文件源码
def quit(self):
        self.done = True
        self.win.destroy()
        gtk.main_quit()
项目:otRebuilder    作者:Pal3love    | 项目源码 | 文件源码
def _delete_event(self, widget, event, data=None):
        gtk.main_quit()
        return False
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
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()

  # ??? ??????? ???????????? ?????????????? ????????
项目:id_photo    作者:aeifn    | 项目源码 | 文件源码
def destroy(self, widget, data=None):
    gtk.main_quit()

#########################################################
#-------- ??? ? ?????? ?????, ? ??? ??????? ??????? ----#
#########################################################
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def quit(self, *args):
            self.win32ext.remove_notify_icon()
            gtk.main_quit()
项目:flashplayer-pygtk    作者:nanpuyue    | 项目源码 | 文件源码
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
项目:flashplayer-pygtk    作者:nanpuyue    | 项目源码 | 文件源码
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()
项目:pub1ic_POC    作者:i1ikey0u    | 项目源码 | 文件源码
def destroy(self, widget, data=None):
        if self.xww:
            os.system("kill {}".format(self.xww.pid + 1))
        gtk.main_quit()
项目:learning-texas-holdem    作者:gjgregory    | 项目源码 | 文件源码
def destroy(self, widget, data=None):
        gtk.main_quit()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def crash(self):
        import gtk
        # mainquit is deprecated in newer versions
        if hasattr(gtk, 'main_quit'):
            gtk.main_quit()
        else:
            gtk.mainquit()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def crash(self):
        gtk.main_quit()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
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()
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
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()
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def on_quit(self, widget, data=None):
        module_init.stop_all()
        os._exit(0)
        gtk.main_quit()
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def on_quit(self, widget, data=None):
        module_init.stop_all()
        os._exit(0)
        gtk.main_quit()
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def _main_quit(*args, **kwargs):
    gtk.main_quit()
    return False
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
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()
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def destroy(self, widget, data=None):
        print "destroy"
        gtk.main_quit()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
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
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def destroy(self, *args):
        if not self.indep:
            self.window.hide()
            self.shown = False
            return True
        else:
            self.window.destroy()
            gtk.main_quit()
项目:yt    作者:yt-project    | 项目源码 | 文件源码
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()
项目:srcsim2017    作者:ZarjRobotics    | 项目源码 | 文件源码
def destroy(self, widget, data=None):
        self.zarj_comm.stop()
        gtk.main_quit()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
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( )
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def destroy(self, widget):
        gtk.main_quit()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def destroy_cb(self, widget, data=None):
        gtk.main_quit()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def run(Widget):
    window = gtk.Window()
    window.connect("delete-event", gtk.main_quit)
    widget = Widget()
    widget.show()
    window.add(widget)
    window.present()
    gtk.main()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def delete_handler(self, *args):
        gtk.main_quit()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def quit(self, *ignored):
        if self.current_engine.playing:
            self.current_engine.stop()
        self._save_settings()
        gtk.main_quit()
    # quit()
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
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()
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
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"
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
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()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
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()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def crash(self):
        import gtk
        # mainquit is deprecated in newer versions
        if hasattr(gtk, 'main_quit'):
            gtk.main_quit()
        else:
            gtk.mainquit()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def crash(self):
        gtk.main_quit()
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def destroy(widget, data=None):
        gtk.main_quit()
项目:96board-mqtt-demo    作者:bfletcher    | 项目源码 | 文件源码
def _quit(self, *args):
        gtk.main_quit()
项目:geometric-bot    作者:carloscabo    | 项目源码 | 文件源码
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()
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
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)
项目:inkscapeMadeEasy    作者:fsmMLK    | 项目源码 | 文件源码
def cb_delete_event(self, widget, event, data=None):
            gtk.main_quit()
            return False
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def gui_quit(self, data):
        self.quit()

        gtk.main_quit()
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def on_quit(self, widget, data=None):
        module_init.stop_all()
        os._exit(0)
        gtk.main_quit()