コード例 #1
0
ファイル: enginesDialog.py プロジェクト: ypeng22/pychess
def run(widgets):
    global firstRun, engine_dialog
    if firstRun:
        # Display of the countries
        items = []
        for iso in ISO3166_LIST:
            path = addDataPrefix("flags/%s.png" % iso.iso2)
            if not (iso.iso2 and os.path.isfile(path)):
                path = addDataPrefix("flags/unknown.png")
            items.append((get_pixbuf(path), iso.country))
        uistuff.createCombo(widgets["engine_country_combo"],
                            name="engine_country_combo",
                            ellipsize_mode=Pango.EllipsizeMode.END)
        data = [(item[0], item[1]) for item in items]
        uistuff.updateCombo(widgets["engine_country_combo"], data)

        engine_dialog = EnginesDialog(widgets)

        def cancel_event(widget, with_confirmation, *args):
            # Confirm if the changes need to be saved
            modified = discoverer.hasChanged()
            if modified and with_confirmation:
                dialog = Gtk.MessageDialog(mainwindow(),
                                           type=Gtk.MessageType.QUESTION,
                                           buttons=Gtk.ButtonsType.YES_NO)
                dialog.set_markup(
                    _("You have unsaved changes. Do you want to save before leaving?"
                      ))
                response = dialog.run()
                dialog.destroy()
                # if response == Gtk.ResponseType.CANCEL:
                #    return False
                if response == Gtk.ResponseType.NO:
                    discoverer.restore()
                if response == Gtk.ResponseType.YES:
                    discoverer.save()

            # Close the window
            widgets["manage_engines_dialog"].hide()
            return True

        def save_event(widget, *args):
            discoverer.save()
            widgets["manage_engines_dialog"].hide()
            return True

        widgets["manage_engines_dialog"].connect("delete-event", cancel_event,
                                                 True)
        widgets["engine_cancel_button"].connect("clicked", cancel_event, False)
        widgets["engine_save_button"].connect("clicked", save_event)
        widgets["manage_engines_dialog"].connect(
            "key-press-event", lambda w, e: cancel_event(w, True)
            if e.keyval == Gdk.KEY_Escape else None)

    discoverer.backup()
    engine_dialog.widgets["enginebook"].set_current_page(0)
    widgets["manage_engines_dialog"].show()
    if not firstRun:
        engine_dialog.update_store()
    firstRun = False
コード例 #2
0
ファイル: enginesDialog.py プロジェクト: leogregianin/pychess
def run(widgets):
    global firstRun, engine_dialog
    if firstRun:
        # Display of the countries
        items = []
        for iso in ISO3166_LIST:
            path = addDataPrefix("flags/%s.png" % iso.iso2)
            if not(iso.iso2 and os.path.isfile(path)):
                path = addDataPrefix("flags/unknown.png")
            items.append((get_pixbuf(path), iso.country))
        uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo",
                            ellipsize_mode=Pango.EllipsizeMode.END)
        data = [(item[0], item[1]) for item in items]
        uistuff.updateCombo(widgets["engine_country_combo"], data)

        engine_dialog = EnginesDialog(widgets)

        def cancel_event(widget, with_confirmation, *args):
            # Confirm if the changes need to be saved
            modified = discoverer.hasChanged()
            if modified and with_confirmation:
                dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
                dialog.set_markup(_("You have unsaved changes. Do you want to save before leaving?"))
                response = dialog.run()
                dialog.destroy()
                # if response == Gtk.ResponseType.CANCEL:
                #    return False
                if response == Gtk.ResponseType.NO:
                    discoverer.restore()
                if response == Gtk.ResponseType.YES:
                    discoverer.save()

            # Close the window
            widgets["manage_engines_dialog"].hide()
            return True

        def save_event(widget, *args):
            discoverer.save()
            widgets["manage_engines_dialog"].hide()
            return True

        widgets["manage_engines_dialog"].connect("delete-event", cancel_event, True)
        widgets["engine_cancel_button"].connect("clicked", cancel_event, False)
        widgets["engine_save_button"].connect("clicked", save_event)
        widgets["manage_engines_dialog"].connect(
            "key-press-event",
            lambda w, e: cancel_event(w, True) if e.keyval == Gdk.KEY_Escape else None)

    discoverer.backup()
    engine_dialog.widgets["enginebook"].set_current_page(0)
    widgets["manage_engines_dialog"].show()
    if not firstRun:
        engine_dialog.update_store()
    firstRun = False
コード例 #3
0
 def updateCombos(*args):
     if cls.widgets["playNormalRadio"].get_active():
         variant = NORMALCHESS
     elif cls.widgets["playVariant1Radio"].get_active():
         variant = conf.get("ngvariant1", FISCHERRANDOMCHESS)
     else:
         variant = conf.get("ngvariant2", LOSERSCHESS)
     variant1 = conf.get("ngvariant1", FISCHERRANDOMCHESS)
     cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)            
     variant2 = conf.get("ngvariant2", LOSERSCHESS)
     cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
     uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], playerItems[variant])
     uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], playerItems[variant])
コード例 #4
0
ファイル: newGameDialog.py プロジェクト: leogregianin/pychess
 def updateCombos(*args):
     if cls.widgets["playNormalRadio"].get_active():
         variant = NORMALCHESS
     elif cls.widgets["playVariant1Radio"].get_active():
         variant = conf.get("ngvariant1")
     else:
         variant = conf.get("ngvariant2")
     variant1 = conf.get("ngvariant1")
     cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
     variant2 = conf.get("ngvariant2")
     cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
     data = [(item[0], item[1]) for item in playerItems[variant]]
     uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data)
     uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data)
コード例 #5
0
 def updateCombos(*args):
     if cls.widgets["playNormalRadio"].get_active():
         variant = NORMALCHESS
     elif cls.widgets["playVariant1Radio"].get_active():
         variant = conf.get("ngvariant1")
     else:
         variant = conf.get("ngvariant2")
     variant1 = conf.get("ngvariant1")
     cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
     variant2 = conf.get("ngvariant2")
     cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
     data = [(item[0], item[1]) for item in playerItems[variant]]
     uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data)
     uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data)
コード例 #6
0
ファイル: enginesDialog.py プロジェクト: scchess/pychess
def run(widgets):
    global firstRun
    if firstRun:
        # Bubble sort for the translated countries
        for i in range(len(ISO3166_LIST) - 1, 1, -1):
            for j in range(1, i - 1):
                if ISO3166_LIST[i].country < ISO3166_LIST[j].country:
                    tmp = ISO3166_LIST[i]
                    ISO3166_LIST[i] = ISO3166_LIST[j]
                    ISO3166_LIST[j] = tmp
        # Display of the countries
        items = []
        for iso in ISO3166_LIST:
            path = addDataPrefix("flags/%s.png" % iso.iso2)
            if not (iso.iso2 and os.path.isfile(path)):
                path = addDataPrefix("flags/unknown.png")
            items.append((get_pixbuf(path), iso.country))
        uistuff.createCombo(widgets["engine_country_combo"],
                            name="engine_country_combo")
        data = [(item[0], item[1]) for item in items]
        uistuff.updateCombo(widgets["engine_country_combo"], data)

        EnginesDialog(widgets)

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

        widgets["manage_engines_dialog"].connect("delete-event", delete_event)
        widgets["engines_close_button"].connect("clicked", delete_event)
        widgets["manage_engines_dialog"].connect(
            "key-press-event", lambda w, e: delete_event(w)
            if e.keyval == Gdk.KEY_Escape else None)

        firstRun = False

    widgets["manage_engines_dialog"].show()
コード例 #7
0
def run(widgets):
    global firstRun
    if firstRun:
        # Bubble sort for the translated countries
        for i in range(len(ISO3166_LIST) - 1, 1, - 1):
            for j in range(1, i - 1):
                if ISO3166_LIST[i].country < ISO3166_LIST[j].country:
                    tmp = ISO3166_LIST[i]
                    ISO3166_LIST[i] = ISO3166_LIST[j]
                    ISO3166_LIST[j] = tmp
        # Display of the countries
        items = []
        for iso in ISO3166_LIST:
            path = addDataPrefix("flags/%s.png" % iso.iso2)
            if not(iso.iso2 and os.path.isfile(path)):
                path = addDataPrefix("flags/unknown.png")
            items.append((get_pixbuf(path), iso.country))
        uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo",
                            ellipsize_mode=Pango.EllipsizeMode.END)
        data = [(item[0], item[1]) for item in items]
        uistuff.updateCombo(widgets["engine_country_combo"], data)

        EnginesDialog(widgets)

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

        widgets["manage_engines_dialog"].connect("delete-event", delete_event)
        widgets["engines_close_button"].connect("clicked", delete_event)
        widgets["manage_engines_dialog"].connect(
            "key-press-event",
            lambda w, e: delete_event(w) if e.keyval == Gdk.KEY_Escape else None)

        firstRun = False

    widgets["manage_engines_dialog"].show()
コード例 #8
0
ファイル: analyzegameDialog.py プロジェクト: metiscus/pychess
 def update_analyzers_store(discoverer):
     data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
     uistuff.updateCombo(widgets["ana_combobox"], data)
コード例 #9
0
 def update_analyzers_store(discoverer):
     data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
     uistuff.updateCombo(widgets["ana_combobox"], data)
     uistuff.updateCombo(widgets["inv_ana_combobox"], data)