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)
def __init__(self): GObject.GObject.__init__(self) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["databaseTasker"] tasker.unparent() self.add(tasker) startButton = self.widgets["openButton"] startButton.set_name("openButton") liststore = Gtk.ListStore(str, str) self.recent_combo = self.widgets["recent_combo"] self.recent_combo.set_model(liststore) renderer_text = Gtk.CellRendererText() renderer_text.set_property("width-chars", 30) renderer_text.set_property("ellipsize", Pango.EllipsizeMode.END) self.recent_combo.pack_start(renderer_text, True) self.recent_combo.add_attribute(renderer_text, "text", 1) self.on_recent_menu_changed(recent_manager, liststore) recent_manager.connect("changed", self.on_recent_menu_changed, liststore) self.widgets["opendialog3"].connect("clicked", self.openDialogClicked) self.widgets["openButton"].connect("clicked", self.openClicked)
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
def __init__(self): GObject.GObject.__init__(self) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["internetGameTasker"] tasker.unparent() self.add(tasker) if ICLogon.dialog is None: ICLogon.dialog = ICLogon.ICLogon() liststore = Gtk.ListStore(str) liststore.append(["FICS"]) liststore.append(["ICC"]) self.ics_combo = self.widgets["ics_combo"] self.ics_combo.set_model(liststore) renderer_text = Gtk.CellRendererText() self.ics_combo.pack_start(renderer_text, True) self.ics_combo.add_attribute(renderer_text, "text", 0) self.ics_combo.connect("changed", ICLogon.dialog.on_ics_combo_changed) self.ics_combo.set_active(conf.get("ics_combo", 0)) self.widgets["connectButton"].connect("clicked", self.connectClicked) self.widgets["opendialog2"].connect("clicked", self.openDialogClicked) self.widgets["startIcon"].set_from_pixbuf(big_start) uistuff.keep(self.widgets["ics_combo"], "icsCombo") uistuff.keep(self.widgets["autoLogin"], "autoLogin")
def __init__(self): GObject.GObject.__init__(self) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["learnTasker"] tasker.unparent() self.add(tasker) startButton = self.widgets["learnButton"] startButton.set_name("learnButton") liststore = Gtk.ListStore(str, str) for file_name, title in PUZZLES: liststore.append([file_name, title]) self.puzzle_combo = self.widgets["puzzle_combo"] self.puzzle_combo.set_model(liststore) renderer_text = Gtk.CellRendererText() self.puzzle_combo.pack_start(renderer_text, True) self.puzzle_combo.add_attribute(renderer_text, "text", 1) # TODO: save latest selected # self.puzzle_combo.connect("changed", ???) self.puzzle_combo.set_active(conf.get("puzzle_combo", 0)) self.widgets["opendialog4"].connect("clicked", self.openDialogClicked) self.widgets["learnButton"].connect("clicked", self.learnClicked)
def __init__(self, gamelist): GObject.GObject.__init__(self) self.gamelist = gamelist self.widgets = uistuff.GladeWidgets("PyChess.glade") self.persp = perspective_manager.get_perspective("database") self.persp.connect("chessfile_opened", self.on_chessfile_opened) self.persp.connect("chessfile_closed", self.on_chessfile_closed) self.persp.connect("chessfile_imported", self.on_chessfile_imported) self.alignment = Gtk.Alignment() self.liststore = Gtk.ListStore(object, Pixbuf, str) self.set_model(self.liststore) self.set_pixbuf_column(1) self.set_text_column(2) self.set_item_orientation(Gtk.Orientation.HORIZONTAL) self.set_activate_on_single_click(True) self.set_selection_mode(Gtk.SelectionMode.BROWSE) pixbuf = Gtk.IconTheme.get_default().load_icon("edit-paste", 32, 0) info = "%s\n%s %s" % (CLIPBASE, "pdb", 0) self.liststore.append([self.gamelist.chessfile, pixbuf, info]) self.connect("item-activated", self.on_item_activated) self.alignment.add(self) self.alignment.show_all() treepath = Gtk.TreePath(0) self.select_path(treepath)
def __init__(self): #GObject.GObject.__init__(self,0,0,0,0) GObject.GObject.__init__(self) self.widgets = widgets = uistuff.GladeWidgets("taskers.glade") tasker = widgets["newGameTasker"] tasker.unparent() self.add(tasker) combo = ToggleComboBox() combo.addItem(_("White"), get_pixbuf("glade/white.png")) combo.addItem(_("Black"), get_pixbuf("glade/black.png")) combo.addItem(_("Random"), get_pixbuf("glade/random.png")) combo.setMarkup("<b>", "</b>") widgets["colorDock"].add(combo) uistuff.keep(combo, "newgametasker_colorcombo") widgets['yourColorLabel'].set_mnemonic_widget(combo) # We need to wait until after engines have been discovered, to init the # playerCombos. We use connect_after to make sure, that newGameDialog # has also had time to init the constants we share with them. self.playerCombo = ToggleComboBox() widgets["opponentDock"].add(self.playerCombo) discoverer.connect_after("all_engines_discovered", self.__initPlayerCombo, widgets) widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo) def on_skill_changed(scale): pix = newGameDialog.skillToIconLarge[int(scale.get_value())] widgets["skillImage"].set_from_pixbuf(pix) widgets["skillSlider"].connect("value-changed", on_skill_changed) on_skill_changed(widgets["skillSlider"]) widgets["startButton"].connect("clicked", self.startClicked) self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
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)
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)
def _createPage(cls, parrentIter, tag): name = tag[-1] iter = cls.treeview.get_model().append(parrentIter, (name, )) cls.tagToIter[tag] = iter widgets = uistuff.GladeWidgets("findbar.glade") frame = widgets["frame"] frame.unparent() frame.show_all() uistuff.keepDown(widgets["scrolledwindow"]) textview = widgets["textview"] tb = textview.get_buffer() tb.create_tag(str(LOG_DEBUG), family='Monospace') tb.create_tag(str(LOG_LOG), family='Monospace', weight=pango.WEIGHT_BOLD) tb.create_tag(str(LOG_WARNING), family='Monospace', foreground="red") tb.create_tag(str(LOG_ERROR), family='Monospace', weight=pango.WEIGHT_BOLD, foreground="red") findbar = widgets["findbar"] findbar.hide() # Make searchEntry and "out of label" share height with the buttons widgets["prevButton"].connect( "size-allocate", lambda w, alloc: widgets["searchEntry"].set_size_request( -1, alloc.height) or widgets["outofLabel"].set_size_request( -1, alloc.height - 2)) # Make "out of label" more visually distinct uistuff.makeYellow(widgets["outofLabel"]) widgets["outofLabel"].hide() widgets["closeButton"].connect("clicked", lambda w: widgets["findbar"].hide()) # Connect showing/hiding of the findbar cls.window.connect("key-press-event", cls.onTextviewKeypress, widgets) widgets["findbar"].connect("key-press-event", cls.onFindbarKeypress) widgets["searchEntry"].connect("changed", cls.onSearchChanged, widgets) widgets["prevButton"].connect("clicked", lambda w: cls.searchJump(-1, widgets)) widgets["nextButton"].connect("clicked", lambda w: cls.searchJump(1, widgets)) cls.pages.append_page(frame) page = {"child": frame, "textview": textview} cls.tagToPage[tag] = page cls.pathToPage[cls.treeview.get_model().get_path(iter)] = page cls.treeview.expand_all()
def setUp(self): widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp) self.learn_persp = Learn() perspective_manager.add_perspective(self.learn_persp)
def setUp(self): widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp) self.database_persp = Database() self.database_persp.create_toolbuttons() perspective_manager.add_perspective(self.database_persp)
def __init__(self): GObject.GObject.__init__(self) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["internetGameTasker"] tasker.unparent() self.add(tasker) def asGuestCallback(check): names = ICLogon.get_user_names() self.widgets["usernameEntry"].set_text( names[1] if check.get_active() else names[0]) self.widgets["passwordLabel"].set_sensitive(not check.get_active()) self.widgets["passwordEntry"].set_sensitive(not check.get_active()) self.widgets["asGuestCheck"].connect("toggled", asGuestCallback) uistuff.keep(self.widgets["asGuestCheck"], "asGuestCheck") as_guest = self.widgets["asGuestCheck"] def user_name_get_value(entry): names = ICLogon.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 = ICLogon.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["usernameEntry"], "usernameEntry", user_name_get_value, user_name_set_value) # workaround to FICS Password input doesnt handle strings starting with a number # https://github.com/pychess/pychess/issues/1375 def password_set_value(entry, value): entry.set_text(str(value)) uistuff.keep(self.widgets["passwordEntry"], "passwordEntry", set_value_=password_set_value) self.widgets["connectButton"].connect("clicked", self.connectClicked) self.widgets["opendialog2"].connect("clicked", self.openDialogClicked) self.widgets["startIcon"].set_from_pixbuf(big_start)
def __init__(self): self.widgets = uistuff.GladeWidgets("promotion.glade") self.dialog = self.widgets["promotionDialog"] self.color = None self.widgets["knightDock"].add(PieceWidget(Piece(WHITE, KNIGHT))) self.widgets["knightDock"].child.show() self.widgets["bishopDock"].add(PieceWidget(Piece(WHITE, BISHOP))) self.widgets["bishopDock"].child.show() self.widgets["rookDock"].add(PieceWidget(Piece(WHITE, ROOK))) self.widgets["rookDock"].child.show() self.widgets["queenDock"].add(PieceWidget(Piece(WHITE, QUEEN))) self.widgets["queenDock"].child.show()
def testPolyglot_2(self): """Testing Polyglot book creation""" widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp) self.database_persp = Database() self.database_persp.create_toolbuttons() perspective_manager.add_perspective(self.database_persp) self.database_persp.open_chessfile(PGN) @asyncio.coroutine def coro(): def on_book_created(persp, event): self.assertTrue(os.path.isfile(BIN)) testcase = testcases[0] board = LBoard(Board) board.applyFen(testcase[0]) openings = book.getOpenings(board) self.assertEqual( sorted(openings), sorted([(newMove(E2, E4), 2, 0), (newMove(A2, A4), 0, 0)])) testcase = testcases[-1] board = LBoard(Board) board.applyFen(testcase[0]) openings = book.getOpenings(board) self.assertEqual(openings, []) event.set() event = asyncio.Event() self.database_persp.connect("bookfile_created", on_book_created, event) self.database_persp.create_book(BIN) yield from event.wait() loop = asyncio.get_event_loop() loop.set_debug(enabled=True) loop.run_until_complete(coro())
def setUp(self): widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp) self.learn_persp = Learn() self.learn_persp.create_toolbuttons() perspective_manager.add_perspective(self.learn_persp) perspective_manager.current_perspective = self.learn_persp dd = DiscovererDialog(discoverer) self.dd_task = create_task(dd.start())
def setUp(self): EmittingTestCase.setUp(self) self.manager = self.connection.bm widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp) self.fics_persp = FICS() perspective_manager.add_perspective(self.fics_persp) self.fics_persp.connection = self.connection self.connection.bm.connect("obsGameCreated", self.fics_persp.onObserveGameCreated)
def __init__(self, discoverer): self.discoverer = discoverer self.widgets = uistuff.GladeWidgets("discovererDialog.glade") # ======================================================================= # Clear glade defaults # ======================================================================= for child in self.widgets["enginesTable"].get_children(): self.widgets["enginesTable"].remove(child) self.finished = False self.throbber = None self.nameToBar = {} discoverer.pre_discover() binnames = self.discoverer.toBeRechecked.keys() if len(binnames) == 0: self.finished = True # ====================================================================== # Insert the names to be discovered # ====================================================================== for i, name in enumerate(binnames): label = Gtk.Label(label=name + ":") label.props.xalign = 1 self.widgets["enginesTable"].attach(label, 0, 1, i, i + 1) bar = Gtk.ProgressBar() self.widgets["enginesTable"].attach(bar, 1, 2, i, i + 1) self.nameToBar[name] = bar # ======================================================================= # Add throbber # ======================================================================= self.throbber = Gtk.Spinner() self.throbber.set_size_request(50, 50) self.widgets["throbberDock"].add(self.throbber) # ======================================================================= # Show the window # ======================================================================= self.widgets["discovererDialog"].set_position( Gtk.WindowPosition.CENTER_ON_PARENT) self.widgets["discovererDialog"].set_modal(True) self.widgets["discovererDialog"].show_all() self.throbber.start()
def init (cls, discoverer): assert not hasattr(cls, "widgets"), "Show can only be called once" cls.widgets = uistuff.GladeWidgets("discovererDialog.glade") #======================================================================= # Clear glade defaults #======================================================================= for child in cls.widgets["enginesTable"].get_children(): cls.widgets["enginesTable"].remove(child) #======================================================================= # Connect us to the discoverer #======================================================================= glock_connect(discoverer, "discovering_started", cls._onDiscoveringStarted) glock_connect(discoverer, "engine_discovered", cls._onEngineDiscovered) glock_connect(discoverer, "all_engines_discovered", cls._onAllEnginesDiscovered) cls.finished = False cls.throbber = None
def __init__(self): #GObject.GObject.__init__(self,0,0,0,0) GObject.GObject.__init__(self) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["internetGameTasker"] tasker.unparent() self.add(tasker) def asGuestCallback(check): names = ICLogon.get_user_names() self.widgets["usernameEntry"].set_text( names[1] if check.get_active() else names[0]) self.widgets["passwordLabel"].set_sensitive(not check.get_active()) self.widgets["passwordEntry"].set_sensitive(not check.get_active()) self.widgets["asGuestCheck"].connect("toggled", asGuestCallback) uistuff.keep(self.widgets["asGuestCheck"], "asGuestCheck") as_guest = self.widgets["asGuestCheck"] def user_name_get_value(entry): names = ICLogon.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 = ICLogon.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["usernameEntry"], "usernameEntry", \ user_name_get_value, user_name_set_value) uistuff.keep(self.widgets["passwordEntry"], "passwordEntry") self.widgets["connectButton"].connect("clicked", self.connectClicked) self.widgets["opendialog2"].connect("clicked", self.openDialogClicked) self.widgets["startIcon"].set_from_pixbuf(big_start)
def __init__(self, variant): self.widgets = uistuff.GladeWidgets("promotion.glade") self.dialog = self.widgets["promotionDialog"] self.color = None self.widgets["knightDock"].add( PieceWidget(Piece(WHITE, KNIGHT), variant)) self.widgets["knightDock"].get_child().show() self.widgets["bishopDock"].add( PieceWidget(Piece(WHITE, BISHOP), variant)) self.widgets["bishopDock"].get_child().show() self.widgets["rookDock"].add(PieceWidget(Piece(WHITE, ROOK), variant)) self.widgets["rookDock"].get_child().show() self.widgets["queenDock"].add(PieceWidget(Piece(WHITE, QUEEN), variant)) self.widgets["queenDock"].get_child().show() self.widgets["kingDock"].add(PieceWidget(Piece(WHITE, KING), variant)) self.widgets["kingDock"].get_child().show()
def __init__(self): GObject.GObject.__init__(self) self.widgets = widgets = uistuff.GladeWidgets("taskers.glade") tasker = widgets["newGameTasker"] tasker.unparent() self.add(tasker) startButton = self.widgets["startButton"] startButton.set_name("startButton") combo = Gtk.ComboBox() uistuff.createCombo(combo, [(get_pixbuf("glade/white.png"), _("White")), (get_pixbuf("glade/black.png"), _("Black")), (get_pixbuf("glade/random.png"), _("Random"))]) widgets["colorDock"].add(combo) if combo.get_active() < 0: combo.set_active(0) uistuff.keep(combo, "newgametasker_colorcombo") widgets['yourColorLabel'].set_mnemonic_widget(combo) # We need to wait until after engines have been discovered, to init the # playerCombos. We use connect_after to make sure, that newGameDialog # has also had time to init the constants we share with them. self.playerCombo = Gtk.ComboBox() widgets["opponentDock"].add(self.playerCombo) discoverer.connect_after("all_engines_discovered", self.__initPlayerCombo, widgets) widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo) def on_skill_changed(scale): # Just to make sphinx happy... try: pix = newGameDialog.skillToIconLarge[int(scale.get_value())] widgets["skillImage"].set_from_pixbuf(pix) except TypeError: pass widgets["skillSlider"].connect("value-changed", on_skill_changed) on_skill_changed(widgets["skillSlider"]) widgets["startButton"].connect("clicked", self.startClicked) self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
def __init__ (self): gtk.Alignment.__init__(self,0,0,0,0) self.widgets = uistuff.GladeWidgets("taskers.glade") tasker = self.widgets["internetGameTasker"] tasker.unparent() self.add(tasker) def asGuestCallback (checkbutton): for widget in (self.widgets["usernameLabel"], self.widgets["usernameEntry"], self.widgets["passwordLabel"], self.widgets["passwordEntry"]): widget.set_sensitive(not checkbutton.get_active()) self.widgets["asGuestCheck"].connect("toggled", asGuestCallback) uistuff.keep(self.widgets["asGuestCheck"], "asGuestCheck") uistuff.keep(self.widgets["usernameEntry"], "usernameEntry") uistuff.keep(self.widgets["passwordEntry"], "passwordEntry") self.widgets["connectButton"].connect("clicked", self.connectClicked) self.widgets["opendialog2"].connect("clicked", self.openDialogClicked) self.widgets["startIcon"].set_from_pixbuf(big_start)
def setUp(self): if sys.platform == "win32": from asyncio.windows_events import ProactorEventLoop loop = ProactorEventLoop() asyncio.set_event_loop(loop) else: loop = asyncio.SelectorEventLoop() asyncio.set_event_loop(loop) self.loop = asyncio.get_event_loop() self.loop.set_debug(enabled=True) widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.welcome_persp = Welcome() perspective_manager.add_perspective(self.welcome_persp) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp)
def __init__(self, variant): self.widgets = uistuff.GladeWidgets("gating.glade") self.widgets["gatingDialog"].set_transient_for(mainwindow()) self.dialog = self.widgets["gatingDialog"] self.color = None if self.widgets["hawkDock"].get_child() is None: self.widgets["hawkDock"].add( PieceWidget(Piece(WHITE, HAWK), variant)) self.widgets["hawkDock"].get_child().show() self.widgets["elephantDock"].add( PieceWidget(Piece(WHITE, ELEPHANT), variant)) self.widgets["elephantDock"].get_child().show() self.widgets["hawkAtRookDock"].add( PieceWidget(Piece(WHITE, HAWK), variant)) self.widgets["hawkAtRookDock"].get_child().show() self.widgets["elephantAtRookDock"].add( PieceWidget(Piece(WHITE, ELEPHANT), variant)) self.widgets["elephantAtRookDock"].get_child().show()
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
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
def open_lounge(self, connection, helperconn, host): if self.first_run: self.init_layout() self.connection = connection self.helperconn = helperconn self.host = host self.finger_sent = False self.messages = [] self.players = [] self.game_cids = {} self.widgets = uistuff.GladeWidgets("fics_lounge.glade") self.widgets["fics_lounge"].hide() fics_home = self.widgets["fics_home"] self.widgets["fics_lounge_content_hbox"].remove(fics_home) self.archive_list = self.widgets["archiveListContent"] self.widgets["fics_panels_notebook"].remove(self.archive_list) self.games_list = self.widgets["gamesListContent"] self.widgets["fics_panels_notebook"].remove(self.games_list) self.news_list = self.widgets["news"] self.widgets["fics_home"].remove(self.news_list) self.players_list = self.widgets["playersListContent"] self.widgets["fics_panels_notebook"].remove(self.players_list) self.seek_graph = self.widgets["seekGraphContent"] self.widgets["fics_panels_notebook"].remove(self.seek_graph) self.seek_list = self.widgets["seekListContent"] self.widgets["fics_panels_notebook"].remove(self.seek_list) self.seek_challenge = SeekChallengeSection(self) def on_autoLogout(alm): self.emit("autoLogout") self.close() self.connection.alm.connect("logOut", on_autoLogout) self.connection.connect("disconnected", lambda connection: self.close()) self.connection.connect("error", self.on_connection_error) if self.connection.isRegistred(): numtimes = conf.get("numberOfTimesLoggedInAsRegisteredUser", 0) + 1 conf.set("numberOfTimesLoggedInAsRegisteredUser", numtimes) self.connection.em.connect( "onCommandNotFound", lambda em, cmd: log.error( "Fics answered '%s': Command not found" % cmd)) self.connection.bm.connect("playGameCreated", self.onPlayGameCreated) self.connection.bm.connect("obsGameCreated", self.onObserveGameCreated) self.connection.bm.connect("exGameCreated", self.onObserveGameCreated) self.connection.fm.connect("fingeringFinished", self.onFinger) # the rest of these relay server messages to the lounge infobar self.connection.bm.connect("tooManySeeks", self.tooManySeeks) self.connection.bm.connect("nonoWhileExamine", self.nonoWhileExamine) self.connection.bm.connect("matchDeclined", self.matchDeclined) self.connection.bm.connect("player_on_censor", self.player_on_censor) self.connection.bm.connect("player_on_noplay", self.player_on_noplay) self.connection.bm.connect("req_not_fit_formula", self.req_not_fit_formula) self.connection.glm.connect("seek-updated", self.on_seek_updated) self.connection.glm.connect("our-seeks-removed", self.our_seeks_removed) self.connection.cm.connect("arrivalNotification", self.onArrivalNotification) self.connection.cm.connect("departedNotification", self.onDepartedNotification) def get_top_games(): if perspective_manager.current_perspective == self: self.connection.client.run_command("games *19") return True if self.connection.ICC: self.event_id = GLib.timeout_add_seconds(5, get_top_games) for user in self.connection.notify_users: user = self.connection.players.get(user) self.user_from_notify_list_is_present(user) self.userinfo = UserInfoSection(self.widgets, self.connection, self.host, self) if not self.first_run: self.notebooks["ficshome"].remove_page(-1) self.notebooks["ficshome"].append_page(fics_home) self.panels = [ panel.Sidepanel().load(self.widgets, self.connection, self) for panel in self.sidePanels ] for panel, instance in zip(self.sidePanels, self.panels): if not self.first_run: self.notebooks[panel.__name__].remove_page(-1) self.notebooks[panel.__name__].append_page(instance) instance.show() tool_buttons = [ self.logoff_button, ] self.quick_seek_buttons = [] if self.connection.ICC: self.quick_seek_buttons = [ self.minute_1_button, self.minute_3_button, self.minute_5_button, self.minute_15_button, self.minute_25_button, self.chess960_button ] tool_buttons += self.quick_seek_buttons perspective_manager.set_perspective_toolbuttons("fics", tool_buttons) if self.first_run: self.first_run = False # After all panel is set up we can push initial messages out self.connection.com.onConsoleMessage("", self.connection.ini_messages)
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-2020") self.aboutdialog.set_version(VERSION_NAME + " " + VERSION) if isgit(): try: self.git_rev = subprocess.check_output( ["git", "describe", "--tags"]).decode().strip() self.aboutdialog.set_version('%s Git %s' % (VERSION_NAME, self.git_rev)) except subprocess.CalledProcessError: pass self.aboutdialog.set_comments(self.aboutdialog.get_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)
def _init(cls): cls.white = get_pixbuf("glade/white.png") cls.black = get_pixbuf("glade/black.png") cls.widgets = uistuff.GladeWidgets("newInOut.glade") cls.widgets["newgamedialog"].set_transient_for(mainwindow()) def on_exchange_players(widget, button_event): white = cls.widgets["whitePlayerCombobox"].get_active() black = cls.widgets["blackPlayerCombobox"].get_active() whiteLevel = cls.widgets["skillSlider1"].get_value() blackLevel = cls.widgets["skillSlider2"].get_value() cls.widgets["whitePlayerCombobox"].set_active(black) cls.widgets["blackPlayerCombobox"].set_active(white) cls.widgets["skillSlider1"].set_value(blackLevel) cls.widgets["skillSlider2"].set_value(whiteLevel) cls.widgets["whitePlayerButton"].set_image( Gtk.Image.new_from_pixbuf(cls.white)) cls.widgets["whitePlayerButton"].connect("button-press-event", on_exchange_players) cls.widgets["blackPlayerButton"].set_image( Gtk.Image.new_from_pixbuf(cls.black)) cls.widgets["blackPlayerButton"].connect("button-press-event", on_exchange_players) uistuff.createCombo(cls.widgets["whitePlayerCombobox"], name="whitePlayerCombobox") uistuff.createCombo(cls.widgets["blackPlayerCombobox"], name="blackPlayerCombobox") cls.widgets["playersIcon"].set_from_pixbuf(big_people) cls.widgets["timeIcon"].set_from_pixbuf(big_time) def on_playerCombobox_changed(widget, skill_hbox): skill_hbox.props.visible = widget.get_active() > 0 cls.widgets["whitePlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox1"]) cls.widgets["blackPlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox2"]) cls.widgets["whitePlayerCombobox"].set_active(0) cls.widgets["blackPlayerCombobox"].set_active(1) def on_skill_changed(scale, image): image.set_from_pixbuf(skillToIcon[int(scale.get_value())]) cls.widgets["skillSlider1"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon1"]) cls.widgets["skillSlider2"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon2"]) cls.widgets["skillSlider1"].set_value(3) cls.widgets["skillSlider2"].set_value(3) cls.__initTimeRadio(_("Blitz"), "ngblitz", cls.widgets["blitzRadio"], cls.widgets["configImageBlitz"], 5, 0, 0) cls.__initTimeRadio(_("Rapid"), "ngrapid", cls.widgets["rapidRadio"], cls.widgets["configImageRapid"], 15, 5, 0) cls.__initTimeRadio(_("Normal"), "ngnormal", cls.widgets["normalRadio"], cls.widgets["configImageNormal"], 40, 15, 0) cls.__initTimeRadio(_("Classical"), "ngclassical", cls.widgets["classicalRadio"], cls.widgets["configImageClassical"], 3, 0, 40) cls.__initVariantRadio("ngvariant1", cls.widgets["playVariant1Radio"], cls.widgets["configImageVariant1"], FISCHERRANDOMCHESS) cls.__initVariantRadio("ngvariant2", cls.widgets["playVariant2Radio"], cls.widgets["configImageVariant2"], LOSERSCHESS) 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__) data = [(item[0], item[1]) for item in playerItems[variant]] uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data) uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data) discoverer.connect_after("all_engines_discovered", updateCombos) updateCombos(discoverer) conf.notify_add("ngvariant1", updateCombos) conf.notify_add("ngvariant2", updateCombos) cls.widgets["playNormalRadio"].connect("toggled", updateCombos) cls.widgets["playNormalRadio"].set_tooltip_text( variants[NORMALCHESS].__desc__) cls.widgets["playVariant1Radio"].connect("toggled", updateCombos) variant1 = conf.get("ngvariant1", FISCHERRANDOMCHESS) cls.widgets["playVariant1Radio"].set_tooltip_text( variants[variant1].__desc__) cls.widgets["playVariant2Radio"].connect("toggled", updateCombos) variant2 = conf.get("ngvariant2", LOSERSCHESS) cls.widgets["playVariant2Radio"].set_tooltip_text( variants[variant2].__desc__) # The "variant" has to come before players, because the engine positions # in the user comboboxes can be different in different variants for key in ("whitePlayerCombobox", "blackPlayerCombobox", "skillSlider1", "skillSlider2", "notimeRadio", "blitzRadio", "rapidRadio", "normalRadio", "classicalRadio", "playNormalRadio", "playVariant1Radio", "playVariant2Radio"): uistuff.keep(cls.widgets[key], key) # We don't want the dialog to deallocate when closed. Rather we hide # it on respond cls.widgets["newgamedialog"].connect("delete_event", lambda *a: True)