def database(self, accion, dbpath, is_temporary=False): if accion == "M": if Code.is_windows: os.startfile(self.configuration.folder_databases()) return if accion == "N": dbpath = WDB_Games.new_database(self.main_window, self.configuration) if dbpath is None: return accion = "R" if accion == "D": resp = QTVarios.select_db(self.main_window, self.configuration, True, False) if resp: if QTUtil2.pregunta(self.main_window, "%s\n%s" % (_("Do you want to remove?"), resp)): Util.remove_file(resp) Util.remove_file(resp + ".st1") return if accion == "R": self.configuration.set_last_database(Util.relative_path(dbpath)) w = WindowDatabase.WBDatabase(self.main_window, self, dbpath, is_temporary, False) if self.main_window: if w.exec_(): if w.reiniciar: self.database("R", self.configuration.get_last_database()) else: Delegados.generaPM(w.infoMove.board.piezas) w.show()
def __init__(self, wparent, game): self.game = game self.wparent = wparent self.configuration = configuration = Code.configuration QtWidgets.QWidget.__init__(self, wparent) li_acciones = ( (_("Save"), Iconos.Grabar(), self.save), None, (_("Cancel"), Iconos.Cancelar(), self.wparent.cancelar), None, (_("Start position"), Iconos.Datos(), self.inicial), None, (_("Clear"), Iconos.Borrar(), self.limpia), None, (_("Take back"), Iconos.Atras(), self.atras), None, ) self.tb = Controles.TBrutina(self, li_acciones, with_text=False, icon_size=20) config_board = configuration.config_board("VOYAGERPGN", 24) self.board = Board.Board(self, config_board) self.board.crea() self.board.set_dispatcher(self.player_has_moved) Delegados.generaPM(self.board.piezas) o_columns = Columnas.ListaColumnas() o_columns.nueva("NUMBER", _("N."), 35, centered=True) self.si_figurines_pgn = configuration.x_pgn_withfigurines nAnchoColor = (self.board.ancho - 35 - 20) // 2 o_columns.nueva("WHITE", _("White"), nAnchoColor, edicion=Delegados.EtiquetaPGN( True if self.si_figurines_pgn else None)) o_columns.nueva("BLACK", _("Black"), nAnchoColor, edicion=Delegados.EtiquetaPGN( False if self.si_figurines_pgn else None)) self.pgn = Grid.Grid(self, o_columns, siCabeceraMovible=False, siSelecFilas=True) self.pgn.setMinimumWidth(self.board.ancho) ly = Colocacion.V().control(self.tb).control(self.board) ly.control(self.pgn) ly.margen(1) self.setLayout(ly) self.board.set_position(self.game.last_position) self.play_next_move()
def __init__(self, wparent, partida): self.partida = partida self.wparent = wparent self.configuracion = configuracion = VarGen.configuracion QtGui.QWidget.__init__(self, wparent) liAcciones = ( (_("Save"), Iconos.Grabar(), self.save), None, (_("Cancel"), Iconos.Cancelar(), self.wparent.cancelar), None, (_("Start position"), Iconos.Datos(), self.inicial), None, (_("Clear"), Iconos.Borrar(), self.limpia), None, (_("Take back"), Iconos.Atras(), self.atras), None, ) self.tb = Controles.TBrutina(self, liAcciones, siTexto=False, tamIcon=20) confTablero = configuracion.confTablero("VOYAGERPGN", 24) self.tablero = Tablero.Tablero(self, confTablero) self.tablero.crea() self.tablero.ponMensajero(self.mueveHumano) Delegados.generaPM(self.tablero.piezas) oColumnas = Columnas.ListaColumnas() oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True) self.siFigurinesPGN = configuracion.figurinesPGN nAnchoColor = (self.tablero.ancho - 35 - 20) / 2 oColumnas.nueva("BLANCAS", _("White"), nAnchoColor, edicion=Delegados.EtiquetaPGN( True if self.siFigurinesPGN else None)) oColumnas.nueva("NEGRAS", _("Black"), nAnchoColor, edicion=Delegados.EtiquetaPGN( False if self.siFigurinesPGN else None)) self.pgn = Grid.Grid(self, oColumnas, siCabeceraMovible=False, siSelecFilas=True) self.pgn.setMinimumWidth(self.tablero.ancho) ly = Colocacion.V().control(self.tb).control(self.tablero) ly.control(self.pgn) ly.margen(1) self.setLayout(ly) self.tablero.ponPosicion(self.partida.ultPosicion) self.siguienteJugada()
def create_board(self): ae = QTUtil.altoEscritorio() mx = int(ae * 0.08) config_board = self.manager.configuration.config_board("BASE", mx) self.board = Board.Board(self, config_board) self.board.crea() self.board.setFocus() Delegados.generaPM(self.board.piezas)
def creaTablero(self): ae = QTUtil.altoEscritorio() mx = 64 if ae >= 750 else 48 confTablero = self.gestor.configuracion.confTablero("BASE", mx) self.tablero = Tablero.Tablero(self, confTablero) self.tablero.crea() self.tablero.setFocus() Delegados.generaPM(self.tablero.piezas)
def __init__(self, wparent, cpu): self.cpu = cpu self.partida = self.cpu.partida self.wparent = wparent self.configuracion = configuracion = cpu.configuracion QtGui.QWidget.__init__(self, wparent) liAcciones = ( ( _("Save"), Iconos.Grabar(), self.save ), None, ( _("Start position"), Iconos.Datos(), self.inicial ), None, ( _("Clear"), Iconos.Borrar(), self.limpia ), None, ( _("Take back"), Iconos.Atras(), self.atras ), None, ( _("Active voice"), Iconos.S_Microfono(), self.wparent.voice_active ), ( _("Deactive voice"), Iconos.X_Microfono(), self.wparent.voice_deactive ), ) self.tb = Controles.TBrutina(self, liAcciones, siTexto=False, tamIcon=20) confTablero = configuracion.confTablero("VOYAGERPGN", 24) self.tablero = Tablero.Tablero(self, confTablero) self.tablero.crea() self.tablero.ponMensajero(self.mueveHumano) Delegados.generaPM(self.tablero.piezas) oColumnas = Columnas.ListaColumnas() oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True) self.siFigurinesPGN = configuracion.figurinesPGN nAnchoColor = (self.tablero.ancho - 35 - 20) / 2 oColumnas.nueva("BLANCAS", _("White"), nAnchoColor, edicion=Delegados.EtiquetaPGN(True if self.siFigurinesPGN else None)) oColumnas.nueva("NEGRAS", _("Black"), nAnchoColor, edicion=Delegados.EtiquetaPGN(False if self.siFigurinesPGN else None)) self.pgn = Grid.Grid(self, oColumnas, siCabeceraMovible=False,siSelecFilas=True) self.pgn.setMinimumWidth(self.tablero.ancho) ly = Colocacion.V().control(self.tb).control(self.tablero) ly.control(self.pgn) ly.margen(1) self.setLayout(ly) self.liVoice = [] self.tablero.ponPosicion(self.partida.ultPosicion) self.siguienteJugada()
def __init__(self, file_tournament, file_work): QtWidgets.QWidget.__init__(self) Code.list_engine_managers = EngineManager.ListEngineManagers() self.torneo = TournamentRun( file_tournament) # Tournament.Tournament(file_tournament) self.file_work = file_work self.db_work = UtilSQL.ListSQL(file_work) self.slow_pieces = self.torneo.slow_pieces() self.setWindowTitle( "%s - %s %d" % (self.torneo.name(), _("Worker"), int(file_work[-5:]))) self.setWindowIcon(Iconos.Torneos()) # Toolbar self.tb = Controles.TBrutina(self, icon_size=24) # Board conf_board = Code.configuration.config_board("TOURNEYPLAY", 36) self.board = Board.Board(self, conf_board) self.board.crea() Delegados.generaPM(self.board.piezas) # PGN self.configuration = Code.configuration self.game = Game.Game() self.pgn = ControlPGN.ControlPGN(self) ly_pgn = self.crea_bloque_informacion() self.is_closed = False self.state = None self.current_side = WHITE ly_tt = Colocacion.V().control(self.tb).control(self.board) layout = Colocacion.H().otro(ly_tt).otro(ly_pgn).relleno().margen(3) self.setLayout(layout) self.cpu = CPU.CPU(self) self.pon_estado(ST_WAITING)
def __init__(self, cpu, icon): QtWidgets.QDialog.__init__(self) self.setWindowTitle(cpu.titulo) self.setWindowIcon(icon) self.cpu = cpu self.siPlay = True self.kibitzer = cpu.kibitzer self.type = cpu.tipo self.dicVideo = self.cpu.dic_video if not self.dicVideo: self.dicVideo = {} self.game = None self.li_moves = [] self.is_black = True self.is_white = True self.siTop = self.dicVideo.get("SITOP", True) self.show_board = self.dicVideo.get("SHOW_BOARD", True) self.nArrows = self.dicVideo.get( "NARROWS", 1 if cpu.tipo == Kibitzers.KIB_THREATS else 2) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuration = cpu.configuration Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuration.config_board( "kib" + cpu.kibitzer.huella, 24) self.board = Board.Board(self, config_board) self.board.crea() self.board.set_dispatcher(self.mensajero) Delegados.generaPM(self.board.piezas) if not self.show_board: self.board.hide() self.with_figurines = cpu.configuration.x_pgn_withfigurines
def __init__(self, cpu): QtWidgets.QDialog.__init__(self) self.cpu = cpu dicVideo = self.cpu.dic_video if not dicVideo: dicVideo = {} self.siTop = dicVideo.get("SITOP", True) self.show_board = dicVideo.get("SHOW_BOARD", True) self.position = Position.Position() self.game = None self.siPlay = True self.li_moves = [] self.history = [] self.setWindowTitle(cpu.titulo) self.setWindowIcon(Iconos.Book()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuration = cpu.configuration Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuration.config_board( "kib" + cpu.kibitzer.huella, 24) self.board = Board.Board(self, config_board) self.board.crea() self.board.set_dispatcher(self.mensajero) Delegados.generaPM(self.board.piezas) self.book = Books.Book("P", cpu.kibitzer.name, cpu.kibitzer.path_exe, True) self.book.polyglot() self.with_figurines = cpu.configuration.x_pgn_withfigurines o_columns = Columnas.ListaColumnas() delegado = Delegados.EtiquetaPOS( True, siLineas=False) if self.with_figurines else None o_columns.nueva("MOVE", _("Move"), 80, centered=True, edicion=delegado) o_columns.nueva("PORC", "%", 60, centered=True) o_columns.nueva("WEIGHT", _("Weight"), 80, siDerecha=True) self.grid_moves = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True) li_acciones = ( (_("Quit"), Iconos.Kibitzer_Close(), self.terminar), (_("Continue"), Iconos.Kibitzer_Play(), self.play), (_("Pause"), Iconos.Kibitzer_Pause(), self.pause), (_("Takeback"), Iconos.pmKibitzer_Back(), self.takeback), (_("Manual position"), Iconos.Kibitzer_Voyager(), self.set_position), (_("Show/hide board"), Iconos.Kibitzer_Board(), self.config_board), ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop), ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom), ) self.tb = Controles.TBrutina(self, li_acciones, with_text=False, icon_size=24) self.tb.setAccionVisible(self.play, False) ly1 = Colocacion.H().control(self.board).control(self.grid_moves) layout = Colocacion.V().control( self.tb).espacio(-8).otro(ly1).margen(3) self.setLayout(layout) self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.cpu.compruebaInput) self.timer.start(500) if not self.show_board: self.board.hide() self.restore_video(dicVideo) self.ponFlags()
def __init__(self, cpu): QtWidgets.QDialog.__init__(self) self.cpu = cpu dicVideo = self.cpu.dic_video if not dicVideo: dicVideo = {} self.siTop = dicVideo.get("SITOP", True) self.siShowTablero = dicVideo.get("SHOW_TABLERO", True) self.position = Position.Position() self.fen = "" self.almFEN = {} self.siPlay = True self.is_white = True self.siNegras = True self.setWindowTitle(cpu.titulo) self.setWindowIcon(Iconos.Book()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuracion = cpu.configuracion Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuracion.config_board( "kib" + cpu.kibitzer.huella, 24) self.tablero = Tablero.Tablero(self, config_board) self.tablero.crea() Delegados.generaPM(self.tablero.piezas) self.em = Controles.EM(self, siHTML=False).soloLectura() f = Controles.TipoLetra(name="Courier New", puntos=10) self.em.ponFuente(f) li_acciones = ( (_("Quit"), Iconos.Kibitzer_Terminar(), self.terminar), (_("Continue"), Iconos.Kibitzer_Continuar(), self.play), (_("Pause"), Iconos.Kibitzer_Pausa(), self.pause), (_("Board"), Iconos.Tablero(), self.config_board), ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop), ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom), ) self.tb = Controles.TBrutina(self, li_acciones, siTexto=False, tamIcon=16) self.tb.setAccionVisible(self.play, False) ly1 = Colocacion.H().control(self.tb) ly2 = Colocacion.V().otro(ly1).control(self.em) layout = Colocacion.H().control(self.tablero).otro(ly2) self.setLayout(layout) self.engine = self.lanzaMotor() self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.cpu.compruebaInput) self.timer.start(200) if not self.siShowTablero: self.tablero.hide() self.restore_video(dicVideo) self.ponFlags()
def __init__(self, cpu): QtWidgets.QDialog.__init__(self) self.cpu = cpu self.kibitzer = cpu.kibitzer dicVideo = self.cpu.dic_video if not dicVideo: dicVideo = {} self.siTop = dicVideo.get("SITOP", True) self.show_board = dicVideo.get("SHOW_BOARD", True) self.position = Position.Position() self.game = None self.siPlay = True self.is_white = True self.is_black = True self.setWindowTitle(cpu.titulo) self.setWindowIcon(Iconos.Book()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuration = cpu.configuration Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuration.config_board( "kib" + cpu.kibitzer.huella, 24) self.board = Board.Board(self, config_board) self.board.crea() Delegados.generaPM(self.board.piezas) self.em = Controles.EM(self, siHTML=False).read_only() f = Controles.TipoLetra(name="Courier New", puntos=10) self.em.ponFuente(f) li_acciones = ( (_("Quit"), Iconos.Kibitzer_Close(), self.terminar), (_("Continue"), Iconos.Kibitzer_Play(), self.play), (_("Pause"), Iconos.Kibitzer_Pause(), self.pause), (_("Show/hide board"), Iconos.Kibitzer_Board(), self.config_board), ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop), ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom), ) self.tb = Controles.TBrutina(self, li_acciones, with_text=False, icon_size=24) self.tb.setAccionVisible(self.play, False) ly1 = Colocacion.H().control(self.board).control(self.em).margen(3) layout = Colocacion.V().control( self.tb).espacio(-10).otro(ly1).margen(3) self.setLayout(layout) self.engine = self.lanzaMotor() self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.cpu.compruebaInput) self.timer.start(200) if not self.show_board: self.board.hide() self.restore_video(dicVideo) self.ponFlags()
def __init__(self, cpu): QtWidgets.QDialog.__init__(self) self.cpu = cpu self.kibitzer = cpu.kibitzer self.siCandidates = cpu.tipo == Kibitzers.KIB_CANDIDATES self.siThreats = cpu.tipo == Kibitzers.KIB_THREATS dicVideo = self.cpu.dic_video if not dicVideo: dicVideo = {} self.siTop = dicVideo.get("SITOP", True) self.siShowTablero = dicVideo.get("SHOW_TABLERO", True) self.nArrows = dicVideo.get("NARROWS", 2) self.fen = "" self.liData = [] self.history = [] self.setWindowTitle(cpu.titulo) self.setWindowIcon(Iconos.Motor()) self.setWindowFlags( QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint ) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuracion = cpu.configuracion Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuracion.config_board("kib" + cpu.kibitzer.huella, 24) self.tablero = Tablero.Tablero(self, config_board) self.tablero.crea() self.tablero.set_dispatcher(self.mensajero) self.siFigurines = cpu.configuracion.x_pgn_withfigurines Delegados.generaPM(self.tablero.piezas) delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.siFigurines else None o_columns = Columnas.ListaColumnas() if not self.siCandidates: o_columns.nueva("DEPTH", "^", 40, centered=True) o_columns.nueva("BESTMOVE", _("Alternatives"), 80, centered=True, edicion=delegado) o_columns.nueva("EVALUATION", _("Evaluation"), 85, centered=True) o_columns.nueva("MAINLINE", _("Main line"), 400) self.grid = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True) self.lbDepth = Controles.LB(self) li_acciones = ( (_("Quit"), Iconos.Kibitzer_Terminar(), self.terminar), (_("Continue"), Iconos.Kibitzer_Continuar(), self.play), (_("Pause"), Iconos.Kibitzer_Pausa(), self.pause), (_("Takeback"), Iconos.Atras(), self.takeback), (_("The line selected is saved on clipboard"), Iconos.MoverGrabar(), self.portapapelesJugSelected), (_("Analyze only color"), Iconos.P_16c(), self.color), (_("Show/hide board"), Iconos.Tablero(), self.config_board), (_("Manual position"), Iconos.Voyager(), self.set_position), ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop), ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom), (_("Options"), Iconos.Opciones(), self.change_options), ) self.tb = Controles.TBrutina(self, li_acciones, siTexto=False, tamIcon=16) self.tb.setAccionVisible(self.play, False) ly1 = Colocacion.H().control(self.tb).relleno().control(self.lbDepth) ly2 = Colocacion.V().otro(ly1).control(self.grid) layout = Colocacion.H().control(self.tablero).otro(ly2) self.setLayout(layout) self.siPlay = True self.is_white = True self.siNegras = True if not self.siShowTablero: self.tablero.hide() self.restore_video(dicVideo) self.ponFlags() self.engine = self.lanzaMotor() self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.compruebaInput) self.timer.start(500) self.depth = 0 self.veces = 0
def __init__(self, cpu): QtWidgets.QDialog.__init__(self) self.cpu = cpu dicVideo = self.cpu.dic_video if not dicVideo: dicVideo = {} self.siTop = dicVideo.get("SITOP", True) self.siShowTablero = dicVideo.get("SHOW_TABLERO", True) self.position = Position.Position() self.fen = "" self.siPlay = True self.li_moves = [] self.history = [] self.setWindowTitle(cpu.titulo) self.setWindowIcon(Iconos.Finales()) self.setWindowFlags( QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint ) self.setBackgroundRole(QtGui.QPalette.Light) Code.configuracion = cpu.configuracion Code.todasPiezas = Piezas.TodasPiezas() config_board = cpu.configuracion.config_board("kib" + cpu.kibitzer.huella, 24) self.tablero = Tablero.Tablero(self, config_board) self.tablero.crea() self.tablero.set_dispatcher(self.mensajero) Delegados.generaPM(self.tablero.piezas) self.t4 = LibChess.T4(cpu.configuracion) self.siFigurines = cpu.configuracion.x_pgn_withfigurines o_columns = Columnas.ListaColumnas() delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.siFigurines else None o_columns.nueva("MOVE", _("Move"), 80, centered=True, edicion=delegado) o_columns.nueva("DTM", "DTM", 60, centered=True) self.grid_moves = Grid.Grid(self, o_columns, dicVideo=dicVideo, siSelecFilas=True) li_acciones = ( (_("Quit"), Iconos.Kibitzer_Terminar(), self.terminar), (_("Continue"), Iconos.Kibitzer_Continuar(), self.play), (_("Pause"), Iconos.Kibitzer_Pausa(), self.pause), (_("Takeback"), Iconos.Atras(), self.takeback), (_("Manual position"), Iconos.Voyager(), self.set_position), (_("Show/hide board"), Iconos.Tablero(), self.config_board), ("%s: %s" % (_("Enable"), _("window on top")), Iconos.Top(), self.windowTop), ("%s: %s" % (_("Disable"), _("window on top")), Iconos.Bottom(), self.windowBottom), ) self.tb = Controles.TBrutina(self, li_acciones, siTexto=False, tamIcon=16) self.tb.setAccionVisible(self.play, False) ly1 = Colocacion.H().control(self.tb) ly2 = Colocacion.V().otro(ly1).control(self.grid_moves) layout = Colocacion.H().control(self.tablero).otro(ly2) self.setLayout(layout) self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.cpu.compruebaInput) self.timer.start(200) if not self.siShowTablero: self.tablero.hide() self.restore_video(dicVideo) self.ponFlags()