• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python uistuff.keepWindowSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pychess.System.uistuff.keepWindowSize函数的典型用法代码示例。如果您正苦于以下问题:Python keepWindowSize函数的具体用法?Python keepWindowSize怎么用?Python keepWindowSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了keepWindowSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: initUi

    def initUi (self):
        self.window = Gtk.Window()
        self.window.set_border_width(12)
        self.window.set_icon_name("pychess")
        self.window.set_title("PyChess - Internet Chess Chat")
        self.window.connect("delete-event", lambda w,e: w.hide() or True)

        uistuff.keepWindowSize("chatwindow", self.window, defaultSize=(650,400))

        dock = PyDockTop("icchat")
        dock.show()
        self.window.add(dock)

        leaf = dock.dock(self.viewspanel, CENTER, Gtk.Label(label="chat"), "chat")
        leaf.setDockable(False)

        self.channelspanel.connect('conversationAdded', self.onConversationAdded)
        self.channelspanel.connect('conversationRemoved', self.onConversationRemoved)
        self.channelspanel.connect('conversationSelected', self.onConversationSelected)
        leaf.dock(self.channelspanel, WEST, Gtk.Label(label=_("Conversations")), "conversations")

        leaf.dock(self.infopanel, EAST, Gtk.Label(label=_("Conversation info")), "info")

        for panel in self.panels:
            panel.show_all()
            panel.start()
开发者ID:sally0813,项目名称:pychess,代码行数:26,代码来源:ChatWindow.py


示例2: __init__

    def __init__ (self):
        self.connection = None
        self.lounge = None
        self.canceled = False
        self.cids = defaultdict(list)
        self.widgets = uistuff.GladeWidgets("fics_logon.glade")
        uistuff.keepWindowSize("fics_logon", self.widgets["fics_logon"],
                               defaultPosition=uistuff.POSITION_GOLDEN)
        self.widgets["fics_logon"].connect('key-press-event',
                lambda w, e: e.keyval == Gdk.KEY_Escape and w.hide())        
        def on_logOnAsGuest_toggled (check):
            self.widgets["passwordLabel"].set_sensitive(not check.get_active())
            self.widgets["passEntry"].set_sensitive(not check.get_active())
        self.widgets["logOnAsGuest"].connect("toggled", on_logOnAsGuest_toggled)
        uistuff.keep(self.widgets["logOnAsGuest"], "logOnAsGuest")
        uistuff.keep(self.widgets["nameEntry"], "usernameEntry")
        uistuff.keep(self.widgets["passEntry"], "passwordEntry")
        self.infobar = Gtk.InfoBar()
        self.infobar.set_message_type(Gtk.MessageType.WARNING)
        #self.widgets["messagePanelHBox"].pack_start(self.infobar, 
        #    expand=False, fill=False)
        self.widgets["messagePanelHBox"].pack_start(self.infobar, 
            False, False, 0)        
        self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
        self.widgets["stopButton"].connect("clicked", self.onCancel, False)
        self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
        self.widgets["connectButton"].connect("clicked", self.onConnectClicked)

        self.widgets["progressbar"].set_show_text(True)
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:29,代码来源:ICLogon.py


示例3: __init__

 def __init__ (self):
     self.widgets = uistuff.GladeWidgets("fics_logon.glade")
     uistuff.keepWindowSize("fics_logon", self.widgets["fics_logon"],
                            defaultPosition=uistuff.POSITION_GOLDEN)
     
     self.widgets["fics_logon"].connect('key-press-event',
             lambda w, e: e.keyval == gtk.keysyms.Escape and w.hide())
     
     
     def on_logOnAsGuest_toggled (check):
         self.widgets["nameLabel"].set_sensitive(not check.get_active())
         self.widgets["nameEntry"].set_sensitive(not check.get_active())
         self.widgets["passwordLabel"].set_sensitive(not check.get_active())
         self.widgets["passEntry"].set_sensitive(not check.get_active())
     self.widgets["logOnAsGuest"].connect("toggled", on_logOnAsGuest_toggled)
     uistuff.keep(self.widgets["logOnAsGuest"], "logOnAsGuest")
     uistuff.keep(self.widgets["nameEntry"], "usernameEntry")
     uistuff.keep(self.widgets["passEntry"], "passwordEntry")
     uistuff.makeYellow(self.widgets["messagePanel"])
     
     self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
     self.widgets["stopButton"].connect("clicked", self.onCancel, False)
     self.widgets["fics_logon"].connect("delete-event", self.onClose)
     
     self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
     self.widgets["connectButton"].connect("clicked", self.onConnectClicked)
     
     self.connection = None
     self.lounge = None
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:29,代码来源:ICLogon.py


示例4: __init__

    def __init__(self):
        self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL, title=_("Ask for permissions"))
        self.window.set_transient_for(mainwindow())
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        gtk_version = (Gtk.get_major_version(), Gtk.get_minor_version())
        if gtk_version >= (3, 12):
            vbox.props.margin_start = 9
            vbox.props.margin_end = 9
        else:
            vbox.props.margin_left = 9
            vbox.props.margin_right = 9
        vbox.props.margin_bottom = 9
        self.window.add(vbox)
        uistuff.keepWindowSize("externalsdialog", self.window, (320, 240), uistuff.POSITION_CENTER)

        label = Gtk.Label(_("Some of PyChess features needs your permission to download external programs"))
        vbox.pack_start(label, True, True, 0)

        box = Gtk.Box()
        check_button = Gtk.CheckButton(_("database querying needs scoutfish"))
        check_button.set_active(conf.get("download_scoutfish", False))
        check_button.connect("toggled", lambda w: conf.set("download_scoutfish", w.get_active()))
        box.add(check_button)
        link = "https://github.com/pychess/scoutfish"
        link_button = Gtk.LinkButton(link, link)
        box.add(link_button)
        vbox.pack_start(box, False, False, 0)

        box = Gtk.Box()
        check_button = Gtk.CheckButton(_("database opening tree needs chess_db"))
        check_button.set_active(conf.get("download_chess_db", False))
        check_button.connect("toggled", lambda w: conf.set("download_chess_db", w.get_active()))
        box.add(check_button)
        link = "https://github.com/pychess/chess_db"
        link_button = Gtk.LinkButton(link, link)
        box.add(link_button)
        vbox.pack_start(box, False, False, 0)

        box = Gtk.Box()
        check_button = Gtk.CheckButton(_("ICC lag compensation needs timestamp"))
        check_button.set_active(conf.get("download_timestamp", False))
        check_button.connect("toggled", lambda w: conf.set("download_timestamp", w.get_active()))
        box.add(check_button)
        link = "https://www.chessclub.com/user/resources/icc/timestamp"
        link_button = Gtk.LinkButton(link, link)
        box.add(link_button)
        vbox.pack_start(box, False, False, 0)

        check_button = Gtk.CheckButton(_("Don't show this dialog on startup."))
        check_button.set_active(conf.get("dont_show_externals_at_startup", False))
        check_button.connect("toggled", lambda w: conf.set("dont_show_externals_at_startup", w.get_active()))
        vbox.pack_start(check_button, True, True, 0)

        buttonbox = Gtk.ButtonBox()
        close_button = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        close_button.connect("clicked", self.on_close_clicked)
        self.window.connect("delete_event", lambda w, a: self.window.destroy())
        buttonbox.add(close_button)
        vbox.pack_start(buttonbox, False, False, 0)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:59,代码来源:ExternalsDialog.py


示例5: __init__

    def __init__(self):
        self.connection = None
        self.lounge = None
        self.canceled = False
        self.cids = defaultdict(list)
        self.widgets = uistuff.GladeWidgets("fics_logon.glade")
        uistuff.keepWindowSize("fics_logon",
                               self.widgets["fics_logon"],
                               defaultPosition=uistuff.POSITION_GOLDEN)
        self.widgets["fics_logon"].connect(
            'key-press-event',
            lambda w, e: e.keyval == Gdk.KEY_Escape and w.hide())

        def on_logOnAsGuest_toggled(check):
            names = get_user_names()
            self.widgets["nameEntry"].set_text(names[1] if check.get_active()
                                               else names[0])
            self.widgets["passwordLabel"].set_sensitive(not check.get_active())
            self.widgets["passEntry"].set_sensitive(not check.get_active())

        self.widgets["logOnAsGuest"].connect("toggled",
                                             on_logOnAsGuest_toggled)
        uistuff.keep(self.widgets["logOnAsGuest"], "asGuestCheck")

        as_guest = self.widgets["logOnAsGuest"]

        def user_name_get_value(entry):
            names = get_user_names()
            if as_guest.get_active():
                text = "%s|%s" % (names[0], entry.get_text())
            else:
                text = "%s|%s" % (entry.get_text(), names[1])
            return text

        def user_name_set_value(entry, value):
            names = get_user_names(value=value)
            if as_guest.get_active():
                entry.set_text(names[1])
            else:
                entry.set_text(names[0])

        uistuff.keep(self.widgets["nameEntry"], "usernameEntry",
                     user_name_get_value, user_name_set_value)
        uistuff.keep(self.widgets["passEntry"], "passwordEntry")
        uistuff.keep(self.widgets["hostEntry"], "hostEntry")
        uistuff.keep(self.widgets["autoLogin"], "autoLogin")
        self.infobar = Gtk.InfoBar()
        self.infobar.set_message_type(Gtk.MessageType.WARNING)
        # self.widgets["messagePanelHBox"].pack_start(self.infobar,
        #    expand=False, fill=False)
        self.widgets["messagePanelHBox"].pack_start(self.infobar, False, False,
                                                    0)
        self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
        self.widgets["stopButton"].connect("clicked", self.onCancel, False)
        self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
        self.widgets["connectButton"].connect("clicked", self.onConnectClicked)

        self.widgets["progressbar"].set_show_text(True)
开发者ID:CarbonFixer,项目名称:pychess,代码行数:58,代码来源:ICLogon.py


示例6: __init__

    def __init__(self):
        self.widgets = uistuff.GladeWidgets("tipoftheday.glade")
        self.widgets["window1"].set_transient_for(mainwindow())
        uistuff.keepWindowSize("tipoftheday", self.widgets["window1"], (320, 240), uistuff.POSITION_CENTER)

        self.widgets["checkbutton1"].set_active(conf.get("show_tip_at_startup"))
        self.widgets["checkbutton1"].connect("toggled", lambda w: conf.set("show_tip_at_startup", w.get_active()))
        self.widgets["close_button"].connect("clicked", lambda w: self.widgets["window1"].emit("delete-event", None))
        self.widgets["window1"].connect("delete_event", lambda w, a: self.widgets["window1"].destroy())
        self.widgets["back_button"].connect("clicked", lambda w: self.set_currentIndex(self.currentIndex - 1))
        self.widgets["forward_button"].connect("clicked", lambda w: self.set_currentIndex(self.currentIndex + 1))

        self.currentIndex = 0
开发者ID:leogregianin,项目名称:pychess,代码行数:13,代码来源:tipOfTheDay.py


示例7: initialize

def initialize(widgets):
    GeneralTab(widgets)
    HintTab(widgets)
    SoundTab(widgets)
    PanelTab(widgets)
    ThemeTab(widgets)
    
    uistuff.keepWindowSize("preferencesdialog", widgets["preferences"],
                           defaultPosition=POSITION_GOLDEN)
    def delete_event (widget, *args):
        widgets["preferences"].hide()
        return True
    widgets["preferences"].connect("delete-event", delete_event)
    widgets["preferences"].connect("key-press-event",
        lambda w,e: w.event(Gdk.Event(Gdk.EventType.DELETE))
        if e.keyval == Gdk.KEY_Escape else None)
开发者ID:Krando,项目名称:pychess,代码行数:16,代码来源:preferencesDialog.py


示例8: __init__

    def __init__(self):
        self.connection = None
        self.helperconn = None
        self.connection_task = None
        self.helperconn_task = None
        self.lounge = None
        self.canceled = False
        self.cids = defaultdict(list)
        self.widgets = uistuff.GladeWidgets("fics_logon.glade")
        uistuff.keepWindowSize("fics_logon",
                               self.widgets["fics_logon"],
                               defaultPosition=uistuff.POSITION_GOLDEN)
        self.widgets["fics_logon"].connect(
            'key-press-event',
            lambda w, e: e.keyval == Gdk.KEY_Escape and w.hide())

        self.ics = "FICS"
        self.as_guest = self.widgets["logOnAsGuest"]

        self.widgets["logOnAsGuest"].connect("toggled", self.on_logOnAsGuest_toggled)

        def on_username_changed(widget):
            conf.set("usernameEntry", self.user_name_get_value(widget), section=self.ics)
        self.widgets["nameEntry"].connect("changed", on_username_changed)

        def on_password_changed(widget):
            conf.set("passwordEntry", widget.get_text(), section=self.ics)
        self.widgets["passEntry"].connect("changed", on_password_changed)

        def on_host_changed(widget):
            conf.set("hostEntry", self.host_get_value(widget), section=self.ics)
        self.widgets["hostEntry"].connect("changed", on_host_changed)

        self.widgets["timesealCheck"].connect("toggled", self.on_timeseal_toggled)

        self.infobar = Gtk.InfoBar()
        self.infobar.set_message_type(Gtk.MessageType.WARNING)
        # self.widgets["messagePanelHBox"].pack_start(self.infobar,
        #    expand=False, fill=False)
        self.widgets["messagePanelHBox"].pack_start(self.infobar, False, False,
                                                    0)
        self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
        self.widgets["stopButton"].connect("clicked", self.onCancel, False)
        self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
        self.widgets["connectButton"].connect("clicked", self.onConnectClicked)

        self.widgets["progressbar"].set_show_text(True)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:47,代码来源:ICLogon.py


示例9: __init__

    def __init__ (self, widgets, connection):
        self.connection = connection

        self.window = Gtk.Window()
        self.window.set_border_width(12)
        self.window.set_icon_name("pychess")
        self.window.set_title("FICS Console")
        self.window.connect("delete-event", lambda w,e: w.hide() or True)
        
        uistuff.keepWindowSize("consolewindow", self.window, defaultSize=(700,400))

        self.consoleView = ConsoleView(self.connection)
        self.window.add(self.consoleView)
        
        widgets["show_console_button"].connect("clicked", self.showConsole)
        connection.com.connect("consoleMessage", self.onConsoleMessage)
        connection.connect("disconnected", self.onDisconnected)
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:17,代码来源:ConsoleWindow.py


示例10: initialize

def initialize(widgets):
    GeneralTab(widgets)
    HintTab(widgets)
    SoundTab(widgets)
    PanelTab(widgets)
    ThemeTab(widgets)
    
    def delete_event (widget, *args):
        widgets["preferences"].hide()
        return False
    widgets["preferences"].connect("delete-event", delete_event)
    widgets["preferences_close_button"].connect("clicked", delete_event)
    
    widgets["preferences"].connect("key-press-event",
        lambda w,e: delete_event(w) if e.keyval == gtk.keysyms.Escape else None)

    uistuff.keepWindowSize("preferencesdialog", widgets["preferences"],
                           defaultPosition=POSITION_GOLDEN)
开发者ID:btrent,项目名称:knave,代码行数:18,代码来源:preferencesDialog.py


示例11: initialize

def initialize(widgets):
    GeneralTab(widgets)
    HintTab(widgets)
    SoundTab(widgets)
    PanelTab(widgets)
    ThemeTab(widgets)
    SaveTab(widgets)

    widgets["preferences_notebook"].set_name("preferences_notebook")
    uistuff.keepWindowSize("preferencesdialog", widgets["preferences_dialog"])

    def delete_event(widget, *args):
        widgets["preferences_dialog"].hide()
        return True

    widgets["preferences_dialog"].connect("delete-event", delete_event)
    widgets["preferences_dialog"].connect(
        "key-press-event",
        lambda w, e: w.event(Gdk.Event(Gdk.EventType.DELETE)) if e.keyval == Gdk.KEY_Escape else None)
开发者ID:jcoffee,项目名称:pychess,代码行数:19,代码来源:preferencesDialog.py


示例12: initialize

def initialize(widgets):
    """ :Description: Initialises the various tabs for each section of configurable artifacts
    """
    GeneralTab(widgets)
    HintTab(widgets)
    SoundTab(widgets)
    PanelTab(widgets)
    ThemeTab(widgets)
    SaveTab(widgets)

    uistuff.keepWindowSize("preferencesdialog", widgets["preferences_dialog"])

    def delete_event(widget, _):
        widgets["preferences_dialog"].hide()
        return True

    widgets["preferences_dialog"].connect("delete-event", delete_event)
    widgets["preferences_dialog"].connect(
        "key-press-event",
        lambda w, e: w.event(Gdk.Event(Gdk.EventType.DELETE)) if e.keyval == Gdk.KEY_Escape else None)
开发者ID:bboutkov,项目名称:pychess,代码行数:20,代码来源:preferencesDialog.py


示例13: _init

    def _init(cls):
        cls.tagToIter = {}
        cls.tagToPage = {}
        cls.pathToPage = {}
        cls.tagToTime = {}

        cls.window = Gtk.Window()
        cls.window.set_title(_("PyChess Information Window"))
        cls.window.set_border_width(12)
        cls.window.set_icon_name("pychess")
        uistuff.keepWindowSize("logdialog", cls.window, (640, 480))
        mainHBox = Gtk.HBox()
        mainHBox.set_spacing(6)
        cls.window.add(mainHBox)

        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        sw.set_shadow_type(Gtk.ShadowType.IN)
        mainHBox.pack_start(sw, False, True, 0)
        cls.treeview = Gtk.TreeView(Gtk.TreeStore(str))
        cls.treeview.append_column(Gtk.TreeViewColumn("",
                                                      Gtk.CellRendererText(),
                                                      text=0))
        cls.treeview.set_headers_visible(False)
        cls.treeview.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        sw.add(cls.treeview)
        cls.pages = Gtk.Notebook()
        cls.pages.set_show_tabs(False)
        cls.pages.set_show_border(False)
        mainHBox.pack_start(cls.pages, True, True, 0)

        mainHBox.show_all()

        def selectionChanged(selection):
            treestore, iter = selection.get_selected()
            if iter:
                child = cls.pathToPage[treestore.get_path(iter).to_string()][
                    "child"]
                cls.pages.set_current_page(cls.pages.page_num(child))

        cls.treeview.get_selection().connect("changed", selectionChanged)
开发者ID:bboutkov,项目名称:pychess,代码行数:41,代码来源:LogDialog.py


示例14: __init__

    def __init__(self, widgets, connection):
        self.connection = connection

        self.window = Gtk.Window()
        self.window.set_border_width(12)

        # ChatWindow uses this to check is_active() so don't touch this!
        self.window.set_icon_name("pychess")

        self.window.set_title("%s Console" % connection.ics_name)
        self.window.connect_after("delete-event",
                                  lambda w, e: w.hide() or True)

        uistuff.keepWindowSize("console", self.window, defaultSize=(800, 400))

        self.consoleView = ConsoleView(self.window, self.connection)
        self.window.add(self.consoleView)

        widgets["show_console_button"].connect("clicked", self.showConsole)
        connection.com.connect("consoleMessage", self.onConsoleMessage)
        connection.connect("disconnected", self.onDisconnected)
开发者ID:JoelMon,项目名称:pychess,代码行数:21,代码来源:ConsoleWindow.py


示例15: _init

 def _init (cls):
     cls.widgets = uistuff.GladeWidgets("tipoftheday.glade")
     
     uistuff.keepWindowSize("tipoftheday", cls.widgets["window1"],
                            (320,240), uistuff.POSITION_CENTER)
     
     cls.widgets["checkbutton1"].set_active(conf.get("show_tip_at_startup", False))
     cls.widgets["checkbutton1"].connect("toggled",
         lambda w: conf.set("show_tip_at_startup", w.get_active()))
     
     cls.widgets["close_button"].connect("clicked",
         lambda w: cls.widgets["window1"].emit("delete-event", None))
     cls.widgets["window1"].connect("delete_event",
         lambda w, a: cls.widgets["window1"].hide())
     
     cls.widgets["back_button"].connect("clicked",
         lambda w: cls.set_currentIndex(cls.currentIndex-1))
     cls.widgets["forward_button"].connect("clicked",
         lambda w: cls.set_currentIndex(cls.currentIndex+1))
     
     cls.currentIndex = 0
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:21,代码来源:tipOfTheDay.py


示例16: initialize

def initialize(widgets):
    """ :Description: Initialises the various tabs for each section of configurable artifacts
    """
    global general_tab
    general_tab = GeneralTab(widgets)

    # All side panels can be show/hide from View menu now, so no need to do the same from preferences
    # We can re enable this after implementing install/uninstall functionality in the future...
    # PanelTab(widgets)

    uistuff.keepWindowSize("preferencesdialog", widgets["preferences_dialog"])

    notebook = widgets["preferences_notebook"]

    def switch_page(widget, page, page_num):
        global hint_tab, theme_tab, sound_tab, save_tab

        if page_num == 1 and hint_tab is None:
            hint_tab = HintTab(widgets)
        elif page_num == 3 and theme_tab is None:
            theme_tab = ThemeTab(widgets)
        elif page_num == 4 and sound_tab is None:
            sound_tab = SoundTab(widgets)
        elif page_num == 5 and save_tab is None:
            save_tab = SaveTab(widgets)

    notebook.connect("switch_page", switch_page)

    def delete_event(widget, _):
        widgets["preferences_dialog"].hide()
        return True

    widgets["preferences_dialog"].connect("delete-event", delete_event)
    widgets["preferences_dialog"].connect(
        "key-press-event",
        lambda w, e: w.event(Gdk.Event(Gdk.EventType.DELETE)) if e.keyval == Gdk.KEY_Escape else None)
开发者ID:leogregianin,项目名称:pychess,代码行数:36,代码来源:preferencesDialog.py


示例17: initialize

def initialize(widgets):
    """ :Description: Initialises the various tabs for each section of configurable artifacts
    """
    GeneralTab(widgets)
    HintTab(widgets)
    SoundTab(widgets)

    # All side panels can be show/hide from View menu now, so no need to do the same from preferences
    # We can re enable this after implementing install/uninstall functionality in the future...
    # PanelTab(widgets)
    ThemeTab(widgets)

    SaveTab(widgets)

    uistuff.keepWindowSize("preferencesdialog", widgets["preferences_dialog"])

    def delete_event(widget, _):
        widgets["preferences_dialog"].hide()
        return True

    widgets["preferences_dialog"].connect("delete-event", delete_event)
    widgets["preferences_dialog"].connect(
        "key-press-event",
        lambda w, e: w.event(Gdk.Event(Gdk.EventType.DELETE)) if e.keyval == Gdk.KEY_Escape else None)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:24,代码来源:preferencesDialog.py


示例18: __init__

    def __init__(self, widgets):
        self.widgets = widgets
        self.dialog = self.widgets["manage_engines_dialog"]
        self.cur_engine = None
        self.default_workdir = getEngineDataPrefix()
        
        uistuff.keepWindowSize("engineswindow", self.dialog, defaultSize=(600, 500))

        # Put engines into tree store
        allstore = gtk.ListStore(gtk.gdk.Pixbuf, str)
        
        self.tv = self.widgets["engines_treeview"]
        self.tv.set_model(allstore)
        self.tv.append_column(gtk.TreeViewColumn(
                "Flag", gtk.CellRendererPixbuf(), pixbuf=0))
        name_renderer = gtk.CellRendererText()
        name_renderer.set_property("editable", True)
        self.tv.append_column(gtk.TreeViewColumn("Name", name_renderer, text=1))
        def name_edited(renderer, path, new_name):
            if self.cur_engine is not None:
                old_name = self.cur_engine
                if new_name and new_name != old_name:
                    names = [engine["name"] for engine in discoverer.getEngines()]
                    if new_name not in names:
                        engine = discoverer.getEngineByName(self.cur_engine)
                        engine["name"] = new_name
                        discoverer.save()
                        self.cur_engine = new_name
                        update_store()                        
                        # Notify playerCombos in NewGameTasker
                        discoverer.emit("all_engines_discovered")
        name_renderer.connect("edited", name_edited)

        # Add cell renderer to protocol combo column
        protocol_combo = self.widgets["engine_protocol_combo"]
        cell = gtk.CellRendererText()
        protocol_combo.pack_start(cell, True)
        protocol_combo.add_attribute(cell, "text", 0)

        # Add columns and cell renderers to options treeview 
        self.options_store = gtk.ListStore(str, gobject.TYPE_PYOBJECT)
        optv = self.widgets["options_treeview"]
        optv.set_model(self.options_store)
        optv.append_column(gtk.TreeViewColumn(
           "Option", gtk.CellRendererText(), text=0))
        optv.append_column(gtk.TreeViewColumn(
           "Data", KeyValueCellRenderer(self.options_store), data=1))

        def update_options(*args):
            if self.cur_engine is not None:
                engines = discoverer.getEngines()
                names = [engine["name"] for engine in engines]
                # After deleting an engine we will select first
                if self.cur_engine not in names:
                    self.cur_engine = engines[0]["name"]
                engine = discoverer.getEngineByName(self.cur_engine)
                options = engine.get("options")
                if options:
                    self.options_store.clear()
                    for option in options:
                        key = option["name"]
                        val = option
                        if option["type"] != "button":
                            val["default"] = option.get("default")
                            val["value"] = option.get("value", val["default"])
                        self.options_store.append([key, val])

        def update_store(*args):
            allstore.clear()
            newGameDialog.createPlayerUIGlobals(discoverer)
            # don't add the very first (Human) player to engine store
            for item in newGameDialog.playerItems[0][1:]:
                allstore.append(item)
            update_options()

        update_store()
        
        ################################################################
        # remove button
        ################################################################
        def remove(button):
            if self.cur_engine is not None:
                self.widgets['remove_engine_button'].set_sensitive(False)
                engine = discoverer.getEngineByName(self.cur_engine)
                discoverer.removeEngine(self.cur_engine)
                discoverer.save()
                update_store(discoverer)
                # Notify playerCombos in NewGameTasker
                discoverer.emit("all_engines_discovered")
                ts = self.tv.get_selection()
                ts.select_path((0,))

        self.widgets["remove_engine_button"].connect("clicked", remove)

        ################################################################
        # add button
        ################################################################
        engine_chooser_dialog = gtk.FileChooserDialog(_("Select engine"), None, gtk.FILE_CHOOSER_ACTION_OPEN,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))

#.........这里部分代码省略.........
开发者ID:btrent,项目名称:knave,代码行数:101,代码来源:enginesDialog.py


示例19: initGlade

    def initGlade(self, log_viewer):
        # Init glade and the 'GladeHandlers'
        self.widgets = widgets = uistuff.GladeWidgets("PyChess.glade")
        self.glade_handlers = GladeHandlers(self)
        widgets.getGlade().connect_signals(self.glade_handlers)
        self.window = widgets["main_window"]

        # new_game_tasker, internet_game_tasker = NewGameTasker(
        # ), InternetGameTasker()
        # tasker.packTaskers(new_game_tasker, internet_game_tasker)
        # widgets["Background"].add(tasker)

        # Redirect widgets
        gamewidget.setWidgets(widgets)

        # The only menuitems that need special initing
        for widget in ("hint_mode", "spy_mode"):
            widgets[widget].set_sensitive(False)

        uistuff.keep(widgets["hint_mode"], "hint_mode")
        uistuff.keep(widgets["spy_mode"], "spy_mode")
        uistuff.keep(widgets["show_sidepanels"], "show_sidepanels")
        uistuff.keep(widgets["auto_call_flag"], "autoCallFlag")

        # Show main window and init d'n'd
        widgets["main_window"].set_title('%s - PyChess' % _('Welcome'))
        widgets["main_window"].connect("delete-event", self.glade_handlers.on_quit1_activate)
        widgets["main_window"].connect("key-press-event", self.glade_handlers.on_window_key_press)

        uistuff.keepWindowSize("main", widgets["main_window"], None, uistuff.POSITION_GOLDEN)

        # To get drag in the whole window, we add it to the menu and the
        # background. If it can be gotten to work, the drag_dest_set_proxy
        # method is very interesting.
        widgets["menubar1"].drag_dest_set(Gtk.DestDefaults.ALL, DND_LIST, DRAG_ACTION)
        widgets["box2"].drag_dest_set(Gtk.DestDefaults.ALL, DND_LIST, DRAG_ACTION)
        widgets["perspectives_notebook"].drag_dest_set(Gtk.DestDefaults.ALL, DND_LIST, DRAG_ACTION)

        # Init 'minor' dialogs

        # Log dialog
        if log_viewer:
            from pychess.widgets import LogDialog
            LogDialog.add_destroy_notify(
                lambda: widgets["log_viewer1"].set_active(0))
        else:
            widgets["log_viewer1"].set_property('sensitive', False)

        # About dialog
        self.aboutdialog = widgets["aboutdialog1"]
        self.aboutdialog.set_program_name(NAME)
        self.aboutdialog.set_copyright("Copyright © 2006-2018")
        self.aboutdialog.set_version(VERSION_NAME + " " + VERSION)
        if os.path.isdir(prefix.addDataPrefix(".git")):
            try:
                label = subprocess.check_output(["git", "describe"])
            except subprocess.CalledProcessError:
                label = ""
            if label:
                comments = self.aboutdialog.get_comments()
                self.git_rev = label
                self.aboutdialog.set_comments("git %s\n%s" %
                                              (self.git_rev, comments))

        with open(prefix.addDataPrefix("ARTISTS"), encoding="utf-8") as f:
            self.aboutdialog.set_artists(f.read().splitlines())
        with open(prefix.addDataPrefix("AUTHORS"), encoding="utf-8") as f:
            self.aboutdialog.set_authors(f.read().splitlines())
        with open(prefix.addDataPrefix("DOCUMENTERS"), encoding="utf-8") as f:
            self.aboutdialog.set_documenters(f.read().splitlines())
        with open(prefix.addDataPrefix("TRANSLATORS"), encoding="utf-8") as f:
            self.aboutdialog.set_translator_credits(f.read())
        with open(prefix.addDataPrefix("LICENSE"), encoding="utf-8") as f:
            self.aboutdialog.set_license(f.read())

        widgets["load_recent_game1"].set_submenu(recent_menu)

        if conf.get("autoLogin"):
            internet_game_tasker.connectClicked(None)
开发者ID:leogregianin,项目名称:pychess,代码行数:79,代码来源:Main.py


示例20: __init__

    def __init__(self, widgets):
        self.widgets = widgets
        self.dialog = self.widgets["manage_engines_dialog"]
        self.cur_engine = None
        self.default_workdir = getEngineDataPrefix()
        
        uistuff.keepWindowSize("engineswindow", self.dialog, defaultSize=(1, 500))

        # Put engines into tree store
        allstore = Gtk.ListStore(Pixbuf, str)
        
        self.tv = self.widgets["engines_treeview"]
        self.tv.set_model(allstore)
        self.tv.append_column(Gtk.TreeViewColumn(
                "Flag", Gtk.CellRendererPixbuf(), pixbuf=0))
        name_renderer = Gtk.CellRendererText()
        name_renderer.set_property("editable", True)
        self.tv.append_column(Gtk.TreeViewColumn("Name", name_renderer, text=1))
        def name_edited(renderer, path, new_name):
            if self.cur_engine is not None:
                old_name = self.cur_engine
                if new_name and new_name != old_name:
                    names = [engine["name"] for engine in discoverer.getEngines()]
                    if new_name not in names:
                        engine = discoverer.getEngineByName(self.cur_engine)
                        engine["name"] = new_name
                        discoverer.save()
                        self.cur_engine = new_name
                        update_store()                        
                        # Notify playerCombos in NewGameTasker
                        discoverer.emit("all_engines_discovered")
        name_renderer.connect("edited", name_edited)

        # Add cell renderer to protocol combo column
        protocol_combo = self.widgets["engine_protocol_combo"]
        cell = Gtk.CellRendererText()
        protocol_combo.pack_start(cell, True)
        protocol_combo.add_attribute(cell, "text", 0)

        # Add columns and cell renderers to options treeview 
        self.options_store = Gtk.ListStore(str, GObject.TYPE_PYOBJECT)
        optv = self.widgets["options_treeview"]
        optv.set_model(self.options_store)
        optv.append_column(Gtk.TreeViewColumn(
           "Option", Gtk.CellRendererText(), text=0))
        optv.append_column(Gtk.TreeViewColumn(
           "Data", KeyValueCellRenderer(self.options_store), data=1))

        def update_options(*args):
            if self.cur_engine is not None:
                engines = discoverer.getEngines()
                names = [engine["name"] for engine in engines]
                # After deleting an engine we will select first
                if self.cur_engine not in names:
                    self.cur_engine = engines[0]["name"]
                engine = discoverer.getEngineByName(self.cur_engine)
                options = engine 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python Board.Board类代码示例发布时间:2022-05-25
下一篇:
Python uistuff.keep函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap