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

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

项目: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()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def _start_shell(self, dummy_button):
        if self.shell_window is not None:
            self.shell_window.present()
            return

        self.shell_window = gtk.Window()
        self.shell_window.set_size_request(750,550)
        self.shell_window.set_resizable(True)
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
        ipython = ipython_view.IPythonView()
        ipython.modify_font(pango.FontDescription(SHELL_FONT))
        ipython.set_wrap_mode(gtk.WRAP_CHAR)
        ipython.show()
        scrolled_window.add(ipython)
        scrolled_window.show()
        self.shell_window.add(scrolled_window)
        self.shell_window.show()
        self.shell_window.connect('destroy', self._on_shell_window_destroy)

        self._update_ipython_selected_node()
        __IPYTHON__.user_ns['viz'] = self
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def __init__(self,servers):
        self.servers = servers;
        self.serverInfo = {};

        table = gtk.Table(60,50);
        self.window = gtk.Window();

        inputEntry = self.build_InputEntry();
        menuBar = self.build_Menu();
        self.noteBook = self.build_Note();
        self.messageView = self.build_MessageView();

        table.attach(menuBar,0,60,0,10);
        table.attach(self.noteBook,0,50,11,50, gtk.EXPAND, gtk.FILL);
        table.attach(self.messageView, 51, 60, 11, 50);
        table.attach(inputEntry,0,60,51,60)

        self.window.set_default_size(1000,700);
        self.window.add(table);
        self.window.show_all();

        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        gtk.main();
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self):
        imageLoc = random.choice(os.listdir(os.path.join(WORKINGDIR, "data", "splashScreens")))
        imageSize = self.get_image_size(open(os.path.join(WORKINGDIR, "data", "splashScreens", imageLoc), 'rb').read())

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_decorated(False)
        self.window.set_title("Micro:Pi")
        self.window.set_icon_from_file(os.path.join(WORKINGDIR, "data", "icon.png"))
        self.window.set_size_request(imageSize[0], -1)
        self.window.set_position(gtk.WIN_POS_CENTER)
        main_vbox = gtk.VBox(False, 1)
        self.window.add(main_vbox)
        hbox = gtk.HBox(False, 0)
        self.img = gtk.Image()
        self.img.set_from_file(os.path.join(WORKINGDIR, "data", "splashScreens", imageLoc))
        main_vbox.pack_start(self.img, True, True)
        self.lbl = gtk.Label('')
        font = pango.FontDescription("Monospace 7")
        self.lbl.modify_font(font)
        main_vbox.pack_end(self.lbl, False, False)
        self.refresh()
        self.window.show_all()
        self.refresh()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def createPanelSettingsWidgets(self):
        """Create the Panel Settings widgets."""
        self.tablePanelSettings = gtk.Table(rows=5, columns=3, homogeneous=False)
        self.tablePanelSettings.set_row_spacings(5)
        self.tablePanelSettings.set_col_spacings(5)

        createLabel(self.tablePanelSettings, text="Window Manager Menu", gridX=0, gridY=0, xPadding=10)
        self.panelMenu = createCheckButton(self.tablePanelSettings, active=False, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred)
        self.registerComponent("wm_menu", self.panelMenu)

        createLabel(self.tablePanelSettings, text="Place In Window Manager Dock", gridX=0, gridY=1, xPadding=10)
        self.panelDock = createCheckButton(self.tablePanelSettings, active=False, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred)
        self.registerComponent("panel_dock", self.panelDock)

        createLabel(self.tablePanelSettings, text="Panel Layer", gridX=0, gridY=2, xPadding=10)
        self.panelLayer = createComboBox(self.tablePanelSettings, ["bottom", "top", "normal"], gridX=1, gridY=2, handler=self.changeOccurred)
        self.registerComponent("panel_layer", self.panelLayer)

        createLabel(self.tablePanelSettings, text="Strut Policy", gridX=0, gridY=3, xPadding=10)
        self.panelAutohideStrut = createComboBox(self.tablePanelSettings, ["none", "minimum", "follow_size"], gridX=1, gridY=3, handler=self.changeOccurred)
        self.registerComponent("strut_policy", self.panelAutohideStrut)

        createLabel(self.tablePanelSettings, text="Panel Monitor (all, 1, 2, ...)", gridX=0, gridY=4, xPadding=10)
        self.panelMonitor = createEntry(self.tablePanelSettings, maxSize=6, width=8, text=PANEL_MONITOR, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred)
        self.registerComponent("panel_monitor", self.panelMonitor)
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
def __init__(self, mpi):
        import webkit
        self.webview = webkit.WebView()

        self.scroller = gtk.ScrolledWindow()
        self.scroller.add(self.webview)

        self.vbox = gtk.VBox(False, 1)
        self.vbox.pack_start(self.scroller, True, True)

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_size_request(1100, 600)
        self.window.connect('delete-event', lambda w, e: w.hide() or True)
        self.window.add(self.vbox)

        self.browser_settings = self.webview.get_settings()
        self.browser_settings.set_property("enable-java-applet", False)
        self.browser_settings.set_property("enable-plugins", False)
        self.browser_settings.set_property("enable-scripts", True)
        self.browser_settings.set_property("enable-private-browsing", True)
        self.browser_settings.set_property("enable-spell-checking", True)
        self.browser_settings.set_property("enable-developer-extras", True)
        self.webview.set_settings(self.browser_settings)
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def display_splash(self):
        """show splash screen"""
        self.splash = gtk.Window()
        self.splash.set_decorated(False)
        self.splash.set_transient_for(self.winMain)
        self.splash.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.splash.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.splash.set_keep_above(True)
        self.splash.set_border_width(self.splash_border_width)
        vbox = gtk.VBox()
        img = gtk.Image()
        self.splash_gfx = os.path.join(CONFIG_DIR, 'layouts', self.layout, 'main-splash.png')
        if os.path.exists(self.splash_gfx):
            self.log_msg('Custom splash found, loading ' + str(self.splash_gfx))
            img.set_from_file(self.splash_gfx)
        else:
            self.splash_gfx = os.path.join(APP_PATH, 'pixmaps', 'wahcade-logo.png')
            self.log_msg('No custom splash found, loading ' + str(self.splash_gfx))
            img.set_from_file(self.splash_gfx)
        if self.splash_show_text == 1:
            lbl = gtk.Label()
            lbl.set_alignment(0.5, 0.5)
            lbl.set_justify(gtk.JUSTIFY_CENTER)
            lbl.set_use_markup(True)
            lbl.set_markup('<big><b>Wah!Cade</b></big>\n%s "%s"' % (VERSION, VERSION_NAME))
            vbox.pack_end(lbl)
        vbox.pack_start(img)
        self.splash.add(vbox)
        self.splash.show_all()
        if not self.tw_api:
            self.twitter_api = self.auth_twitter() ## Auth Twitter during startup
        self.wait_with_events(0.25)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, title, parent=None):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_modal(True)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_title(title)
        if parent:
            self.set_transient_for(parent)

        self.set_resizable(False)

        vbox = gtk.VBox(False, 2)

        self.label = gtk.Label("")
        self.label.set_size_request(100, 50)
        self.label.show()

        self.pbar = gtk.ProgressBar()
        self.pbar.show()

        vbox.pack_start(self.label, 0, 0, 0)
        vbox.pack_start(self.pbar, 0, 0, 0)

        vbox.show()

        self.add(vbox)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, msg, parent=None):
        gtk.Window.__init__(self)
        self.set_title("Please Wait")
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        if parent:
            self.set_transient_for(parent)
            self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        else:
            self.set_position(gtk.WIN_POS_CENTER)

        vbox = gtk.VBox(False, 2)

        l = gtk.Label(msg)
        l.show()
        vbox.pack_start(l)

        self.prog = gtk.ProgressBar()
        self.prog.show()
        vbox.pack_start(self.prog)

        vbox.show()
        self.add(vbox)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, radiosel, download, upload, iport, eport):
        gtk.Window.__init__(self)

        self.tips = gtk.Tooltips()

        self.fn_radiosel = radiosel
        self.fn_download = download
        self.fn_upload = upload
        self.fn_iport = iport
        self.fn_eport = eport

        self.set_title("CHIRP: CSV Dump")
        self.set_resizable(False)

        vbox = gtk.VBox(False, 2)

        vbox.pack_start(self.make_radio_sel(), 0, , )
        vbox.pack_start(self.make_image_ctl(), 0, , )
        vbox.pack_start(self.make_file_ctl(), 0, , )
        vbox.pack_start(self.make_status_bar(), 0, , )

        vbox.show()
        self.add(vbox)
项目: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()
项目:otRebuilder    作者:Pal3love    | 项目源码 | 文件源码
def __init__(self, fontfile):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("%s - pyftinspect" % fontfile)
        self.window.connect("delete_event", self._delete_event)
        self.window.set_size_request(400, 600)

        self.scrolled_window = gtk.ScrolledWindow()
        self.window.add(self.scrolled_window)

        self.font = ttLib.TTFont(fontfile, lazy=True)
        self.treemodel = FontTreeModel(self.font)
        self.treeview = gtk.TreeView(self.treemodel)
        #self.treeview.set_reorderable(True)

        for i in range(2):
            col_name = ('Key', 'Value')[i]
            col = gtk.TreeViewColumn(col_name)
            col.set_sort_column_id(-1)
            self.treeview.append_column(col)

            cell = gtk.CellRendererText()
            col.pack_start(cell, True)
            col.add_attribute(cell, 'text', i)

        self.treeview.set_search_column(1)
        self.scrolled_window.add(self.treeview)
        self.window.show_all()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def restore(self, widget, data=None):
        self.window.deiconify()
        self.window.present()

        return True

    # Destroy Classification Banner Window on Resize (Display Banner Will Relaunch)
项目:pixelvloed    作者:JanKlopper    | 项目源码 | 文件源码
def canvas(self):
    """Init the pygame canvas"""
    sdl2.ext.init()
    if gtk:
      window = gtk.Window()
      screen = window.get_screen()
    self.width = gtk.gdk.screen_width() if gtk else DEFAULT_WIDTH
    self.height = gtk.gdk.screen_height() if gtk else DEFAULT_HEIGHT
    self.width = options.width if options.width else self.width
    self.height = options.height if options.height else self.height
    self.screen = sdl2.ext.Window(self.set_title(),
                                  size=(self.width, self.height))
    self.screen.show()
    self.surface = self.screen.get_surface()
项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def open_window(self, url):
      url = address_bar.get_text()
      for letter in url:
          if '.' not in url:
               a = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CANCEL)
               a.set_markup("<big><b>WTF!?!? Thats not even a website?</b></big>")
               a.run()
               return
      if 'http://' not in url:
           w = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK)
           w.set_markup("<big><b>**mumble, mumble** Force to change {} to {}</b></big>".format(url, 'http://'+url+'/'))
           w.run()
           url = 'http://'+url+'/'
      os.system('python Web-Window.py '+url)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self):
        super(ProgressBarDetails, self).__init__()

        #Configure the Window
        self.set_resizable(False)
        self.connect("destroy", self.destroy_progress)
        self.set_title("Progress Bar")
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_size_request(460, 150)
        self.set_border_width(0)

        #Create the VBox in case we want to add additional items later
        self.vbox = gtk.VBox(False, 5)
        self.vbox.set_border_width(10)
        self.add(self.vbox)
        self.vbox.show()

        #create the scrolled window
        self.scrolled_window =gtk.ScrolledWindow()
        self.scrolled_window.set_usize(460, 100)
        self.vbox.add(self.scrolled_window)
        self.scrolled_window.show()

        self.text_view = gtk.TextView()
        self.msg_i = 0
        self.text_buffer = self.text_view.get_buffer()
        self.scrolled_window.add_with_viewport(self.text_view)
        self.text_view.connect("size-allocate", self.autoscroll)
        self.text_view.show()

        # Create the ProgressBar
        self.pbar = gtk.ProgressBar()
        #self.pbar.set_usize(460, 40)
        self.pbar.set_fraction(0.0)
        self.vbox.add(self.pbar)
        self.pbar.show()

        #Display the Window
        self.show()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self):
        super(ProgressBar, self).__init__()

        #Configure the Window
        self.set_resizable(False)
        self.connect("destroy", self.destroy_progress)
        self.set_title("Progress Bar")
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_size_request(460, 50)
        self.set_border_width(0)

        #Create the VBox in case we want to add additional items later
        vbox = gtk.VBox(False, 5)
        vbox.set_border_width(10)
        self.add(vbox)
        vbox.show()

        # Create the ProgressBar
        self.pbar = gtk.ProgressBar()
        self.pbar.set_fraction(0.0)
        self.pbar.set_text("Starting")
        vbox.add(self.pbar)
        self.pbar.show()

        #Display the Window
        self.show()
项目: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 run(Widget):
    window = gtk.Window()
    window.connect("delete-event", gtk.main_quit)
    widget = Widget()
    widget.show()
    window.add(widget)
    window.present()
    gtk.main()
项目: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"
项目:96board-mqtt-demo    作者:bfletcher    | 项目源码 | 文件源码
def _setup_widgets(self):
        self._window = gtk.Window()
        self._window.hide()
        self._window.connect("destroy", self._quit)
        widget = gtk.DrawingArea()
        self._window.add(widget)
        self.lcd_display = LCDWidget(widget, g_rows, g_cols)
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
def _main_window_setup(self, now=False):
        def create(self):
            wcfg = self.config['main_window']

            window = gtk.Window(gtk.WINDOW_TOPLEVEL)
            self.main_window = {'window': window}

            if wcfg.get('style', 'default') == 'default':
                self._main_window_default_style()
            else:
                raise NotImplementedError('We only have one style atm.')

            if wcfg.get('close_quits'):
                window.connect("delete_event", lambda a1,a2: gtk.main_quit())
            else:
                window.connect('delete-event', lambda w, e: w.hide() or True)
            window.connect("destroy", lambda wid: gtk.main_quit())

            window.set_title(self.config.get('app_name', 'gui-o-matic'))
            window.set_decorated(True)
            if wcfg.get('center', False):
                window.set_position(gtk.WIN_POS_CENTER)
            window.set_size_request(
                wcfg.get('width', 360), wcfg.get('height',360))
            if wcfg.get('show'):
                window.show_all()

        if now:
            create(self)
        else:
            gobject.idle_add(create, self)
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def popup_message(message):
    """shows popup message while executing decorated function"""

    def wrap(f):

        def wrapped_f(*args, **kwargs):
            if gtk:
                window = gtk.Window()
                window.set_title('Griffith info')
                window.set_position(gtk.WIN_POS_CENTER)
                window.set_keep_above(True)
                window.stick()
                window.set_default_size(200, 50)
                label = gtk.Label()
                label.set_markup("""<big><b>Griffith:</b>
%s</big>""" % message)
                window.add(label)
                window.set_modal(True)
                window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
                window.show_all()
                while gtk.events_pending():    # give GTK some time for updates
                    gtk.main_iteration()
            else:
                print message,
            res = f(*args, **kwargs)
            if gtk:
                window.destroy()
            else:
                print ' [done]'
            return res
        return wrapped_f
    return wrap
项目:pyttrss    作者:balanceofcowards    | 项目源码 | 文件源码
def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.window.set_title("Unread article list")
        #self.window.set_geometry_hints(None, min_width=100, min_height=100, max_width=100, max_height=100)
        self.window.connect("destroy", self.hide)
        #self.window.connect("key_press_event", self.on_key_pressed)
        self.read = []
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def __init__(self, parser, max_tree_depth):
        self.parser = parser
        self._max_tree_depth = max_tree_depth
        self.search_thread = None
        self.search_lock = threading.Lock()
        self.name_entry = name_entry = gtk.Entry()
        name_entry.connect('activate', self.on_name_entry_activate)
        search_button = self.search_button = gtk.Button(stock=gtk.STOCK_FIND)
        search_button.connect('clicked', self.on_search)
        search_button.set_no_show_all(True)
        search_button.show()
        stop_button = self.stop_button = gtk.Button(stock=gtk.STOCK_STOP)
        stop_button.connect('clicked', self.stop_search)
        stop_button.set_no_show_all(True)
        self.progress = progress = gtk.ProgressBar()
        progress.set_size_request(-1, 8)
        name_box = gtk.HBox(spacing=8)
        name_box.set_border_width(8)
        name_box.pack_start(name_entry, True, True)
        name_box.pack_start(search_button, False)
        name_box.pack_start(stop_button, False)
        self.store = gtk.TreeStore(str, str, str, str)  # name, icon, fnstyle, info
        self.treeview = treeview = self._create_treeview(self.store)
        scroller = gtk.ScrolledWindow()
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroller.add(treeview)
        settings_view = SettingsView(max_depth_value=max_tree_depth)
        settings_view.on_max_depth_changed = self.on_max_depth_changed
        extension = gtk.expander_new_with_mnemonic('_Settings')
        extension.add(settings_view.view)
        vbox = gtk.VBox()
        vbox.pack_start(name_box, False)
        vbox.pack_start(progress, False)
        vbox.pack_start(scroller, True, True)
        vbox.pack_start(extension, False)
        self.window = window = gtk.Window()
        window.set_title(Application.title)
        window.set_default_size(800, 600)
        window.set_icon(Application.get_icon())
        window.add(vbox)
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def __init__(self):
        progress = self.progress = gtk.ProgressBar()
        progress.set_text('Loading...')
        align = gtk.Alignment(0.5, 0.5, xscale=1.0)
        align.add(progress)
        window = self.window = gtk.Window()
        window.set_title(Application.title)
        window.set_border_width(8)
        window.add(align)
        window.set_default_size(400, 120)
        self._last_update_progress = 0.0
项目:hls-player    作者:weimingtom    | 项目源码 | 文件源码
def __init__(self, display=True):
        import pygst
        import gst
        if display:
            self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
            self.window.set_title("Video-Player")
            self.window.set_default_size(500, 400)
            self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
            self.window.connect('delete-event', lambda _: reactor.stop())
            self.movie_window = gtk.DrawingArea()
            self.window.add(self.movie_window)
            self.window.show_all()

        self.player = gst.Pipeline("player")
        self.appsrc = gst.element_factory_make("appsrc", "source")
        self.appsrc.connect("enough-data", self.on_enough_data)
        self.appsrc.connect("need-data", self.on_need_data)
        self.appsrc.set_property("max-bytes", 10000)
        if display:
            self.decodebin = gst.element_factory_make("decodebin2", "decodebin")
            self.decodebin.connect("new-decoded-pad", self.on_decoded_pad)
            self.player.add(self.appsrc, self.decodebin)
            gst.element_link_many(self.appsrc, self.decodebin)
        else:
            sink = gst.element_factory_make("filesink", "filesink")
            sink.set_property("location", "/tmp/hls-player.ts")
            self.player.add(self.appsrc, sink)
            gst.element_link_many(self.appsrc, sink)
        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)
        self._playing = False
        self._need_data = False
        self._cb = None
项目:File-Explorer    作者:aj95    | 项目源码 | 文件源码
def searchfunc(self,widget):
        fileName = self.searchfile.get_text()
        paths = "\n"
        for root, dirs, files in os.walk('/home', topdown=False):
            for name in files:
                if name == fileName:
                    paths += "  " + str(os.path.join(root, name))  + "  \n\n"
            for name in dirs:
                if name == fileName:
                    paths += "  " + str(os.path.join(root, name)) + "  \n\n"
        paths = paths[:-1]
        if len(paths) > 0 :
            self.popup = gtk.Window()
            self.popup.set_title( "Paths" )
            vbox = gtk.VBox(False,0)
            hbox = gtk.HBox(False)
            label = gtk.Label(paths)
            label.set_line_wrap( True )
            label.connect( "size-allocate",self.size_allocate)
            vbox.pack_start(gtk.Label(paths),True,False,0)
            closeButton = gtk.Button(" Close ")
            closeButton.set_sensitive(True)
            closeButton.connect("clicked",self.on_destroy)
            hbox.pack_start(closeButton,True,False,0)
            vbox.pack_start(hbox,True,False,10)
            self.popup.add(vbox)
            self.popup.set_type_hint( gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
            self.popup.show_all()
项目:Proxy-Factory    作者:ping99    | 项目源码 | 文件源码
def main():
    global __file__
    __file__ = os.path.abspath(__file__)
    if os.path.islink(__file__):
        __file__ = getattr(os, 'readlink', lambda x: x)(__file__)
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    if not os.path.exists('goagent-logo.png'):
        # first run and drop shortcut to desktop
        drop_desktop()

    window = gtk.Window()
    terminal = vte.Terminal()
    GoAgentGTK(window, terminal)
    gtk.main()
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def __init__(self,title,image):
        gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)

        self.set_title(title)
        self.image = image
        self.frame_bar = None
        # variables
        self.is_playing = False
        self.is_replay = False
        # modifiable widgets
        self.play_button_images = []
        self.widgets_to_disable = [] # widgets to disable when playing
        self.play_bar = None

        # frames
        self.frames = [] # all frame widgets
        self.active = None  # active frame / gimp layer
        self.before_play = None # active frame before play

        self.framerate = 30

        # new frame.
        self.new_layer_type = TRANSPARENT_FILL

        # onionskin variables
        self.oskin = False
        self.oskin_depth = 2
        self.oskin_backward = True
        self.oskin_forward = False
        self.oskin_opacity = 50.0
        self.oskin_opacity_decay = 20.0
        self.oskin_onplay= True

        self.player = None

        # gtk window
        self.win_pos = (20,20)
        self.win_size = (200,200)
        # create all widgets
        self._setup_widgets()
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def getWindons(self):
        command = 'D:\\CYEMS\\client\\start.bat'
        dir = os.path.dirname(command)
        os.chdir(dir)
        os.popen(command).read()
        win = gtk.Window(gtk.WINDOW_TOPLEVEL)

        return win
项目:XX-Net-Mini    作者:GFWParty    | 项目源码 | 文件源码
def main():
    global __file__
    __file__ = os.path.abspath(__file__)
    if os.path.islink(__file__):
        __file__ = getattr(os, 'readlink', lambda x: x)(__file__)
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    if not os.path.exists('goagent-logo.png'):
        # first run and drop shortcut to desktop
        drop_desktop()

    window = gtk.Window()
    terminal = vte.Terminal()
    GoAgentGTK(window, terminal)
    gtk.main()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, **args):
        if "parent" in args:
            parent = args["parent"]
            del args["parent"]
        else:
            parent = None

        if "cancel" in args:
            cancel = args["cancel"]
            del args["cancel"]
        else:
            cancel = None

        gtk.Window.__init__(self, **args)

        self.set_transient_for(parent)
        self.set_modal(True)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        vbox = gtk.VBox(False, 2)
        vbox.show()
        self.add(vbox)

        self.set_title(_("Clone Progress"))
        self.set_resizable(False)

        self.infolabel = gtk.Label(_("Cloning"))
        self.infolabel.show()
        vbox.pack_start(self.infolabel, 1, 1, 1)

        self.progbar = gtk.ProgressBar()
        self.progbar.set_fraction(0.0)
        self.progbar.show()
        vbox.pack_start(self.progbar, 0, 0, 0)

        cancel_b = gtk.Button(_("Cancel"))
        cancel_b.connect("clicked", lambda b: cancel())
        cancel_b.show()
        vbox.pack_start(cancel_b, 0, 0, 0)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self):

            self.main_loop = gobject.MainLoop()            

            # Create a window with a horizontal scale.
            self.wnd = gtk.Window()
            self.wnd.set_default_size(640, 480)
            self.wnd.set_title('Have fun with the transparency slider')

            hscale = gtk.HScale()
            hscale.set_digits(0)
            hscale.set_increments(1, 10)
            hscale.set_range(0, 100)
            hscale.set_value(100)

            hscale.connect('value_changed', self.set_window_alpha)

            self.wnd.add(hscale)

            # Note: gtk window must be realized before installing extensions.
            self.wnd.realize()
            self.wnd.show_all()

            self.win32ext = GTKWin32Ext(self.wnd)

            self.win32ext.add_notify_icon()

            # GTK menus from the notify icon!
            menu = gtk.Menu()

            menu_item = gtk.MenuItem('Baloons!')
            menu_item.connect_object('activate', self.menu_cb, self.wnd)
            menu.append(menu_item)

            menu_item = gtk.MenuItem('Fadeout Window')
            menu_item.connect('activate', self.fadeoutwindow)
            menu.append(menu_item)

            menu_item = gtk.MenuItem('Window Disappeared?')
            menu_item.connect('activate', self.fadeinwindow)
            menu.append(menu_item)

            menu.show_all()
            self.win32ext.notify_icon.menu = menu

            # Set up the callback messages
            self.win32ext.message_map({
                WM_TRAYMESSAGE: self.on_notifyicon_activity
                })
项目:pub1ic_POC    作者:i1ikey0u    | 项目源码 | 文件源码
def __init__(self, width, height):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(0)
        self.window.set_size_request(width, height + 30)
        self.window.set_app_paintable(True)

        self.screen = self.window.get_screen()
        self.rgba = self.screen.get_rgba_colormap()
        self.window.set_colormap(self.rgba)
        self.window.connect('expose-event', self.expose)

        self.vbox = gtk.VBox(False, 5)
        self.hbox = gtk.HBox(False, 3)
        self.bbox = gtk.HBox(True, 3)

        self.entry = gtk.Entry()
        self.entry.set_max_length(0)
        self.entry.set_size_request(int(width / 2), 25)
        self.entry.connect("activate", self.enter_callback, self.entry)
        self.spr = gtk.ToggleButton(label='spr')
        self.spr.connect("toggled", self.on_button_toggled, 'spr')
        self.ctrl = gtk.ToggleButton(label='ctrl')
        self.ctrl.connect("toggled", self.on_button_toggled, 'ctrl')
        self.alt = gtk.ToggleButton(label='alt')
        self.alt.connect("toggled", self.on_button_toggled, 'alt')
        self.enter = gtk.Button(label='Enter')
        self.enter.connect("clicked", self.on_enter_clicked)
        self.backspace = gtk.Button(label='Backspace')
        self.backspace.connect("clicked", self.on_backspace_clicked)
        self.shell = gtk.Button(label='R-Shell')
        self.shell.connect("clicked", self.on_shell_clicked, self.entry)

        self.hbox.add(self.entry)
        self.bbox.add(self.spr)
        self.bbox.add(self.ctrl)
        self.bbox.add(self.alt)
        self.bbox.add(self.enter)
        self.bbox.add(self.backspace)
        self.bbox.add(self.shell)
        self.hbox.add(self.bbox)

        self.halign = gtk.Alignment(1, 0, 1, 0)
        self.halign.add(self.hbox)

        self.allalign = gtk.Alignment(0, 0, 1, 1)
        self.clickbox = gtk.EventBox()
        self.clickbox.connect('button-press-event', self.on_click)
        self.clickbox.set_visible_window(False)

        self.allalign.add(self.clickbox)
        self.vbox.pack_start(self.allalign, True, True, 0)

        self.vbox.pack_end(self.halign, False, False, 0)

        self.window.add(self.vbox)

        self.window.show_all()

        self.window.move(100, 100)
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.window = gtk.Window()
        self.window.set_title("Create An Image")
        self.window.set_icon_from_file(os.path.join(WORKINGDIR, "data", "icon.png"))
        colour = gtk.gdk.color_parse(DARKCOL)
        self.window.modify_bg(gtk.STATE_NORMAL, colour)

        self.vvbox = gtk.VBox()
        self.table = gtk.Table(5, 5)
        self.table.set_border_width(2)
        self.table.set_row_spacings(2)
        self.table.set_col_spacings(2)
        self.buttons = {}

        for y in range(5):
            for x in range(5):
                eb = gtk.EventBox()
                i = gtk.Image()
                i.set_from_file(os.path.join(WORKINGDIR, "data", "selected.png"))
                i.show()
                eb.add(i)
                eb.hide()
                eb.modify_bg(gtk.STATE_NORMAL, colour)
                eb.connect_object("button-press-event", self.togglePart, (x, y))

                eb2 = gtk.EventBox()
                i2 = gtk.Image()
                i2.set_from_file(os.path.join(WORKINGDIR, "data", "unselected.png"))
                i2.show()
                eb2.add(i2)
                eb2.show()
                eb2.modify_bg(gtk.STATE_NORMAL, colour)
                eb2.connect_object("button-press-event", self.togglePart, (x, y))

                self.buttons[(x, y)] = (eb, eb2)

                self.table.attach(eb, x, x + 1, y, y + 1)
                self.table.attach(eb2, x, x + 1, y, y + 1)

        self.table.show()
        self.vvbox.pack_start(self.table)
        hbox = gtk.HBox()
        self.confirmButton = gtk.Button("Okay")
        self.confirmButton.show()
        self.confirmButton.connect("clicked", self.okay)
        hbox.pack_start(self.confirmButton, True, False)
        cancelButton = gtk.Button("Cancel")
        cancelButton.connect("clicked", self.destroy)
        cancelButton.show()
        hbox.pack_end(cancelButton, True, False)
        hbox.show()
        self.vvbox.pack_start(hbox)
        self.vvbox.show()
        self.window.add(self.vvbox)
        self.onOkay = None

        self.running = True
        self.destoryed = False
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def __init__(self, tw):
        """Create and shows the window."""
        self.tw = tw

        # Create top-level window
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.set_title("Preferences")
        self.connect("delete_event", self.quit)

        self.layout = gtk.Table(2, 2, False)

        self.table = gtk.Table(5, 2, False)
        self.table.set_row_spacings(5)
        self.table.set_col_spacings(5)

        createLabel(self.table, text="Default Font", gridX=0, gridY=0)
        self.font = gtk.FontButton(self.tw.defaults["font"])
        self.font.set_alignment(0, 0.5)
        self.table.attach(self.font, 1, 2, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

        createLabel(self.table, text="Default Background Color", gridX=0, gridY=1)
        self.bgColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["bgColor"]))
        self.bgColor.set_alignment(0, 0.5)
        self.table.attach(self.bgColor, 1, 2, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

        createLabel(self.table, text="Default Foreground Color", gridX=0, gridY=2)
        self.fgColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["fgColor"]))
        self.fgColor.set_alignment(0, 0.5)
        self.table.attach(self.fgColor, 1, 2, 2, 3, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

        createLabel(self.table, text="Default Border Color", gridX=0, gridY=3)
        self.borderColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["borderColor"]))
        self.borderColor.set_alignment(0, 0.5)
        self.table.attach(self.borderColor, 1, 2, 3, 4, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

        createLabel(self.table, text="Number of background styles", gridX=0, gridY=4)
        self.bgCount = createEntry(self.table, maxSize=6, width=8, text=str(self.tw.defaults["bgCount"]), gridX=1, gridY=4, xExpand=True, yExpand=True)

        self.layout.attach(self.table, 0, 2, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND, xpadding=20, ypadding=5)

        createButton(self.layout, text="Save", stock=gtk.STOCK_SAVE, name="save", gridX=0, gridY=1, xExpand=True, yExpand=True, handler=self.save)
        createButton(self.layout, text="Cancel", stock=gtk.STOCK_CANCEL, name="cancel", gridX=1, gridY=1, xExpand=True, yExpand=True, handler=self.quit)

        self.add(self.layout)

        self.show_all()
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def __init__(self):
        gtk.Window.__init__(self)

        self.graph = Graph()

        window = self

        window.set_title('Dot Viewer')
        window.set_default_size(512, 512)
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # Create actions
        actiongroup.add_actions((
            ('Open', gtk.STOCK_OPEN, None, None, None, self.on_open),
            ('Reload', gtk.STOCK_REFRESH, None, None, None, self.on_reload),
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, None, self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget.on_zoom_100),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        # Create a Toolbar
        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)

        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        self.show_all()
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
def show_splash_screen(self, height=None, width=None,
                           progress_bar=False, image=None, message=None,
                           now=False):
        def show(self):
            window = gtk.Window(gtk.WINDOW_TOPLEVEL)
            vbox = gtk.VBox(False, 1)

            if message:
                lbl = gtk.Label()
                lbl.set_markup(message or '')
                lbl.set_alignment(0.5, 0.5)
                vbox.pack_start(lbl, True, True)
            else:
                lbl = None

            if image:
                self._set_background_image(vbox, image)

            if progress_bar:
                pbar = gtk.ProgressBar()
                pbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
                vbox.pack_end(pbar, False, True)
            else:
                pbar = None

            window.set_title(self.config.get('app_name', 'gui-o-matic'))
            window.set_decorated(False)
            window.set_position(gtk.WIN_POS_CENTER)
            window.set_size_request(width or 240, height or 320)
            window.add(vbox)
            window.show_all()

            self.hide_splash_screen(now=True)
            self.splash = {
                'window': window,
                'vbox': vbox,
                'message': lbl,
                'progress': pbar}
        if now:
            show(self)
        else:
            gobject.idle_add(show, self)
项目:python-3-for-absolute-begs    作者:Apress    | 项目源码 | 文件源码
def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        # This is a new call, which just sets the title of our
        # new window to "Hello Buttons!"
        self.window.set_title("Hello Buttons!")

        # Here we just set a handler for delete_event that immediately
        # exits GTK.
        self.window.connect("delete_event", self.delete_event)

        # Sets the border width of the window.
        self.window.set_border_width(10)

        # We create a box to pack widgets into.  This is described in detail
        # in the "packing" section. The box is not really visible, it
        # is just used as a tool to arrange widgets.
        self.box1 = gtk.HBox(gtk.FALSE, 0)

        # Put the box into the main window.
        self.window.add(self.box1)

        # Creates a new button with the label "Button 1".
        self.button1 = gtk.Button("Button 1")

        # Now when the button is clicked, we call the "callback" method
        # with a pointer to "button 1" as its argument
        self.button1.connect("clicked", self.callback, "button 1")

        # Instead of add(), we pack this button into the invisible
        # box, which has been packed into the window.
        self.box1.pack_start(self.button1, gtk.TRUE, gtk.TRUE, 0)

        # Always remember this step, this tells GTK that our preparation for
        # this button is complete, and it can now be displayed.
        self.button1.show()

        # Do these same steps again to create a second button
        self.button2 = gtk.Button("Button 2")

        # Call the same callback method with a different argument,
        # passing a pointer to "button 2" instead.
        self.button2.connect("clicked", self.callback, "button 2")

        self.box1.pack_start(self.button2, gtk.TRUE, gtk.TRUE, 0)

        # The order in which we show the buttons is not really important, but I
        # recommend showing the window last, so it all pops up at once.
        self.button2.show()
        self.box1.show()
        self.window.show()
项目:python-3-for-absolute-begs    作者:Apress    | 项目源码 | 文件源码
def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        # This is a new call, which just sets the title of our
        # new window to "Hello Buttons!"
        self.window.set_title("Hello Buttons!")

        # Here we just set a handler for delete_event that immediately
        # exits GTK.
        self.window.connect("delete_event", self.delete_event)

        # Sets the border width of the window.
        self.window.set_border_width(10)

        # We create a box to pack widgets into.  This is described in detail
        # in the "packing" section. The box is not really visible, it
        # is just used as a tool to arrange widgets.
        self.box1 = gtk.HBox(gtk.FALSE, 0)

        # Put the box into the main window.
        self.window.add(self.box1)

        # Creates a new button with the label "Button 1".
        self.button1 = gtk.Button("Button 1")

        # Now when the button is clicked, we call the "callback" method
        # with a pointer to "button 1" as its argument
        self.button1.connect("clicked", self.callback, "button 1")

        # Instead of add(), we pack this button into the invisible
        # box, which has been packed into the window.
        self.box1.pack_start(self.button1, gtk.TRUE, gtk.TRUE, 0)

        # Always remember this step, this tells GTK that our preparation for
        # this button is complete, and it can now be displayed.
        self.button1.show()

        # Do these same steps again to create a second button
        self.button2 = gtk.Button("Button 2")

        # Call the same callback method with a different argument,
        # passing a pointer to "button 2" instead.
        self.button2.connect("clicked", self.callback, "button 2")

        self.box1.pack_start(self.button2, gtk.TRUE, gtk.TRUE, 0)

        # The order in which we show the buttons is not really important, but I
        # recommend showing the window last, so it all pops up at once.
        self.button2.show()
        self.box1.show()
        self.window.show()
项目:python-3-for-absolute-begs    作者:Apress    | 项目源码 | 文件源码
def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        # Set the title of the window to "Graphic User Interface"
        self.window.set_title("Graphic User Interface")

        # Create a handler for delete_event that immediately quits GTK.
        self.window.connect("delete_event", self.delete_event)

        # Set the border width of the window.
        self.window.set_border_width(6)

        # Create a box to pack the widgets into. The box is an invisible 
        # container, which is used to arrange the widgets inside it.
        self.box1 = gtk.HBox(gtk.FALSE, 0)

        # Put the box into the main window.
        self.window.add(self.box1)

        # Create a new button with the label "Hello".
        self.button1 = gtk.Button("Hello")

        # Now when the button is clicked, we call the self.callback method 
        # with a pointer to "the Hello button" as its argument.
        self.button1.connect("clicked", self.callback, "the Hello button")

        # Instead of add(), we pack this button into the invisible box, 
        # which has been packed into the window.
        self.box1.pack_start(self.button1, gtk.TRUE, gtk.TRUE, 0)

        # Always remember this step, this tells GTK to actually display the 
        # button.
        self.button1.show()

        # Do these same steps again to create a second button
        self.button2 = gtk.Button("Quit")

        # This time, delete_event is called and the window exits.
        self.button2.connect("clicked", self.delete_event, "the Quit button")
        self.box1.pack_start(self.button2, gtk.TRUE, gtk.TRUE, 0)

        # The order in which the buttons are shown is not really important, 
        # but it is recommended to show the window last, so that everything 
        # displays at once.
        self.button2.show()
        self.box1.show()
        self.window.show()
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def __init__(self):
        gtk.Window.__init__(self)

        self.graph = Graph()

        window = self

        window.set_title('Dot Viewer')
        window.set_default_size(512, 512)
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # Create actions
        actiongroup.add_actions((
            ('Open', gtk.STOCK_OPEN, None, None, None, self.on_open),
            ('Reload', gtk.STOCK_REFRESH, None, None, None, self.on_reload),
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, None, self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, None, self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, None, self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, None, self.widget.on_zoom_100),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        # Create a Toolbar
        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)

        vbox.pack_start(self.widget)

        self.set_focus(self.widget)

        self.show_all()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def test():
    win = gtk.Window(gtk.WINDOW_TOPLEVEL)
    lst = ListWidget([(gobject.TYPE_STRING, "Foo"),
                      (gobject.TYPE_BOOLEAN, "Bar")])

    lst.add_item("Test1", True)
    lst.set_values([("Test2", True), ("Test3", False)])

    lst.show()
    win.add(lst)
    win.show()

    win1 = ProgressDialog("foo")
    win1.show()

    win2 = gtk.Window(gtk.WINDOW_TOPLEVEL)
    lle = LatLonEntry()
    lle.show()
    win2.add(lle)
    win2.show()

    win3 = gtk.Window(gtk.WINDOW_TOPLEVEL)
    lst = TreeWidget([(gobject.TYPE_STRING, "Id"),
                      (gobject.TYPE_STRING, "Value")],
                     1)
    lst.set_values({"Fruit": [("Apple", "Red"), ("Orange", "Orange")],
                    "Pizza": [("Cheese", "Simple"), ("Pepperoni", "Yummy")]})
    lst.add_item("Fruit", "Bananna", "Yellow")
    lst.show()
    win3.add(lst)
    win3.show()

    def print_val(entry):
        if entry.validate():
            print "Valid: %s" % entry.value()
        else:
            print "Invalid"
    lle.connect("activate", print_val)

    lle.set_text("45 13 12")

    try:
        gtk.main()
    except KeyboardInterrupt:
        pass

    print lst.get_values()