Python gtk 模块,WIN_POS_CENTER_ON_PARENT 实例源码

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

项目:pyttrss    作者:balanceofcowards    | 项目源码 | 文件源码
def show(self, articles):
        treestore = gtk.TreeStore(str, str, str, int)
        for article in articles:
            entry = [article['title'], article['link'], article['id'], 700]
            treestore.append(None, entry)
        treeview = gtk.TreeView(treestore)
        tvcolumn = gtk.TreeViewColumn('Articles: {}'.format(len(articles)))
        treeview.append_column(tvcolumn)
        cell = gtk.CellRendererText()
        tvcolumn.pack_start(cell, True)
        tvcolumn.add_attribute(cell, 'text', 0)
        tvcolumn.add_attribute(cell, 'weight', 3)
        self.window.add(treeview)
        self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        treeview.connect("row-activated", self.open_article, treestore)
        treeview.connect("cursor-changed", self.skip_article, treestore)
        self.window.show_all()
项目: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, 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, **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)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def __init__(self, parent, plugins):
        super(PluginConfigGUI, self).__init__()
        self.main_gui = parent

        #TODO: Add one for compression format
        self.value_type_create = {
            "text": self.create_text_hbox,
            "number": self.create_number_hbox,
            "checkbox": self.create_checkbox_hbox,
            "radio": self.create_radio_hbox,
            "option": self.create_option_hbox,
            "options": self.create_options_hbox,
            "time": self.create_time_hbox,
            "netiface": self.create_netiface_hbox,
            "netifaces": self.create_netifaces_hbox,
            "filepath": self.create_filepath_hbox,
            "path": self.create_path_hbox
        }

        self.set_title("Plugin Configurations")
        self.set_modal(True)
        self.set_transient_for(self.main_gui)
        self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        #self.set_size_request(500, 700)
        self.set_border_width(6)
        self.set_resizable(False)

        self.plugins = plugins
        plugin_names = [plugin.name for plugin in self.plugins]

        vbox_main = gtk.VBox()

        hbox_plugins = gtk.HBox()
        frame_plugin_confs = gtk.Frame("Plugin Configurations:")

        self.vbox_plugin_main = None

        label_plugins = gtk.Label("Plugin")
        combobox_plugins = gtk.combo_box_new_text()
        for label in plugin_names:
            combobox_plugins.append_text(label)
        combobox_plugins.set_active(0)
        combobox_plugins.connect('changed', self.select_plugin, combobox_plugins, frame_plugin_confs)

        button_close = gtk.Button("Close")
        button_close.connect("clicked", self.close_plugin_config_dialog)

        hbox_plugins.pack_start(label_plugins)
        hbox_plugins.pack_start(combobox_plugins)
        vbox_main.pack_start(hbox_plugins)
        vbox_main.pack_start(frame_plugin_confs)
        vbox_main.pack_start(button_close)

        self.show_plugin_configs(combobox_plugins.get_active_text(), frame_plugin_confs)

        self.add(vbox_main)
        self.show_all()
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def _setup_widgets(self):
        """
        create all the window staticaly placed widgets.
        """
        #load the saved setting before start.
        self.set_settings(Utils.load_conffile("conf.json"))

        # basic window definitions
        self.connect("destroy",self.destroy)
        self.connect("focus_in_event",self.on_window_focus)
        self.connect("configure_event",self.on_window_resize)

        self.set_default_size(self.win_size[0],self.win_size[1])
        self.set_keep_above(True)

        #self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.move(self.win_pos[0],self.win_pos[1])

        # parse gimp theme gtkrc
        gtkrc_path  = self._get_theme_gtkrc(gimp.personal_rc_file('themerc'))

        if  os.name != 'nt':# try apply the theme by parse a gtkrc file if is not a windows system.
            gtk.rc_parse(gtkrc_path)
        else: # if error occur them parse the file in another way.
            gtk.rc_add_default_file(gtkrc_path)
            gtk.rc_reparse_all()

        # start creating basic layout
        base = gtk.VBox()

        # commands bar widgets
        cbar = gtk.HBox()
        cbar.pack_start(self._setup_playbackbar(),False,False,10)
        cbar.pack_start(self._setup_editbar(),False,False,10)
        cbar.pack_start(self._setup_onionskin(),False,False,10)
        cbar.pack_start(self._setup_config(),False,False,10)
        cbar.pack_start(self._setup_generalbar(),False,False,10)

        # frames bar widgets
        self.frame_bar = gtk.HBox()
        scroll_window = gtk.ScrolledWindow()
        scroll_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
        scroll_window.add_with_viewport(self.frame_bar)
        scroll_window.set_size_request(-1,140)

        # mount the widgets together
        base.pack_start(cbar,False,False,0)
        base.pack_start(scroll_window,True,True,0)
        self.add(base)

        # catch all layers
        self._scan_image_layers()
        self.active = 0
        self.on_goto(None,GIMP_ACTIVE)

        # finalize showing all widgets
        self.show_all()