Python gtk 模块,WIN_POS_CENTER 实例源码

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

项目: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
项目: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()
项目: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()
项目: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)
项目: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()
项目: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()
项目: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()
项目: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
项目:gimp-fanim    作者:douglasvini    | 项目源码 | 文件源码
def __init__(self,title="Config",parent=None,config = None):
        gtk.Dialog.__init__(self,title,parent, gtk.DIALOG_DESTROY_WITH_PARENT,
                ('Apply',gtk.RESPONSE_APPLY,'Cancel',gtk.RESPONSE_CANCEL))

        self.set_keep_above(True)
        self.set_position(gtk.WIN_POS_CENTER)

        self.last_config= config # settings 
        self.atual_config = config

        # setup all widgets
        self._setup_widgets()
项目: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)
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def _info(type, value, tb):
    """display exception"""
    #ungrab a potentially "grabbed" mouse pointer
    gtk.gdk.pointer_ungrab()
    #create dialog
    dialog = gtk.MessageDialog(
        parent = None,
        flags = 0,
        type = gtk.MESSAGE_WARNING,
        buttons = gtk.BUTTONS_NONE,
        message_format = _("<big><b>Error</b></big>"))
    dialog.set_title(_("Bug Detected"))
    dialog.vbox.get_children()[0].get_children()[1].get_children()[0].set_property("use-markup", True)
    dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
    #details
    textview = gtk.TextView() 
    textview.show()
    textview.set_editable(False)
    textview.modify_font(pango.FontDescription("Monospace"))
    sw = gtk.ScrolledWindow() 
    sw.show()
    sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    sw.add(textview)
    frame = gtk.Frame()
    frame.set_shadow_type(gtk.SHADOW_IN)
    frame.add(sw)
    frame.set_border_width(6)
    dialog.vbox.add(frame)
    textbuffer = textview.get_buffer()
    trace = StringIO.StringIO()
    traceback.print_exception(type, value, tb, None, trace)
    textbuffer.set_text(trace.getvalue())
    textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3)
    dialog.details = frame
    dialog.set_position(gtk.WIN_POS_CENTER)
    dialog.set_gravity(gtk.gdk.GRAVITY_CENTER)
    dialog.details.show()
    #display the dialog
    resp = dialog.run()
    if resp == gtk.RESPONSE_CLOSE:
        pass
    dialog.destroy()
    sys.exit(1)

#sys.excepthook = _info
项目:Proxy-Factory    作者:ping99    | 项目源码 | 文件源码
def __init__(self, window, terminal):
        self.window = window
        self.window.set_size_request(652, 447)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.connect('delete-event',self.delete_event)
        self.terminal = terminal

        for cmd in ('python2.7', 'python27', 'python2'):
            if os.system('which %s' % cmd) == 0:
                self.command[1] = cmd
                break

        self.window.add(terminal)
        self.childpid = self.terminal.fork_command(self.command[0], self.command, os.getcwd())
        if self.childpid > 0:
            self.childexited = self.terminal.connect('child-exited', self.on_child_exited)
            self.window.connect('delete-event', lambda w, e: gtk.main_quit())
        else:
            self.childexited = None

        spawn_later(0.5, self.show_startup_notify)

        if should_visible():
            self.window.show_all()

        logo_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'goagent-logo.png')
        if not os.path.isfile(logo_filename):
            with open(logo_filename, 'wb') as fp:
                fp.write(base64.b64decode(GOAGENT_LOGO_DATA))
        self.window.set_icon_from_file(logo_filename)

        if appindicator:
            self.trayicon = appindicator.Indicator('GoAgent', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS)
            self.trayicon.set_status(appindicator.STATUS_ACTIVE)
            self.trayicon.set_attention_icon('indicator-messages-new')
            self.trayicon.set_icon(logo_filename)
            self.trayicon.set_menu(self.make_menu())
        else:
            self.trayicon = gtk.StatusIcon()
            self.trayicon.set_from_file(logo_filename)
            self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon))
            self.trayicon.connect('activate', self.show_hide_toggle)
            self.trayicon.set_tooltip('GoAgent')
            self.trayicon.set_visible(True)
项目:XX-Net-Mini    作者:GFWParty    | 项目源码 | 文件源码
def __init__(self, window, terminal):
        self.window = window
        self.window.set_size_request(652, 447)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.connect('delete-event',self.delete_event)
        self.terminal = terminal

        for cmd in ('python2.7', 'python27', 'python2'):
            if os.system('which %s' % cmd) == 0:
                self.command[1] = cmd
                break

        self.window.add(terminal)
        self.childpid = self.terminal.fork_command(self.command[0], self.command, os.getcwd())
        if self.childpid > 0:
            self.childexited = self.terminal.connect('child-exited', self.on_child_exited)
            self.window.connect('delete-event', lambda w, e: gtk.main_quit())
        else:
            self.childexited = None

        spawn_later(0.5, self.show_startup_notify)

        if should_visible():
            self.window.show_all()

        logo_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'goagent-logo.png')
        if not os.path.isfile(logo_filename):
            with open(logo_filename, 'wb') as fp:
                fp.write(base64.b64decode(GOAGENT_LOGO_DATA))
        self.window.set_icon_from_file(logo_filename)

        if appindicator:
            self.trayicon = appindicator.Indicator('XX-Mini', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS)
            self.trayicon.set_status(appindicator.STATUS_ACTIVE)
            self.trayicon.set_attention_icon('indicator-messages-new')
            self.trayicon.set_icon(logo_filename)
            self.trayicon.set_menu(self.make_menu())
        else:
            self.trayicon = gtk.StatusIcon()
            self.trayicon.set_from_file(logo_filename)
            self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon))
            self.trayicon.connect('activate', self.show_hide_toggle)
            self.trayicon.set_tooltip('XX-Mini')
            self.trayicon.set_visible(True)