def __init__(self, wParent, configuracion, fen): QtGui.QDialog.__init__(self, wParent) self.wParent = wParent self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = configuracion self.setWindowTitle(_("Position")) self.setWindowIcon(Iconos.Datos()) # Quien mueve self.rbBlancas = Controles.RB(self, _("White")) self.rbNegras = Controles.RB(self, _("Black")) # Enroques permitidos self.cbBoo = Controles.CHB(self, _("White") + " O-O", True) self.cbBooo = Controles.CHB(self, _("White") + " O-O-O", True) self.cbNoo = Controles.CHB(self, _("Black") + " O-O", True) self.cbNooo = Controles.CHB(self, _("Black") + " O-O-O", True) # Peon al paso lbAlPaso = Controles.LB(self, _("En passant") + ":") self.edAlPaso = Controles.ED(self).controlrx( "(-|[a-h][36])").anchoFijo(30) # Medias jugadas desde ultimo mov. peon self.edMedias, lbMedias = QTUtil2.spinBoxLB( self, 0, 0, 999, etiqueta=_("Moves since the last pawn advance or capture"), maxTam=50) # Jugadas self.edJugadas, lbJugadas = QTUtil2.spinBoxLB(self, 1, 1, 999, etiqueta=_("Moves"), maxTam=50) # Botones adicionales btPosInicial = Controles.PB(self, _("Start position"), self.posInicial, plano=False) btLimpiaTablero = Controles.PB(self, _("Clear board"), self.limpiaTablero, plano=False) btPegar = Controles.PB(self, _("Paste FEN position"), self.pegarPosicion, plano=False) btCopiar = Controles.PB(self, _("Copy FEN position"), self.copiarPosicion, plano=False) btVoyager = Controles.PB(self, "", self.lanzaVoyager, plano=False).ponIcono(Iconos.Voyager()) self.btVoice = Controles.PB(self, "", self.voiceActive, plano=False).ponIcono(Iconos.S_Microfono()) self.btVoiceX = Controles.PB(self, "", self.voiceDeactive, plano=False).ponIcono( Iconos.X_Microfono()) # Tablero confTablero = configuracion.confTablero("POSICION", 24) self.posicion = ControlPosicion.ControlPosicion() if fen: self.posicion.leeFen(fen) else: self.posicion.posInicial() self.tablero = Tablero.PosTablero(self, confTablero) self.tablero.crea() self.tablero.ponMensajero(self.mueve) self.tablero.mensBorrar = self.borraCasilla self.tablero.mensCrear = self.creaCasilla self.tablero.mensRepetir = self.repitePieza self.ultimaPieza = "P" self.piezas = self.tablero.piezas self.resetPosicion() # Piezas drag-drop self.dragDropWI = QTVarios.ListaPiezas(self, "P;N;B;R;Q;K", self.tablero) self.dragDropWB = QTVarios.ListaPiezas(self, "P,N,B,R,Q,K", self.tablero) self.dragDropBD = QTVarios.ListaPiezas(self, "k;q;r;b;n;p", self.tablero) self.dragDropBA = QTVarios.ListaPiezas(self, "k,q,r,b,n,p", self.tablero) self.tablero.ponDispatchDrop(self.dispatchDrop) self.tablero.baseCasillasSC.setAcceptDrops(True) # Ayuda lbAyuda = Controles.LB( self, _("<ul><li><b>Add piece</b> : Right mouse button on empty square</li><li><b>Copy piece</b> : Left mouse button on empty square</li><li><b>Move piece</b> : Drag and drop piece with left mouse button</li><li><b>Delete piece</b> : Right mouse button on occupied square</li></ul>" )) # Tool bar tb = QTUtil2.tbAcceptCancel(self, siReject=False) # Layout # # Quien mueve hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(30).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Next move"), hbox) # # Enroques ly = Colocacion.G().control(self.cbBoo, 0, 0).control(self.cbNoo, 0, 1) ly.control(self.cbBooo, 1, 0).control(self.cbNooo, 1, 1) gbEnroques = Controles.GB(self, _("Castling moves possible"), ly) ## Otros ly = Colocacion.G() ly.controld(lbMedias, 0, 0, 1, 3).control(self.edMedias, 0, 3) ly.controld(lbAlPaso, 1, 0).control(self.edAlPaso, 1, 1) ly.controld(lbJugadas, 1, 2).control(self.edJugadas, 1, 3) gbOtros = Controles.GB(self, "", ly) ## Botones adicionales lyBA = Colocacion.H().control(btPosInicial).control( btLimpiaTablero).control(btPegar).control(btCopiar).control( btVoyager) ## Ayuda ly = Colocacion.H().control(lbAyuda) gbAyuda = Controles.GB(self, _("Help"), ly) ## Izquierda ly = Colocacion.V().control(gbColor).relleno().control( gbEnroques).relleno() ly.control(gbOtros).relleno().control(gbAyuda).margen(5) lyI = Colocacion.V().control(tb).otro(ly).margen(3) ## Derecha lyBT = Colocacion.H().control(self.btVoice).control(self.btVoiceX) lyDA = Colocacion.G() lyDA.controlc(self.dragDropBA, 0, 1).otro(lyBT, 0, 2) lyDA.controld(self.dragDropWI, 1, 0).control(self.tablero, 1, 1).control(self.dragDropBD, 1, 2) lyDA.controlc(self.dragDropWB, 2, 1) lyD = Colocacion.V().otro(lyDA).otro(lyBA).relleno() ## Completo ly = Colocacion.H().otro(lyI).otro(lyD).margen(3) self.setLayout(ly) if configuracion.siDGT: if not DGT.activarSegunON_OFF(self.dgt): # Error QTUtil2.mensError( self, _("Error, could not detect the DGT board driver.")) self.ponCursor() self.voyager = None self.bufferVoice = "" self.queueVoice = [] self.isVoiceActive = False if not configuracion.voice: self.btVoiceX.setVisible(False) self.btVoice.setVisible(False) else: if Voice.runVoice.isActive(): self.voiceActive() else: self.voiceDeactive()
def __init__(self, procesador): self.configuracion = procesador.configuracion self.procesador = procesador self.dbHisto = Util.DicSQL(self.configuracion.ficheroGMhisto) self.bloqueApertura = None self.liAperturasFavoritas = [] wParent = procesador.pantalla titulo = _("Play like a grandmaster") icono = Iconos.GranMaestro() extparam = "gm" QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam) flb = Controles.TipoLetra(puntos=10) # Toolbar liAcciones = [(_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("One game"), Iconos.Uno(), self.unJuego), None, (_("Import"), Iconos.ImportarGM(), self.importar)] tb = Controles.TBrutina(self, liAcciones) # Grandes maestros self.liGM = GM.listaGM() li = [(x[0], x[1]) for x in self.liGM] li.insert(0, ("-", None)) self.cbGM = QTUtil2.comboBoxLB( self, li, li[0][1] if len(self.liGM) == 0 else li[1][1]) self.cbGM.capturaCambiado(self.compruebaGM) hbox = Colocacion.H().relleno().control(self.cbGM).relleno() gbGM = Controles.GB(self, _("Choose a grandmaster"), hbox).ponFuente(flb) # Personales self.liPersonal = GM.listaGMpersonal( self.procesador.configuracion.dirPersonalTraining) if self.liPersonal: li = [(x[0], x[1]) for x in self.liPersonal] li.insert(0, ("-", None)) self.cbPersonal = QTUtil2.comboBoxLB(self, li, li[0][1]) self.cbPersonal.capturaCambiado(self.compruebaP) btBorrar = Controles.PB(self, "", self.borrarPersonal, plano=False).ponIcono(Iconos.Borrar(), tamIcon=16) hbox = Colocacion.H().relleno().control( self.cbPersonal).control(btBorrar).relleno() gbPersonal = Controles.GB(self, _("Personal games"), hbox).ponFuente(flb) # Color self.rbBlancas = Controles.RB(self, _("White"), rutina=self.compruebaColor) self.rbBlancas.activa(True) self.rbNegras = Controles.RB(self, _("Black"), rutina=self.compruebaColor) self.rbNegras.activa(False) # Contrario self.chContrario = Controles.CHB( self, _("Choose the opponent's move, when there are multiple possible answers" ), False) # Juez liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) self.liMotores = self.configuracion.comboMotoresMultiPV10() self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB( self, self.liMotores, self.configuracion.tutorInicial, _("Engine")) self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat( 1.0).anchoFijo(50) self.lbJtiempo = Controles.LB2P(self, _("Time in seconds")) self.cbJdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth) self.lbJdepth = Controles.LB2P(self, _("Depth")) self.lbJshow = Controles.LB2P(self, _("Show rating")) self.chbEvals = Controles.CHB(self, _("Show all evaluations"), False) liOptions = [(_("All moves"), None), (_("Moves are different"), True), (_("Never"), False)] self.cbJshow = Controles.CB(self, liOptions, True) self.lbJmultiPV = Controles.LB2P( self, _("Number of moves evaluated by engine(MultiPV)")) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) self.cbJmultiPV = Controles.CB(self, li, "PD") # Inicial self.edJugInicial, lbInicial = QTUtil2.spinBoxLB( self, 1, 1, 99, etiqueta=_("Initial move"), maxTam=40) # Libros fvar = self.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.recuperaVar(fvar) # # Comprobamos que todos esten accesibles self.listaLibros.comprueba() li = [(x.nombre, x) for x in self.listaLibros.lista] li.insert(0, ("--", None)) self.cbBooks, lbBooks = QTUtil2.comboBoxLB( self, li, None, _("Bypass moves in the book")) # Aperturas self.btApertura = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.aperturasEditar).ponPlano(False) self.btAperturasFavoritas = Controles.PB( self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos()) self.btAperturasQuitar = Controles.PB( self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No()) hbox = Colocacion.H().control(self.btAperturasQuitar).control( self.btApertura).control(self.btAperturasFavoritas).relleno() gbOpening = Controles.GB(self, _("Opening"), hbox) # gbBasic # # Color hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(10).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(flb) # Tiempo ly1 = Colocacion.H().control(self.lbJmotor).control( self.cbJmotor).control(self.lbJshow).control( self.cbJshow).relleno() ly2 = Colocacion.H().control(self.lbJtiempo).control(self.edJtiempo) ly2.control(self.lbJdepth).control(self.cbJdepth).espacio(15).control( self.chbEvals).relleno() ly3 = Colocacion.H().control(self.lbJmultiPV).control( self.cbJmultiPV).relleno() ly = Colocacion.V().otro(ly1).otro(ly2).otro(ly3) self.gbJ = Controles.GB(self, _("Adjudicator"), ly).conectar(self.cambiaJuez) # Opciones vlayout = Colocacion.V().control(gbColor) vlayout.espacio(5).control(self.gbJ) vlayout.margen(20) gbBasic = Controles.GB(self, "", vlayout) gbBasic.setFlat(True) # Opciones avanzadas lyInicial = Colocacion.H().control(lbInicial).control( self.edJugInicial).relleno().control(lbBooks).control( self.cbBooks).relleno() vlayout = Colocacion.V().relleno().otro(lyInicial).control(gbOpening) vlayout.espacio(5).control(self.chContrario).margen(20).relleno() gbAdvanced = Controles.GB(self, "", vlayout) gbAdvanced.setFlat(True) # Historico self.liHisto = [] oColumnas = Columnas.ListaColumnas() oColumnas.nueva("FECHA", _("Date"), 80, siCentrado=True) oColumnas.nueva("PACIERTOS", _("Hints"), 90, siCentrado=True) oColumnas.nueva("PUNTOS", _("Points accumulated"), 120, siCentrado=True) oColumnas.nueva("ENGINE", _("Adjudicator"), 100, siCentrado=True) oColumnas.nueva("RESUMEN", _("Game played"), 150) self.grid = grid = Grid.Grid(self, oColumnas, siSelecFilas=True, background=None) self.grid.coloresAlternados() self.registrarGrid(grid) # Tabs self.tab = Controles.Tab().ponPosicion("S") self.tab.nuevaTab(gbBasic, _("Basic")) self.tab.nuevaTab(gbAdvanced, _("Advanced")) self.tab.nuevaTab(self.grid, _("Track record")) # Cabecera lyCab = Colocacion.H().control(gbGM) if self.liPersonal: lyCab.control(gbPersonal) layout = Colocacion.V().control(tb).otro(lyCab).control( self.tab).margen(3) self.setLayout(layout) self.recuperaDic() self.cambiaJuez() self.compruebaGM() self.compruebaP() self.compruebaHisto() self.aperturaMuestra() self.btAperturasFavoritas.hide() self.recuperarVideo(anchoDefecto=450)
def __init__(self, procesador, txtcategoria, nivel, seconds, listaFen, record): titulo = _("Check your memory on a chessboard") icono = Iconos.Memoria() extparam = "memoria" QTVarios.WDialogo.__init__(self, procesador.main_window, titulo, icono, extparam) f = Controles.TipoLetra(puntos=10, peso=75) self.configuration = procesador.configuration self.nivel = nivel self.seconds = seconds self.record = record # Board config_board = self.configuration.config_board("MEMORIA", 48) self.listaFen = listaFen self.position = Position.Position() self.board = Board.PosBoard(self, config_board) self.board.crea() self.board.ponDispatchDrop(self.dispatchDrop) self.board.baseCasillasSC.setAcceptDrops(True) self.ultimaPieza = "P" self.piezas = self.board.piezas tamPiezas = max(16, int(32 * self.board.config_board.anchoPieza() / 48)) self.listaPiezasW = QTVarios.ListaPiezas(self, "P,N,B,R,Q,K", self.board, tamPiezas, margen=0) self.listaPiezasB = QTVarios.ListaPiezas(self, "p,n,b,r,q,k", self.board, tamPiezas, margen=0) # Ayuda lbAyuda = Controles.LB( self, _("<ul><li><b>Add piece</b> : Right mouse button on empty square</li><li><b>Copy piece</b> : Left mouse button on empty square</li><li><b>Move piece</b> : Drag and drop piece with left mouse button</li><li><b>Delete piece</b> : Right mouse button on occupied square</li></ul>" ), ) ly = Colocacion.H().control(lbAyuda) self.gbAyuda = Controles.GB(self, _("Help"), ly) # Rotulos informacion lbCategoria = Controles.LB(self, txtcategoria).ponFuente(f) lbNivel = Controles.LB(self, _X(_("Level %1/%2"), str(nivel + 1), "25")).ponFuente(f) if record: lbRecord = Controles.LB(self, _X(_("Record %1 seconds"), str(record))).ponFuente(f) # Rotulo de vtime self.rotuloDispone = (Controles.LB( self, _X(_("You have %1 seconds to remember the position of %2 pieces"), str(self.seconds), str(self.nivel + 3))).set_wrap().ponFuente(f).align_center()) self.rotuloDispone1 = (Controles.LB( self, _("when you know you can press the Continue button")). set_wrap().ponFuente(f).align_center()) ly = Colocacion.V().control(self.rotuloDispone).control( self.rotuloDispone1) self.gbTiempo = Controles.GB(self, "", ly) self.rotuloDispone1.hide() # Tool bar li_acciones = ( (_("Start"), Iconos.Empezar(), "empezar"), (_("Continue"), Iconos.Pelicula_Seguir(), "seguir"), (_("Check"), Iconos.Check(), "comprobar"), (_("Target"), Iconos.Verde32(), "objetivo"), (_("Wrong"), Iconos.Rojo32(), "nuestro"), (_("Repeat"), Iconos.Pelicula_Repetir(), "repetir"), (_("Resign"), Iconos.Abandonar(), "abandonar"), ) self.tb = tb = Controles.TB(self, li_acciones) self.pon_toolbar(["empezar"]) # Colocamos lyP = Colocacion.H().relleno().control(self.listaPiezasW).control( self.listaPiezasB).relleno().margen(0) lyT = Colocacion.V().control(self.board).otro(lyP).margen(0) lyI = Colocacion.V() lyI.control(tb) lyI.relleno() lyI.controlc(lbCategoria) lyI.controlc(lbNivel) if record: lyI.controlc(lbRecord) lyI.controlc(self.gbTiempo) lyI.relleno() lyI.control(self.gbAyuda) lyI.margen(3) ly = Colocacion.H().otro(lyT).otro(lyI).relleno() ly.margen(3) self.setLayout(ly) self.timer = None self.encenderExtras(False)
def __init__(self, manager, tutor, siRival, siOpenings, is_white, siPuntos): titulo = _("Analyzing your move") icono = Iconos.Tutor() extparam = "tutor" QTVarios.WDialogo.__init__(self, manager.main_window, titulo, icono, extparam) self.tutor = tutor self.manager0 = manager.manager self.respLibro = None self.siElegidaOpening = False self.x_tutor_view = manager.procesador.configuration.x_tutor_view # ~ self.setStyleSheet("QDialog,QGroupBox { background: #f0f0f0; }") f = Controles.TipoLetra(puntos=12, peso=75) flb = Controles.TipoLetra(puntos=10) flba = Controles.TipoLetra(puntos=8) ae = QTUtil.anchoEscritorio() mx = 32 if ae > 1000 else 20 config_board = Code.configuration.config_board("TUTOR", mx) # Boards def create_board(name, si=True, siLibre=True, siMas=False): if not si: return None, None, None board = Board.Board(self, config_board) board.crea() board.ponerPiezasAbajo(is_white) lytb, tb = QTVarios.lyBotonesMovimiento(self, name, siLibre, siMas=siMas) return board, lytb, tb self.boardTutor, lytbTutor, self.tbTutor = create_board("tutor") self.boardUsuario, lytbUsuario, self.tbUsuario = create_board("user") self.boardRival, lytbRival, self.tbRival = create_board( "rival", siRival) self.boardOpening, lytbOpening, self.tbOpening = create_board( "opening", siOpenings, siLibre=False) tutor.ponBoardsGUI(self.boardTutor, self.boardUsuario, self.boardRival, self.boardOpening) # Puntuaciones self.lbTutorPuntuacion = Controles.LB(self).align_center().ponFuente( flb) self.lbUsuarioPuntuacion = Controles.LB(self).align_center().ponFuente( flb) if siRival: self.lbRivalPuntuacion = Controles.LB( self).align_center().ponFuente(flb) # Openings if siOpenings: li_options = self.tutor.opcionesOpenings() self.cbOpenings = Controles.CB(self, li_options, 0) self.cbOpenings.setFont(flba) self.connect(self.cbOpenings, QtCore.SIGNAL("currentIndexChanged(int)"), self.tutor.cambiarOpening) # RM liRM = [] for n, uno in enumerate(tutor.list_rm): liRM.append((uno[1], n)) self.cbRM, self.lbRM = QTUtil2.comboBoxLB(self, liRM, liRM[0][1], _("Moves analyzed")) self.connect(self.cbRM, QtCore.SIGNAL("currentIndexChanged (int)"), tutor.cambiadoRM) lyRM = Colocacion.H().control(self.lbRM).control(self.cbRM) lyTutor = Colocacion.V().relleno().control( self.lbTutorPuntuacion).relleno() gbTutor = Controles.GB(self, _("Tutor's suggestion"), lyTutor).ponFuente(f).align_center() if siPuntos: gbTutor.to_connect(self.elegirTutor) self.lbTutorPuntuacion.setEnabled(True) lyUsuario = Colocacion.V().relleno().control( self.lbUsuarioPuntuacion).relleno() gbUsuario = (Controles.GB( self, _("Your move"), lyUsuario).ponFuente(f).align_center().to_connect( self.elegirUsuario)) self.lbUsuarioPuntuacion.setEnabled(True) btLibros = Controles.PB(self, _("Consult a book"), self.consultaLibro).ponPlano(False) if siRival: lyRival = Colocacion.V().relleno().control( self.lbRivalPuntuacion).relleno() gbRival = Controles.GB(self, _("Opponent's prediction"), lyRival).ponFuente(f).align_center() if siOpenings: lyOpenings = Colocacion.V().relleno().control( self.cbOpenings).relleno() gbOpenings = Controles.GB(self, _("Opening"), lyOpenings).align_center().ponFuente(f) if siPuntos: gbOpenings.to_connect(self.elegirOpening) self.cbOpenings.setEnabled(True) self.tutor.cambiarOpening(0) dicVista = { POS_TUTOR_HORIZONTAL: ((0, 1), (0, 2)), POS_TUTOR_HORIZONTAL_2_1: ((0, 1), (4, 0)), POS_TUTOR_HORIZONTAL_1_2: ((4, 0), (4, 1)), POS_TUTOR_VERTICAL: ((4, 0), (8, 0)), } usu, riv = dicVista[self.x_tutor_view] fu, cu = usu fr, cr = riv layout = Colocacion.G() layout.controlc(gbTutor, 0, 0).controlc(self.boardTutor, 1, 0).otro(lytbTutor, 2, 0).otroc(lyRM, 3, 0) layout.controlc(gbUsuario, fu, cu).controlc(self.boardUsuario, fu + 1, cu).otro( lytbUsuario, fu + 2, cu).controlc(btLibros, fu + 3, cu) if siRival: layout.controlc(gbRival, fr, cr).controlc(self.boardRival, fr + 1, cr).otro(lytbRival, fr + 2, cr) elif siOpenings: layout.controlc(gbOpenings, fr, cr).controlc(self.boardOpening, fr + 1, cr).otro(lytbOpening, fr + 2, cr) layout.margen(8) self.setLayout(layout) self.restore_video(siTam=False)
def __init__(self, gestor, tutor, siRival, siAperturas, siBlancas, siPuntos): titulo = _("Analyzing your move") icono = Iconos.Tutor() extparam = "tutor" QTVarios.WDialogo.__init__(self, gestor.pantalla, titulo, icono, extparam) self.tutor = tutor self.gestor0 = gestor.gestor self.respLibro = None self.siElegidaApertura = False self.vistaTutor = gestor.procesador.configuracion.vistaTutor # ~ self.setStyleSheet("QDialog,QGroupBox { background: #f0f0f0; }") f = Controles.TipoLetra(puntos=12, peso=75) flb = Controles.TipoLetra(puntos=10) flba = Controles.TipoLetra(puntos=8) ae = QTUtil.anchoEscritorio() mx = 32 if ae > 1000 else 20 confTablero = VarGen.configuracion.confTablero("TUTOR", mx) # Tableros def creaTablero(nombre, si=True, siLibre=True, siMas=False): if not si: return None, None, None tablero = Tablero.Tablero(self, confTablero) tablero.crea() tablero.ponerPiezasAbajo(siBlancas) lytb, tb = QTVarios.lyBotonesMovimiento(self, nombre, siLibre, siMas=siMas) return tablero, lytb, tb self.tableroTutor, lytbTutor, self.tbTutor = creaTablero("tutor") self.tableroUsuario, lytbUsuario, self.tbUsuario = creaTablero( "usuario") self.tableroRival, lytbRival, self.tbRival = creaTablero( "rival", siRival) self.tableroApertura, lytbApertura, self.tbApertura = creaTablero( "apertura", siAperturas, siLibre=False) tutor.ponTablerosGUI(self.tableroTutor, self.tableroUsuario, self.tableroRival, self.tableroApertura) # Puntuaciones self.lbTutorPuntuacion = Controles.LB(self).alinCentrado().ponFuente( flb) self.lbUsuarioPuntuacion = Controles.LB(self).alinCentrado().ponFuente( flb) if siRival: self.lbRivalPuntuacion = Controles.LB( self).alinCentrado().ponFuente(flb) # Aperturas if siAperturas: liOpciones = self.tutor.opcionesAperturas() self.cbAperturas = Controles.CB(self, liOpciones, 0) self.cbAperturas.setFont(flba) self.connect(self.cbAperturas, QtCore.SIGNAL("currentIndexChanged(int)"), self.tutor.cambiarApertura) # RM liRM = [] for n, uno in enumerate(tutor.listaRM): liRM.append((uno[1], n)) self.cbRM, self.lbRM = QTUtil2.comboBoxLB(self, liRM, liRM[0][1], _("Moves analyzed")) self.connect(self.cbRM, QtCore.SIGNAL("currentIndexChanged (int)"), tutor.cambiadoRM) lyRM = Colocacion.H().control(self.lbRM).control(self.cbRM) lyTutor = Colocacion.V().relleno().control( self.lbTutorPuntuacion).relleno() gbTutor = Controles.GB(self, _("Tutor's suggestion"), lyTutor).ponFuente(f).alinCentrado() if siPuntos: gbTutor.conectar(self.elegirTutor) self.lbTutorPuntuacion.setEnabled(True) lyUsuario = Colocacion.V().relleno().control( self.lbUsuarioPuntuacion).relleno() gbUsuario = Controles.GB( self, _("Your move"), lyUsuario).ponFuente(f).alinCentrado().conectar(self.elegirUsuario) self.lbUsuarioPuntuacion.setEnabled(True) btLibros = Controles.PB(self, _("Consult a book"), self.consultaLibro).ponPlano(False) if siRival: lyRival = Colocacion.V().relleno().control( self.lbRivalPuntuacion).relleno() gbRival = Controles.GB(self, _("Opponent's prediction"), lyRival).ponFuente(f).alinCentrado() if siAperturas: lyAperturas = Colocacion.V().relleno().control( self.cbAperturas).relleno() gbAperturas = Controles.GB(self, _("Opening"), lyAperturas).alinCentrado().ponFuente(f) if siPuntos: gbAperturas.conectar(self.elegirApertura) self.cbAperturas.setEnabled(True) self.tutor.cambiarApertura(0) dicVista = { kTutorH: ((0, 1), (0, 2)), kTutorH2_1: ((0, 1), (4, 0)), kTutorH1_2: ((4, 0), (4, 1)), kTutorV: ((4, 0), (8, 0)) } usu, riv = dicVista[self.vistaTutor] fu, cu = usu fr, cr = riv layout = Colocacion.G() layout.controlc(gbTutor, 0, 0).controlc(self.tableroTutor, 1, 0).otro(lytbTutor, 2, 0).otroc(lyRM, 3, 0) layout.controlc(gbUsuario, fu, cu).controlc(self.tableroUsuario, fu + 1, cu).otro( lytbUsuario, fu + 2, cu).controlc(btLibros, fu + 3, cu) if siRival: layout.controlc(gbRival, fr, cr).controlc(self.tableroRival, fr + 1, cr).otro(lytbRival, fr + 2, cr) elif siAperturas: layout.controlc(gbAperturas, fr, cr).controlc(self.tableroApertura, fr + 1, cr).otro(lytbApertura, fr + 2, cr) layout.margen(8) self.setLayout(layout) self.recuperarVideo(siTam=False)
def __init__(self, procesador): wParent = procesador.pantalla self.configuracion = procesador.configuracion self.procesador = procesador self.siCambios = False QtGui.QDialog.__init__(self, wParent) self.setWindowTitle(_("Training with a book")) self.setWindowIcon(Iconos.Libros()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint) self.setMinimumWidth(450) flb = Controles.TipoLetra(puntos=10) # Variables antiguas dic = self.recuperaDIC() if dic is None: dic = {} dic_siBlancas = dic.get("SIBLANCAS", True) dic_nomLibro = dic.get("NOMLIBRO", "") dic_RR = dic.get("RR", "au") dic_RJ = dic.get("RJ", False) # Toolbar liAcciones = [ (_("Accept"), Iconos.Aceptar(), "aceptar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, ] tb = Controles.TB(self, liAcciones) # Color self.rbBlancas = QtGui.QRadioButton(_("White")) self.rbBlancas.setChecked(dic_siBlancas) self.rbNegras = QtGui.QRadioButton(_("Black")) self.rbNegras.setChecked(not dic_siBlancas) hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(10).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(flb) # Libros fvar = self.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.recuperaVar(fvar) # # Comprobamos que todos esten accesibles self.listaLibros.comprueba() li = [(x.nombre, x) for x in self.listaLibros.lista] libInicial = None if dic_nomLibro: for nom, libro in li: if nom == dic_nomLibro: libInicial = libro break if libInicial is None: libInicial = li[0][1] if li else None self.cb = QTUtil2.comboBoxLB(self, li, libInicial) btNuevo = Controles.PB(self, "", self.nuevo, plano=False).ponIcono(Iconos.Nuevo(), tamIcon=16) btBorrar = Controles.PB(self, "", self.borrar, plano=False).ponIcono(Iconos.Borrar(), tamIcon=16) hbox = Colocacion.H().relleno().control( self.cb).control(btNuevo).control(btBorrar).relleno() gbLibro = Controles.GB(self, _("Book"), hbox).ponFuente(flb) # Respuesta rival li = ( (_("Selected by the player"), "su"), (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ) self.cbRR = QTUtil2.comboBoxLB(self, li, dic_RR) hbox = Colocacion.H().relleno().control(self.cbRR).relleno() gbRR = Controles.GB(self, _("Opponent's move"), hbox).ponFuente(flb) # Respuesta jugador self.chRJ = Controles.CHB(self, _("Always the highest percentage"), dic_RJ) hbox = Colocacion.H().relleno().control(self.chRJ).relleno() gbRJ = Controles.GB(self, _("Player's move"), hbox).ponFuente(flb) vlayout = Colocacion.V() vlayout.control(gbColor).espacio(5) vlayout.control(gbLibro).espacio(5) vlayout.control(gbRR).espacio(5) vlayout.control(gbRJ) vlayout.margen(20) layout = Colocacion.V().control(tb).otro(vlayout).margen(3) self.setLayout(layout)
def __init__(self, owner, db_mate15, mate15): QTVarios.WDialogo.__init__(self, owner, _("Mate in 1½"), Iconos.Mate15(), "runmate15") self.configuracion = Code.configuracion self.mate15 = mate15 self.db_mate15 = db_mate15 conf_board = self.configuracion.config_board("RUNMATE15", 64) self.board = Tablero.TableroEstatico(self, conf_board) self.board.crea() # Rotulo informacion self.lb_info = Controles.LB( self, "[%d] %s" % (self.mate15.pos + 1, self.mate15.info)).ponTipoLetra( puntos=self.configuracion.x_pgn_fontpoints).alinCentrado() self.lb_info.setStyleSheet( "QWidget { background-color: #1f497d; color: #FFFFFF;padding: 16px; }" ) self.lb_first_move = Controles.LB(self).ponTipoLetra(puntos=12, peso=500) self.bt_check = Controles.PB(self, _("Check"), self.check, False).ponIcono(Iconos.Check(), tamIcon=20) self.lb_result = Controles.LB(self).ponTipoLetra(puntos=12, peso=500) # Movimientos self.li_lb_wm = [] ly = Colocacion.G().margen(4) for fila in range(10): lb = Controles.LB(self).ponTipoLetra(puntos=12, peso=500) wm = WRunCommon.WEdMove(self) self.li_lb_wm.append((lb, wm)) ly.controld(lb, fila, 0) ly.columnaVacia(1, 20) ly.control(wm, fila, 2) lb.hide() wm.hide() ly.filaVacia(10, 20) ly.controlc(self.bt_check, 11, 0, numColumnas=3) ly.controlc(self.lb_result, 12, 0, numColumnas=3) self.gb = Controles.GB(self, _("Next moves and their solutions"), ly).ponFuente( Controles.TipoLetra(puntos=10, peso=75)) self.gb.hide() li_acciones = ( (_("Close"), Iconos.MainMenu(), self.terminar), None, (_("Begin"), Iconos.Empezar(), self.begin), (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir), ) self.tb = QTVarios.LCTB(self, li_acciones, style=QtCore.Qt.ToolButtonTextBesideIcon, tamIcon=32) self.show_tb(self.terminar, self.begin) ly_right = Colocacion.V().control(self.tb).\ controlc(self.lb_info).espacio(40).\ controlc(self.lb_first_move).espacio(20).\ control(self.gb).relleno() ly_center = Colocacion.H().control(self.board).otro(ly_right).margen(3) self.setLayout(ly_center) self.restore_video() self.adjustSize() self.gb.setDisabled(True) self.li_lb_wm[0][1].activa() self.ultimaCelda = None
def __init__(self, wParent): QtGui.QWidget.__init__(self, wParent) self.wParent = wParent self.jg = None self.partida = None puntos = VarGen.configuracion.puntosPGN f = Controles.TipoLetra(puntos=puntos, peso=75) # ftxt = Controles.TipoLetra( nombre="Courier New", puntos=puntos ) f9 = Controles.TipoLetra(puntos=puntos) ftxt = f9 # Apertura self.lbApertura = Controles.LB( self, "").ponFuente(f).alinCentrado().ponColorFondoN( "#eeeeee", "#474d59").ponWrap() self.lbApertura.hide() # Valoracion liOpciones = [("-", "-")] dicNAGs = TrListas.dicNAGs() carpNAGs = "./IntFiles/NAGs" for x in dicNAGs: if x: fsvg = "%s/$%d.svg" % (carpNAGs, x) if os.path.isfile(fsvg): liOpciones.append(("$%d : %s" % (x, dicNAGs[x]), str(x), QTVarios.fsvg2ico(fsvg, 16))) else: liOpciones.append(("$%d : %s" % (x, dicNAGs[x]), str(x))) self.maxNAGs = 10 self.liNAGs = [] for x in range(self.maxNAGs): cb = Controles.CB(self, liOpciones, "").ponAnchoMinimo().capturaCambiado( self.valoracionCambiada).ponFuente(f9) if x: cb.hide() self.liNAGs.append(cb) liOpciones = [(x, x) for x in ("-", "!", "!!", "?", "??", "!?", "?!")] self.valoracionDirecta = Controles.CB( self, liOpciones, "-").ponAnchoFijo(42).capturaCambiado( self.valoracionDirectaCambiada) lyH = Colocacion.H().control(self.valoracionDirecta).control( self.liNAGs[0]) ly = Colocacion.V().otro(lyH) for x in range(1, self.maxNAGs): ly.control(self.liNAGs[x]) self.gbValoracion = Controles.GB(self, _("Rating"), ly).ponFuente(f) # Comentarios self.comentario = Controles.EM(self, siHTML=False).capturaCambios( self.comentarioCambiado).ponFuente(ftxt).anchoMinimo(200) ly = Colocacion.H().control(self.comentario) self.gbComentario = Controles.GB(self, _("Comments"), ly).ponFuente(f) # Variantes liAcciones = ( (_("Append"), Iconos.Mas(), "tbMasVariante"), None, ("%s+%s" % (_("Append"), _("Engine")), Iconos.MasR(), "tbMasVarianteR"), None, (_("Edit"), Iconos.ComentarioEditar(), "tbEditarVariante"), None, (_("Remove"), Iconos.Borrar(), "tbBorrarVariante"), None, ) tbVariantes = Controles.TB(self, liAcciones, siTexto=False, tamIcon=16) self.variantes = Controles.EM(self, siHTML=False).capturaCambios( self.variantesCambiado).ponFuente(ftxt) self.variantes.capturaDobleClick(self.variantesDobleClick) ly = Colocacion.V().control(tbVariantes).control(self.variantes) self.gbVariantes = Controles.GB(self, _("Variants"), ly).ponFuente(f) layout = Colocacion.V() layout.control(self.lbApertura) layout.control(self.gbValoracion) layout.control(self.gbComentario) layout.control(self.gbVariantes) layout.margen(5) self.setLayout(layout)
def __init__(self, wparent, is_game, game): self.game = game self.position = game.first_position self.configuration = configuration = Code.configuration self.is_game = is_game self.wparent = wparent QtWidgets.QWidget.__init__(self, wparent) li_acciones = ( (_("Save"), Iconos.GrabarComo(), self.save), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Start position"), Iconos.Inicio(), self.inicial), None, (_("Clear board"), Iconos.Borrar(), self.limpiaBoard), (_("Paste FEN position"), Iconos.Pegar16(), self.pegar), (_("Copy FEN position"), Iconos.Copiar(), self.copiar), (_("Scanner"), Iconos.Scanner(), self.scanner), ) self.tb = Controles.TBrutina(self, li_acciones, with_text=False, icon_size=20) config_board = configuration.config_board("VOYAGERPOS", 24) self.board = Board.PosBoard(self, config_board) self.board.crea() self.board.set_dispatcher(self.mueve) self.board.mensBorrar = self.borraCasilla self.board.mensCrear = self.creaCasilla self.board.mensRepetir = self.repitePieza self.board.ponDispatchDrop(self.dispatchDrop) self.board.baseCasillasSC.setAcceptDrops(True) dragDropWB = QTVarios.ListaPiezas(self, "P,N,B,R,Q,K", self.board, margen=0) dragDropBA = QTVarios.ListaPiezas(self, "k,q,r,b,n,p", self.board, margen=0) self.rbWhite = Controles.RB(self, _("White"), rutina=self.cambiaColor) self.rbBlack = Controles.RB(self, _("Black"), rutina=self.cambiaColor) self.cbWoo = Controles.CHB(self, _("White") + " O-O", True) self.cbWooo = Controles.CHB(self, _("White") + " O-O-O", True) self.cbBoo = Controles.CHB(self, _("Black") + " O-O", True) self.cbBooo = Controles.CHB(self, _("Black") + " O-O-O", True) lbEnPassant = Controles.LB(self, _("En passant") + ":") self.edEnPassant = Controles.ED(self).controlrx( "(-|[a-h][36])").anchoFijo(30) self.edMovesPawn, lbMovesPawn = QTUtil2.spinBoxLB( self, 0, 0, 999, etiqueta=_("Halfmove clock"), maxTam=50) self.edFullMoves, lbFullMoves = QTUtil2.spinBoxLB( self, 1, 1, 999, etiqueta=_("Fullmove number"), maxTam=50) self.vars_scanner = Scanner.Scanner_vars( self.configuration.carpetaScanners) self.lb_scanner = Controles.LB(self) pb_scanner_deduce = Controles.PB(self, _("Deduce"), self.scanner_deduce, plano=False) self.chb_scanner_flip = Controles.CHB(self, _("Flip the board"), False).capture_changes( self, self.scanner_flip) self.pb_scanner_learn = Controles.PB(self, _("Learn"), self.scanner_learn, plano=False) self.pb_scanner_learn_quit = Controles.PB( self, "", self.scanner_learn_quit).ponIcono(Iconos.Menos(), icon_size=24) self.pb_scanner_learn_quit.ponToolTip( _("Remove last learned")).anchoFijo(24) self.sb_scanner_tolerance, lb_scanner_tolerance = QTUtil2.spinBoxLB( self, self.vars_scanner.tolerance, 3, 20, etiqueta=_("Deduction tolerance"), maxTam=50) self.sb_scanner_tolerance_learns, lb_scanner_tolerance_learns = QTUtil2.spinBoxLB( self, self.vars_scanner.tolerance_learns, 1, 6, etiqueta=_("Learning tolerance"), maxTam=50) self.chb_rem_ghost_deductions = Controles.CHB( self, _("Remove ghost deductions"), self.vars_scanner.rem_ghost) self.cb_scanner_select, lb_scanner_select = QTUtil2.comboBoxLB( self, [], None, _("OPR")) self.cb_scanner_select.capture_changes(self.scanner_change) pb_scanner_more = Controles.PB(self, "", self.scanner_more).ponIcono( Iconos.Mas()) self.chb_scanner_ask = Controles.CHB(self, _("Ask before new capture"), self.vars_scanner.ask) self.li_scan_pch = [] self.is_scan_init = False # LAYOUT ------------------------------------------------------------------------------------------- hbox = Colocacion.H().control(self.rbWhite).espacio(15).control( self.rbBlack) gbColor = Controles.GB(self, _("Side to play"), hbox) ly = Colocacion.G().control(self.cbWoo, 0, 0).control(self.cbBoo, 0, 1) ly.control(self.cbWooo, 1, 0).control(self.cbBooo, 1, 1) gbEnroques = Controles.GB(self, _("Castling moves possible"), ly) ly = Colocacion.G() ly.controld(lbMovesPawn, 0, 0, 1, 3).control(self.edMovesPawn, 0, 3) ly.controld(lbEnPassant, 1, 0).control(self.edEnPassant, 1, 1) ly.controld(lbFullMoves, 1, 2).control(self.edFullMoves, 1, 3) gbOtros = Controles.GB(self, "", ly) lyT = Colocacion.H().relleno().control(lb_scanner_tolerance).espacio( 5).control(self.sb_scanner_tolerance).relleno() lyTL = Colocacion.H().relleno().control( lb_scanner_tolerance_learns).espacio(5).control( self.sb_scanner_tolerance_learns).relleno() lyL = Colocacion.H().control(self.pb_scanner_learn).control( self.pb_scanner_learn_quit) lyS = Colocacion.H().control(lb_scanner_select).control( self.cb_scanner_select).control(pb_scanner_more) ly = Colocacion.V().control(self.chb_scanner_flip).control( pb_scanner_deduce).otro(lyL).otro(lyT).otro(lyTL) ly.control(self.chb_rem_ghost_deductions).otro(lyS) ly.control(self.chb_scanner_ask) self.gb_scanner = Controles.GB(self, _("Scanner"), ly) lyG = Colocacion.G() lyG.controlc(dragDropBA, 0, 0) lyG.control(self.board, 1, 0).control(self.lb_scanner, 1, 1) lyG.controlc(dragDropWB, 2, 0).controlc(self.gb_scanner, 2, 1, numFilas=4) lyG.controlc(gbColor, 3, 0) lyG.controlc(gbEnroques, 4, 0) lyG.controlc(gbOtros, 5, 0) layout = Colocacion.V() layout.controlc(self.tb) layout.otro(lyG) layout.margen(1) self.setLayout(layout) self.ultimaPieza = "P" self.piezas = self.board.piezas self.resetPosicion() self.ponCursor() self.lb_scanner.hide() self.pb_scanner_learn_quit.hide() self.gb_scanner.hide()
def __init__(self, owner, db_counts, count): QTVarios.WDialogo.__init__(self, owner, _("Count moves"), Iconos.Count(), "runcounts") self.configuration = Code.configuration self.count = count self.db_counts = db_counts conf_board = self.configuration.config_board("RUNCOUNTS", 64) self.board = Board.BoardEstaticoMensaje(self, conf_board, None) self.board.crea() # Rotulo informacion self.lb_info_game = Controles.LB( self, self.count.game.titulo( "DATE", "EVENT", "WHITE", "BLACK", "RESULT")).ponTipoLetra( puntos=self.configuration.x_pgn_fontpoints) # Movimientos self.ed_moves = Controles.ED(self, "").ponTipoLetra(puntos=32) self.ed_moves.setValidator(QtGui.QIntValidator(self.ed_moves)) self.ed_moves.setAlignment(QtCore.Qt.AlignRight) self.ed_moves.anchoFijo(72) ly = Colocacion.H().relleno().control(self.ed_moves).relleno() self.gb_counts = Controles.GB(self, _("Number of moves"), ly).ponFuente( Controles.TipoLetra(puntos=10, peso=75)) self.lb_result = Controles.LB(self).ponTipoLetra( puntos=10, peso=500).anchoFijo(254).altoFijo(32).set_wrap() self.lb_info = (Controles.LB(self).ponTipoLetra( puntos=14, peso=500).anchoFijo(254).set_foreground_backgound( "white", "#496075").align_center()) # Botones li_acciones = ( (_("Close"), Iconos.MainMenu(), self.terminar), None, (_("Begin"), Iconos.Empezar(), self.begin), (_("Check"), Iconos.Check(), self.check), (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir), ) self.tb = QTVarios.LCTB(self, li_acciones, style=QtCore.Qt.ToolButtonTextBesideIcon, icon_size=32) self.show_tb(self.terminar, self.begin) ly_right = (Colocacion.V().control(self.tb).controlc( self.lb_info).relleno().control(self.gb_counts).relleno().control( self.lb_result).relleno()) ly_center = Colocacion.H().control(self.board).otro(ly_right) ly = Colocacion.V().otro(ly_center).control( self.lb_info_game).margen(3) self.setLayout(ly) self.restore_video() self.adjustSize() # Tiempo self.time_base = time.time() self.gb_counts.setDisabled(True) self.pon_info_posic() self.set_position()
def __init__(self, procesador): self.configuration = procesador.configuration self.procesador = procesador self.db_histo = UtilSQL.DictSQL(self.configuration.ficheroGMhisto) self.opening_block = None self.li_preferred_openings = [] w_parent = procesador.main_window titulo = _("Play like a Grandmaster") icono = Iconos.GranMaestro() extparam = "gm" QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam) flb = Controles.TipoLetra( puntos=procesador.configuration.x_menu_points) # Toolbar li_acciones = [ (_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("One game"), Iconos.Uno(), self.unJuego), None, (_("Import"), Iconos.ImportarGM(), self.importar), ] tb = Controles.TBrutina(self, li_acciones) # Grandes maestros self.li_gm = GM.lista_gm() gb_style = Common.gb_style() li = [(x[0], x[1]) for x in self.li_gm] li.insert(0, ("-", None)) self.cb_gm = QTUtil2.comboBoxLB( self, li, li[0][1] if len(self.li_gm) == 0 else li[1][1]) self.cb_gm.capture_changes(self.check_gm) hbox = Colocacion.H().relleno().control(self.cb_gm).relleno() gbGM = Controles.GB(self, _("Choose a Grandmaster"), hbox).ponFuente(flb) gbGM.setStyleSheet(gb_style) # Personales self.li_personal = GM.lista_gm_personal( self.procesador.configuration.personal_training_folder) if self.li_personal: li = [(x[0], x[1]) for x in self.li_personal] li.insert(0, ("-", None)) self.cbPersonal = QTUtil2.comboBoxLB(self, li, li[0][1]) self.cbPersonal.capture_changes(self.check_personal) btBorrar = Controles.PB(self, "", self.borrarPersonal).ponIcono( Iconos.Borrar(), icon_size=24) hbox = Colocacion.H().relleno().control( self.cbPersonal).control(btBorrar).relleno() gb_personal = Controles.GB(self, _("Personal games"), hbox).ponFuente(flb) gb_personal.setStyleSheet(gb_style) # Color self.rb_white = Controles.RB(self, _("White"), rutina=self.check_color) self.rb_white.setFont(flb) self.rb_white.activa(True) self.rb_black = Controles.RB(self, _("Black"), rutina=self.check_color) self.rb_black.setFont(flb) self.rb_black.activa(False) # Contrario self.ch_select_rival_move = Controles.CHB( self, _("Choose the opponent's move, when there are multiple possible answers" ), False) # Juez liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) self.liMotores = self.configuration.comboMotoresMultiPV10() self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB( self, self.liMotores, self.configuration.tutor_inicial, _("Engine")) self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat( 1.0).anchoFijo(50) self.lbJtiempo = Controles.LB2P(self, _("Time in seconds")) self.cbJdepth = Controles.CB(self, liDepths, 0).capture_changes(self.change_depth) self.lbJdepth = Controles.LB2P(self, _("Depth")) self.lbJshow = Controles.LB2P(self, _("Show rating")) self.chbEvals = Controles.CHB(self, _("Show all evaluations"), False) li_options = [(_("All moves"), None), (_("Moves are different"), True), (_("Never"), False)] self.cbJshow = Controles.CB(self, li_options, True) self.lbJmultiPV = Controles.LB2P( self, _("Number of moves evaluated by engine(MultiPV)")) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) self.cbJmultiPV = Controles.CB(self, li, "PD") self.li_adjudicator_controls = ( self.cbJmotor, self.lbJmotor, self.edJtiempo, self.lbJtiempo, self.lbJdepth, self.cbJdepth, self.lbJshow, self.cbJshow, self.lbJmultiPV, self.cbJmultiPV, self.chbEvals, ) for control in self.li_adjudicator_controls: control.setFont(flb) # Inicial self.edJugInicial, lbInicial = QTUtil2.spinBoxLB( self, 1, 1, 99, etiqueta=_("Initial move"), maxTam=40) # Libros fvar = self.configuration.file_books self.list_books = Books.ListBooks() self.list_books.restore_pickle(fvar) # # Comprobamos que todos esten accesibles self.list_books.check() li = [(x.name, x) for x in self.list_books.lista] li.insert(0, ("--", None)) self.cbBooks, lbBooks = QTUtil2.comboBoxLB( self, li, None, _("Bypass moves in the book")) # Openings self.btOpening = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.aperturasEditar).ponPlano(False) self.btOpeningsFavoritas = Controles.PB( self, "", self.preferred_openings).ponIcono(Iconos.Favoritos()) self.btOpeningsQuitar = Controles.PB( self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No()) hbox = Colocacion.H().control(self.btOpeningsQuitar).control( self.btOpening).control(self.btOpeningsFavoritas).relleno() gbOpening = Controles.GB(self, _("Opening"), hbox) # gbBasic # # Color hbox = Colocacion.H().relleno().control( self.rb_white).espacio(10).control(self.rb_black).relleno() gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(flb) gbColor.setStyleSheet(gb_style) # Tiempo ly1 = Colocacion.H().control(self.lbJmotor).control( self.cbJmotor).relleno().control(self.lbJshow).control( self.cbJshow) ly2 = Colocacion.H().control(self.lbJtiempo).control(self.edJtiempo) ly2.control(self.lbJdepth).control(self.cbJdepth).relleno().control( self.chbEvals) ly3 = Colocacion.H().control(self.lbJmultiPV).control( self.cbJmultiPV).relleno() ly = Colocacion.V().otro(ly1).otro(ly2).otro(ly3) self.gbJ = Controles.GB(self, _("Adjudicator"), ly).to_connect(self.change_adjudicator) self.gbJ.setStyleSheet(gb_style) # Opciones vlayout = Colocacion.V().control(gbColor) vlayout.espacio(5).control(self.gbJ) vlayout.margen(20) gbBasic = Controles.GB(self, "", vlayout) gbBasic.setFlat(True) # Opciones avanzadas lyInicial = Colocacion.H().control(lbInicial).control( self.edJugInicial).relleno().control(lbBooks).control( self.cbBooks).relleno() vlayout = Colocacion.V().otro(lyInicial).control(gbOpening) vlayout.espacio(5).control( self.ch_select_rival_move).margen(20).relleno() gbAdvanced = Controles.GB(self, "", vlayout) gbAdvanced.setFlat(True) # Historico self.liHisto = [] o_columns = Columnas.ListaColumnas() o_columns.nueva("FECHA", _("Date"), 100, centered=True) o_columns.nueva("PACIERTOS", _("Hints"), 90, centered=True) o_columns.nueva("PUNTOS", _("Points accumulated"), 140, centered=True) o_columns.nueva("ENGINE", _("Adjudicator"), 100, centered=True) o_columns.nueva("RESUMEN", _("Game played"), 280) self.grid = grid = Grid.Grid(self, o_columns, siSelecFilas=True, background=None) self.grid.coloresAlternados() self.register_grid(grid) # Tabs self.tab = Controles.Tab().set_position("S") self.tab.nuevaTab(gbBasic, _("Basic")) self.tab.nuevaTab(gbAdvanced, _("Advanced")) self.tab.nuevaTab(self.grid, _("Track record")) self.tab.setFont(flb) # Cabecera lyCab = Colocacion.H().control(gbGM) if self.li_personal: lyCab.control(gb_personal) layout = Colocacion.V().control(tb).otro(lyCab).control( self.tab).margen(6) self.setLayout(layout) self.restore_dic() self.change_adjudicator() self.check_gm() self.check_personal() self.check_histo() self.aperturaMuestra() self.btOpeningsFavoritas.hide() self.restore_video(anchoDefecto=750)
def __init__(self, w_parent, nombre_torneo): torneo = self.torneo = Tournament.Tournament(nombre_torneo) titulo = nombre_torneo icono = Iconos.Torneos() extparam = "untorneo_v1" QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam) self.configuration = Code.configuration # Datos self.liEnActual = [] self.xjugar = None self.liResult = None self.last_change = Util.today() self.li_results = [] # Toolbar tb = Controles.TBrutina(self, icon_size=24) tb.new(_("Close"), Iconos.MainMenu(), self.terminar) tb.new(_("Launch a worker"), Iconos.Lanzamiento(), self.gm_launch) # Tabs self.tab = tab = Controles.Tab() # Tab-configuration -------------------------------------------------- w = QtWidgets.QWidget() # Adjudicator lb_resign = Controles.LB( self, "%s (%s): " % (_("Minimum centipawns to assign winner"), "0=%s" % _("Disable"))) self.ed_resign = Controles.ED(self).tipoInt( torneo.resign()).anchoFijo(30) bt_resign = Controles.PB(self, "", rutina=self.borra_resign).ponIcono( Iconos.Reciclar()) # Draw-plys lbDrawMinPly = Controles.LB( self, "%s (%s): " % (_("Minimum moves to assign draw"), "0=%s" % _("Disable"))) self.sbDrawMinPly = Controles.SB(self, torneo.drawMinPly(), 20, 1000) # Draw-puntos lb_draw_range = Controles.LB( self, _("Maximum centipawns to assign draw") + ": ") self.ed_draw_range = Controles.ED(self).tipoInt( torneo.drawRange()).anchoFijo(30) bt_draw_range = Controles.PB( self, "", rutina=self.borra_draw_range).ponIcono(Iconos.Reciclar()) # adjudicator self.liMotores = self.configuration.comboMotoresMultiPV10() self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB( self, self.liMotores, torneo.adjudicator(), _("Engine")) self.edJtiempo = Controles.ED(self).tipoFloat( torneo.adjudicator_time()).anchoFijo(50) self.lbJtiempo = Controles.LB2P(self, _("Time in seconds")) layout = Colocacion.G() layout.controld(self.lbJmotor, 3, 0).control(self.cbJmotor, 3, 1) layout.controld(self.lbJtiempo, 4, 0).control(self.edJtiempo, 4, 1) self.gbJ = Controles.GB(self, _("Adjudicator"), layout) self.gbJ.setCheckable(True) self.gbJ.setChecked(torneo.adjudicator_active()) lbBook = Controles.LB(self, _("Opening book") + ": ") fvar = self.configuration.file_books self.list_books = Books.ListBooks() self.list_books.restore_pickle(fvar) # Comprobamos que todos esten accesibles self.list_books.check() li = [(x.name, x.path) for x in self.list_books.lista] li.insert(0, ("* " + _("None"), "-")) self.cbBooks = Controles.CB(self, li, torneo.book()) btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=False).ponIcono(Iconos.Nuevo(), icon_size=16) lyBook = Colocacion.H().control( self.cbBooks).control(btNuevoBook).relleno() lbBookDepth = Controles.LB(self, _("Max depth of book (0=Maximum)") + ": ") self.sbBookDepth = Controles.SB(self, torneo.bookDepth(), 0, 200) lb_slow = Controles.LB(self, _("Slow down the movement of pieces") + ": ") self.chb_slow = Controles.CHB(self, " ", self.torneo.slow_pieces()) # Posicion inicial lbFEN = Controles.LB(self, _("Initial position") + ": ") self.fen = torneo.fen() self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False) self.btPosicionQuitar = Controles.PB( self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()) self.btPosicionPegar = (Controles.PB(self, "", self.posicionPegar).ponIcono( Iconos.Pegar16()).ponToolTip( _("Paste FEN position"))) lyFEN = (Colocacion.H().control(self.btPosicionQuitar).control( self.btPosicion).control(self.btPosicionPegar).relleno()) # Norman Pollock lbNorman = Controles.LB( self, '%s(<a href="https://komodochess.com/pub/40H-pgn-utilities">?</a>): ' % _("Initial position from Norman Pollock openings database"), ) self.chbNorman = Controles.CHB(self, " ", self.torneo.norman()) # Layout layout = Colocacion.G() ly_res = Colocacion.H().control( self.ed_resign).control(bt_resign).relleno() ly_dra = Colocacion.H().control( self.ed_draw_range).control(bt_draw_range).relleno() layout.controld(lb_resign, 0, 0).otro(ly_res, 0, 1) layout.controld(lbDrawMinPly, 1, 0).control(self.sbDrawMinPly, 1, 1) layout.controld(lb_draw_range, 2, 0).otro(ly_dra, 2, 1) layout.controld(lbBook, 3, 0).otro(lyBook, 3, 1) layout.controld(lbBookDepth, 4, 0).control(self.sbBookDepth, 4, 1) layout.controld(lbFEN, 5, 0).otro(lyFEN, 5, 1) layout.controld(lbNorman, 6, 0).control(self.chbNorman, 6, 1) layout.controld(lb_slow, 7, 0).control(self.chb_slow, 7, 1) layoutV = Colocacion.V().relleno().otro(layout).control( self.gbJ).relleno() layoutH = Colocacion.H().relleno().otro(layoutV).relleno() # Creamos w.setLayout(layoutH) tab.nuevaTab(w, _("Configuration")) # Tab-engines -------------------------------------------------- self.splitterEngines = QtWidgets.QSplitter(self) self.register_splitter(self.splitterEngines, "engines") # TB li_acciones = [ (_("New"), Iconos.TutorialesCrear(), self.enNuevo), None, (_("Modify"), Iconos.Modificar(), self.enModificar), None, (_("Remove"), Iconos.Borrar(), self.enBorrar), None, (_("Copy"), Iconos.Copiar(), self.enCopiar), None, (_("Import"), Iconos.MasDoc(), self.enImportar), None, ] tbEnA = Controles.TBrutina(self, li_acciones, icon_size=16, style=QtCore.Qt.ToolButtonTextBesideIcon) # Grid engine o_columns = Columnas.ListaColumnas() o_columns.nueva("NUM", _("N."), 50, centered=True) o_columns.nueva("ALIAS", _("Alias"), 209) self.gridEnginesAlias = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True, xid=GRID_ALIAS) self.register_grid(self.gridEnginesAlias) w = QtWidgets.QWidget() ly = Colocacion.V().control(self.gridEnginesAlias).margen(0) w.setLayout(ly) self.splitterEngines.addWidget(w) o_columns = Columnas.ListaColumnas() o_columns.nueva("CAMPO", _("Label"), 200, siDerecha=True) o_columns.nueva("VALOR", _("Value"), 286) self.gridEnginesValores = Grid.Grid(self, o_columns, siSelecFilas=False, xid=GRID_VALUES) self.register_grid(self.gridEnginesValores) w = QtWidgets.QWidget() ly = Colocacion.V().control(self.gridEnginesValores).margen(0) w.setLayout(ly) self.splitterEngines.addWidget(w) self.splitterEngines.setSizes([250, 520]) # por defecto w = QtWidgets.QWidget() ly = Colocacion.V().control(tbEnA).control(self.splitterEngines) w.setLayout(ly) tab.nuevaTab(w, _("Engines")) # Creamos # Tab-games queued-------------------------------------------------- w = QtWidgets.QWidget() # TB li_acciones = [ (_("New"), Iconos.TutorialesCrear(), self.gm_crear_queued), None, (_("Remove"), Iconos.Borrar(), self.gm_borrar_queued), None, ] tbEnG = Controles.TBrutina(self, li_acciones, icon_size=16, style=QtCore.Qt.ToolButtonTextBesideIcon) o_columns = Columnas.ListaColumnas() o_columns.nueva("NUM", _("N."), 50, centered=True) o_columns.nueva("WHITE", _("White"), 190, centered=True) o_columns.nueva("BLACK", _("Black"), 190, centered=True) o_columns.nueva("TIME", _("Time"), 170, centered=True) # o_columns.nueva("STATE", _("State"), 190, centered=True) self.gridGamesQueued = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True, xid=GRID_GAMES_QUEUED) self.register_grid(self.gridGamesQueued) # Layout layout = Colocacion.V().control(tbEnG).control(self.gridGamesQueued) # Creamos w.setLayout(layout) tab.nuevaTab(w, _("Games queued")) # Tab-games terminados-------------------------------------------------- w = QtWidgets.QWidget() # TB li_acciones = [ (_("Remove"), Iconos.Borrar(), self.gm_borrar_finished), None, (_("Show"), Iconos.PGN(), self.gm_show_finished), None, (_("Save") + "(%s)" % _("PGN"), Iconos.GrabarComo(), self.gm_save_pgn), None, (_("Save") + "(%s)" % _("Database"), Iconos.GrabarComo(), self.gm_save_database), None, ] tbEnGt = Controles.TBrutina(self, li_acciones, icon_size=16, style=QtCore.Qt.ToolButtonTextBesideIcon) o_columns = Columnas.ListaColumnas() o_columns.nueva("NUM", _("N."), 50, centered=True) o_columns.nueva("WHITE", _("White"), 190, centered=True) o_columns.nueva("BLACK", _("Black"), 190, centered=True) o_columns.nueva("TIME", _("Time"), 170, centered=True) o_columns.nueva("RESULT", _("Result"), 190, centered=True) self.gridGamesFinished = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True, xid=GRID_GAMES_FINISHED) self.register_grid(self.gridGamesFinished) # Layout layout = Colocacion.V().control(tbEnGt).control(self.gridGamesFinished) # Creamos w.setLayout(layout) tab.nuevaTab(w, _("Games finished")) # Tab-resultado -------------------------------------------------- w = QtWidgets.QWidget() # Grid wh = _("W") bl = _("B") o_columns = Columnas.ListaColumnas() o_columns.nueva("NUM", _("N."), 35, centered=True) o_columns.nueva("ENGINE", _("Engine"), 120, centered=True) o_columns.nueva("SCORE", _("Score") + "%", 50, centered=True) o_columns.nueva("WIN", _("Wins"), 50, centered=True) o_columns.nueva("DRAW", _("Draws"), 50, centered=True) o_columns.nueva("LOST", _("Losses"), 50, centered=True) o_columns.nueva("WIN-WHITE", "%s %s" % (wh, _("Wins")), 60, centered=True) o_columns.nueva("DRAW-WHITE", "%s %s" % (wh, _("Draws")), 60, centered=True) o_columns.nueva("LOST-WHITE", "%s %s" % (wh, _("Losses")), 60, centered=True) o_columns.nueva("WIN-BLACK", "%s %s" % (bl, _("Wins")), 60, centered=True) o_columns.nueva("DRAW-BLACK", "%s %s" % (bl, _("Draws")), 60, centered=True) o_columns.nueva("LOST-BLACK", "%s %s" % (bl, _("Losses")), 60, centered=True) o_columns.nueva("GAMES", _("Games"), 50, centered=True) self.gridResults = Grid.Grid(self, o_columns, siSelecFilas=True, xid=GRID_RESULTS) self.register_grid(self.gridResults) self.qtColor = { "WHITE": QTUtil.qtColorRGB(255, 250, 227), "BLACK": QTUtil.qtColorRGB(221, 255, 221), "SCORE": QTUtil.qtColorRGB(170, 170, 170), } # Layout layout = Colocacion.V().control(self.gridResults) # Creamos w.setLayout(layout) tab.nuevaTab(w, _("Results")) # Layout # tab.set_position("W") layout = Colocacion.V().control(tb).espacio(-3).control(tab).margen(2) self.setLayout(layout) self.restore_video(siTam=True, anchoDefecto=800, altoDefecto=430) self.gridEnginesAlias.gotop() self.ed_resign.setFocus() self.muestraPosicion() QtCore.QTimer.singleShot(5000, self.comprueba_cambios) self.rotulos_tabs()
def __init__(self, procesador): self.procesador = procesador self.configuracion = procesador.configuracion self.siPlay = False self.wreload = False self.dbwashing = Washing.DBWashing(procesador.configuracion) self.washing = self.dbwashing.washing eng = self.washing.lastEngine(procesador.configuracion) siTerminado = eng is None owner = procesador.pantalla titulo = _("The Washing Machine") extparam = "washing" icono = Iconos.WashingMachine() QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) # Toolbar tb = Controles.TBrutina(self) tb.new(_("Close"), Iconos.MainMenu(), self.terminar) tb.new(_("File"), Iconos.Recuperar(), self.file) if not siTerminado: tb.new(_("Play"), Iconos.Play(), self.play) # Tab current ia = self.washing.index_average() c_create = "#f9e7e7" c_tactics = "#df8f87" c_reinit = "#8aa678" c_des = "#e4e4e4" c_hab = "#9dde67" c_act = "#dd2a2b" c_ia = "#cccdea" li_ia = ("#ffed00", "#ff8e00", "#29b41b", "#1174ff", "#bc01d9", "#eb0000") d_ia = li_ia[int(eng.index() / (100.0 / 6.0)) % 6] state = eng.state wsvg = QtSvg.QSvgWidget() with open("IntFiles/washing-machine.svg") as f: svg = f.read() d_create = c_des d_tactics = c_des d_reinit = c_des ctac = "" if state == Washing.CREATING: d_create = c_act elif state == Washing.REPLAY: d_create = c_hab d_tactics = c_hab d_reinit = c_act elif state == Washing.TACTICS: d_create = c_hab d_tactics = c_act ctac = str(eng.numTactics()) svg = svg.replace(c_create, d_create) svg = svg.replace(c_tactics, d_tactics) svg = svg.replace(c_reinit, d_reinit) svg = svg.replace("TAC", ctac) svg = svg.replace(c_ia, d_ia) wsvg.load(QtCore.QByteArray(svg)) p = 1.0 wsvg.setFixedSize(287.79 * p, 398.83 * p) if siTerminado: plant = "<tr><td align=\"right\">%s:</td><td><b>%s</b></td></tr>" hints, times, games = self.washing.totals() nEngines = self.washing.numEngines() html = '<h2><center>%s: %d %s</center></h2><br><table cellpadding="4">' % ( _("Finished"), nEngines, _("engines")) for x in range(3): html += plant html += "</table>" html = html % ( _("Hints"), "%d (%0.02f)" % (hints, hints * 1.0 / nEngines), _("Games"), "%d (%0.02f)" % (games, games * 1.0 / nEngines), _("Time"), "%s (%s)" % (Util.secs2str(times), Util.secs2str(int(times / nEngines))), ) else: plant = "<tr><td align=\"right\">%s:</td><td><b>%s</b></td></tr>" plantverde = "<tr><td align=\"right\">%s:</td><td style=\"color:green;\"><b>%s</b></td></tr>" html = "<h2><center>%s %d/%d</center></h2><br><table cellpadding=\"4\">" for x in range(8): html += plantverde if x == 2 else plant html += "</table>" html = html % ( _("Washing"), self.washing.numEngines(), self.washing.totalEngines(procesador.configuracion), _("Engine"), eng.nombre, _("Elo"), eng.elo, "<b>%s</b>" % _("Task"), eng.lbState(), _("Color"), _("White") if eng.color else _("Black"), _("Hints"), "%d/%d" % (eng.hints_current, eng.hints), _("Games"), eng.games, _("Time"), eng.lbTime(), _("Index"), eng.cindex(), ) lbTxt = Controles.LB(self, html).ponTipoLetra(puntos=12) lbIdx = Controles.LB(self, "%0.2f%%" % ia).alinCentrado().ponTipoLetra( puntos=36, peso=700) ly0 = Colocacion.V().control(wsvg).relleno(1) ly1 = Colocacion.V().espacio(20).control(lbTxt).espacio(20).control( lbIdx).relleno(1) ly2 = Colocacion.H().otro(ly0).otro(ly1) gbCurrent = Controles.GB(self, "", ly2) # Lista oColumnas = Columnas.ListaColumnas() oColumnas.nueva("STEP", _("Washing"), 50, siCentrado=True) oColumnas.nueva("ENGINE", _("Engine"), 170, siCentrado=True) oColumnas.nueva("ELO", _("Elo"), 50, siCentrado=True) oColumnas.nueva("COLOR", _("Color"), 70, siCentrado=True) oColumnas.nueva("STATE", _("State"), 90, siCentrado=True) oColumnas.nueva("HINTS", _("Hints"), 60, siCentrado=True) oColumnas.nueva("GAMES", _("Games"), 60, siCentrado=True) oColumnas.nueva("TIME", _("Time"), 60, siCentrado=True) oColumnas.nueva("DATE", _("Date"), 120, siCentrado=True) oColumnas.nueva("INDEX", _("Index"), 60, siCentrado=True) self.grid = grid = Grid.Grid(self, oColumnas, siSelecFilas=True) nAnchoPgn = self.grid.anchoColumnas() + 20 self.grid.setMinimumWidth(nAnchoPgn) self.registrarGrid(grid) ly0 = Colocacion.V().control(self.grid) gbDatos = Controles.GB(self, "", ly0) self.tab = Controles.Tab() self.tab.nuevaTab(gbCurrent, _("Current")) self.tab.nuevaTab(gbDatos, _("Data")) # Colocamos --------------------------------------------------------------- ly = Colocacion.V().control(tb).control(self.tab) self.setLayout(ly) self.recuperarVideo(siTam=True, anchoDefecto=nAnchoPgn)
def __init__(self, owner, db_captures, capture): QTVarios.WDialogo.__init__(self, owner, _("Captures and threats in a game"), Iconos.Captures(), "runcaptures") self.configuration = Code.configuration self.capture = capture self.db_captures = db_captures conf_board = self.configuration.config_board("RUNCAPTURES", 64) self.board = Board.BoardEstaticoMensaje(self, conf_board, None) self.board.crea() # Rotulo informacion self.lb_info_game = Controles.LB( self, self.capture.game.titulo( "DATE", "EVENT", "WHITE", "BLACK", "RESULT")).ponTipoLetra( puntos=self.configuration.x_pgn_fontpoints) # Movimientos self.liwm_captures = [] ly = Colocacion.G().margen(4) for i in range(16): f = i // 2 c = i % 2 wm = WRunCommon.WEdMove(self) self.liwm_captures.append(wm) ly.control(wm, f, c) self.gb_captures = Controles.GB(self, _("Captures"), ly).ponFuente( Controles.TipoLetra(puntos=10, peso=750)) self.liwm_threats = [] ly = Colocacion.G().margen(4) for i in range(16): f = i // 2 c = i % 2 wm = WRunCommon.WEdMove(self) self.liwm_threats.append(wm) ly.control(wm, f, c) self.gb_threats = Controles.GB(self, _("Threats"), ly).ponFuente( Controles.TipoLetra(puntos=10, peso=750)) self.lb_result = Controles.LB(self).ponTipoLetra( puntos=10, peso=500).anchoFijo(254).altoFijo(32).set_wrap() self.lb_info = ( Controles.LB(self).anchoFijo(254).set_foreground_backgound( "white", "#496075").align_center().ponTipoLetra(puntos=14, peso=500)) # Botones li_acciones = ( (_("Close"), Iconos.MainMenu(), self.terminar), None, (_("Begin"), Iconos.Empezar(), self.begin), (_("Check"), Iconos.Check(), self.check), (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir), ) self.tb = QTVarios.LCTB(self, li_acciones, style=QtCore.Qt.ToolButtonTextBesideIcon, icon_size=32) self.show_tb(self.terminar, self.begin) ly_right = (Colocacion.V().control(self.tb).controlc( self.lb_info).relleno().control( self.gb_captures).relleno().control(self.gb_threats).control( self.lb_result).relleno()) ly_center = Colocacion.H().control(self.board).otro(ly_right) ly = Colocacion.V().otro(ly_center).control( self.lb_info_game).margen(3) self.setLayout(ly) self.restore_video() self.adjustSize() # Tiempo self.time_base = time.time() self.gb_captures.setDisabled(True) self.gb_threats.setDisabled(True) self.liwm_captures[0].activa() self.ultimaCelda = None self.pon_info_posic() self.set_position()
def __init__(self, w_parent, rival, categorias, categoria, configuration): super(wDatos, self).__init__(w_parent) self.setWindowTitle(_("New game")) self.setWindowIcon(Iconos.Datos()) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) tb = QTUtil2.tbAcceptCancel(self) f = Controles.TipoLetra(puntos=12, peso=75) flb = Controles.TipoLetra(puntos=10) self.max_level, self.maxNivelHecho, self.max_puntos = categorias.max_level_by_category( categoria) # self.max_level = max_level = categoria.level_done+1 # self.maxNivelHecho = categoria.hecho # self.max_puntos = categoria.max_puntos() self.ed = Controles.SB(self, self.max_level, 1, self.max_level).tamMaximo(40) lb = Controles.LB(self, categoria.name() + " " + _("Level")) lb.ponFuente(f) self.lbPuntos = Controles.LB(self).align_right() self.ed.valueChanged.connect(self.nivelCambiado) is_white = not categoria.done_with_white() self.rb_white = QtWidgets.QRadioButton(_("White")) self.rb_white.setChecked(is_white) self.rb_black = QtWidgets.QRadioButton(_("Black")) self.rb_black.setChecked(not is_white) self.rb_white.clicked.connect(self.ponMaxPuntos) self.rb_black.clicked.connect(self.ponMaxPuntos) # Rival lbRMotor = Controles.LB( self, "<b>%s</b> : %s" % (_("Engine"), rival.name)).ponFuente(flb).set_wrap().anchoFijo(400) lbRAutor = Controles.LB( self, "<b>%s</b> : %s" % (_("Author"), rival.autor)).ponFuente(flb).set_wrap().anchoFijo(400) lbRWeb = (Controles.LB( self, '<b>%s</b> : <a href="%s">%s</a>' % (_("Web"), rival.url, rival.url)).set_wrap().anchoFijo(400).ponFuente(flb)) ly = Colocacion.V().control(lbRMotor).control(lbRAutor).control( lbRWeb).margen(10) gbR = Controles.GB(self, _("Opponent"), ly).ponFuente(f) # Tutor tutor = configuration.tutor lbTMotor = Controles.LB( self, "<b>%s</b> : %s" % (_("Engine"), tutor.name)).ponFuente(flb).set_wrap().anchoFijo(400) lbTAutor = Controles.LB( self, "<b>%s</b> : %s" % (_("Author"), tutor.autor)).ponFuente(flb).set_wrap().anchoFijo(400) siURL = hasattr(tutor, "url") if siURL: lbTWeb = (Controles.LB( self, '<b>%s</b> : <a href="%s">%s</a>' % ("Web", tutor.url, tutor.url)).set_wrap().anchoFijo(400).ponFuente(flb)) ly = Colocacion.V().control(lbTMotor).control(lbTAutor) if siURL: ly.control(lbTWeb) ly.margen(10) gbT = Controles.GB(self, _("Tutor"), ly).ponFuente(f) hbox = Colocacion.H().relleno().control( self.rb_white).espacio(10).control(self.rb_black).relleno() gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(f) lyNivel = Colocacion.H().control(lb).control( self.ed).espacio(10).control(self.lbPuntos).relleno() vlayout = Colocacion.V().otro(lyNivel).espacio(10).control( gbColor).espacio(10).control(gbR).espacio(10).control(gbT).margen( 30) layout = Colocacion.V().control(tb).otro(vlayout).margen(3) self.setLayout(layout) self.ponMaxPuntos()
def __init__(self, owner, motor, segundos, min_min, min_max, linea=None, ref=None): super(WPotencia, self).__init__(owner, _("Determine your calculating power"), Iconos.Potencia(), "potencia") self.partida, self.dicPGN, info, self.jugadaInicial, self.linea = lee1LineaMFN( linea) if linea else leeLineaMFN() self.fen = self.partida.jugada(self.jugadaInicial).posicion.fen() self.ref = ref self.historico = owner.historico self.procesador = owner.procesador self.configuracion = self.procesador.configuracion if motor.startswith("*"): motor = motor[1:] confMotor = self.configuracion.buscaTutor(motor, "stockfish") self.xtutor = self.procesador.creaGestorMotor(confMotor, segundos * 1000, None) self.xtutor.maximizaMultiPV() # Tablero confTablero = self.configuracion.confTablero("POTENCIA", 48) self.min_min = min_min self.min_max = min_max cp = self.partida.jugada(self.jugadaInicial).posicion self.tablero = Tablero.TableroEstatico(self, confTablero) self.tablero.crea() self.tablero.ponerPiezasAbajo(cp.siBlancas) self.tablero.ponPosicion(cp) # Rotulo informacion self.lbInformacion = self.creaLBInformacion(info, cp) # Consultar la partida self.btConsultar = Controles.PB(self, _("Show game"), self.consultar, plano=False) # Rotulo tiempo self.lbTiempo = Controles.LB(self, "").alinCentrado() self.liwm = [] conj_piezas = self.tablero.piezas siBlancas = cp.siBlancas for i in range(12): wm = WBlqMove(self, conj_piezas, siBlancas, i) self.liwm.append(wm) siBlancas = not siBlancas # Tool bar liAcciones = ( ( _("Quit"), Iconos.MainMenu(), self.terminar ), ( _("Cancel"), Iconos.Cancelar(), self.cancelar ), ( _("Check"), Iconos.Check(), self.comprobar ), ) self.tb = Controles.TBrutina(self, liAcciones) # Layout lyInfo = Colocacion.H().relleno().control(self.lbInformacion).control(self.btConsultar).relleno() lyT = Colocacion.V().relleno().control(self.tablero).otro(lyInfo).controlc(self.lbTiempo).relleno() lyV = Colocacion.V() for wm in self.liwm: lyV.control(wm) lyV.relleno() f = Controles.TipoLetra(puntos=10, peso=75) self.gbMovs = Controles.GB(self, _("Next moves"), lyV).ponFuente(f) lyTV = Colocacion.H().otro(lyT).control(self.gbMovs).relleno() ly = Colocacion.V().control(self.tb).otro(lyTV).relleno() self.setLayout(ly) self.recuperarVideo() self.adjustSize() liTB = [self.cancelar] # Tiempo self.timer = None if min_min or min_max: self.baseTiempo = time.time() if min_min: self.gbMovs.hide() self.iniciaReloj(self.pensandoHastaMin) else: liTB.insert(0, self.comprobar) self.iniciaReloj(self.pensandoHastaMax) self.ponToolBar(liTB) self.liwm[0].activa() self.btConsultar.hide() self.ultimaCelda = None
def __init__(self, owner, dicdatos): self.dicdatos = dicdatos site = dicdatos["SITE"] self.level = dicdatos["LEVEL"] self.intervalo = dicdatos["INTERVAL"] self.intervaloPorPieza = dicdatos["INTERVALPIECE"] self.esatacada = dicdatos["ISATTACKED"] self.esatacante = dicdatos["ISATTACKING"] self.posicion = dicdatos["POSITION"] self.color = dicdatos["COLOR"] self.errors = dicdatos["ERRORS"] self.time = dicdatos["TIME"] self.liFENs = dicdatos["FENS"] mas = "x" if self.intervaloPorPieza else "" titulo = "%s (%s%d\")" % (site, mas, self.intervalo) super(WPlay, self).__init__(owner, titulo, Iconos.Gafas(), "visualplay") self.procesador = owner.procesador self.configuracion = self.procesador.configuracion # Tiempo en tablero intervaloMax = self.intervalo if self.intervaloPorPieza: intervaloMax *= 32 # Tablero confTablero = self.configuracion.confTablero("VISUALPLAY", 48) self.tablero = Tablero.Tablero(self, confTablero) self.tablero.crea() lyT = Colocacion.V().control(self.tablero) self.gbTablero = Controles.GB(self, "", lyT) # entradas ly = Colocacion.G() self.posPosicion = None self.posColor = None self.posIsAttacked = None self.posIsAttacking = None lista = [_("Piece")] if self.posicion: lista.append(_("Position")) if self.color: lista.append(_("Square color")) if self.esatacada: lista.append(_("Is attacked?")) if self.esatacante: lista.append(_("Is attacking?")) self.liLB2 = [] for col, eti in enumerate(lista): ly.control(Controles.LB(self, eti), 0, col + 1) lb2 = Controles.LB(self, eti) ly.control(lb2, 0, col + len(lista) + 2) self.liLB2.append(lb2) elementos = len(lista) + 1 liComboPieces = [] for c in "PNBRQKpnbrqk": liComboPieces.append(("", c, self.tablero.piezas.icono(c))) self.pmBien = Iconos.pmAceptarPeque() self.pmMal = Iconos.pmCancelarPeque() self.pmNada = Iconos.pmPuntoAmarillo() self.liBloques = [] for x in range(32): fila = x % 16 + 1 colPos = elementos if x > 15 else 0 unBloque = [] self.liBloques.append(unBloque) # # Solucion lb = Controles.LB(self, "").ponImagen(self.pmNada) ly.control(lb, fila, colPos) unBloque.append(lb) # # Piezas colPos += 1 cb = Controles.CB(self, liComboPieces, "P") # cb.setStyleSheet("* { min-height:32px }") cb.setIconSize(QtCore.QSize(20, 20)) ly.control(cb, fila, colPos) unBloque.append(cb) if self.posicion: ec = Controles.ED(self, "").caracteres(2).controlrx( "(|[a-h][1-8])").anchoFijo(24).alinCentrado() colPos += 1 ly.controlc(ec, fila, colPos) unBloque.append(ec) if self.color: cl = QTVarios.TwoImages(Iconos.pmBlancas(), Iconos.pmNegras()) colPos += 1 ly.controlc(cl, fila, colPos) unBloque.append(cl) if self.esatacada: isat = QTVarios.TwoImages(Iconos.pmAtacada().scaledToWidth(24), Iconos.pmPuntoNegro()) colPos += 1 ly.controlc(isat, fila, colPos) unBloque.append(isat) if self.esatacante: at = QTVarios.TwoImages(Iconos.pmAtacante().scaledToWidth(24), Iconos.pmPuntoNegro()) colPos += 1 ly.controlc(at, fila, colPos) unBloque.append(at) ly1 = Colocacion.H().otro(ly).relleno() ly2 = Colocacion.V().otro(ly1).relleno() self.gbSolucion = Controles.GB(self, "", ly2) f = Controles.TipoLetra("", 11, 80, False, False, False, None) bt = Controles.PB(self, _("End game"), self.terminar, plano=False).ponIcono( Iconos.FinPartida()).ponFuente(f) self.btTablero = Controles.PB(self, _("Go to board"), self.activaTablero, plano=False).ponIcono( Iconos.Tablero()).ponFuente(f) self.btComprueba = Controles.PB(self, _("Test the solution"), self.compruebaSolucion, plano=False).ponIcono( Iconos.Check()).ponFuente(f) self.btGotoNextLevel = Controles.PB(self, _("Go to next level"), self.gotoNextLevel, plano=False).ponIcono( Iconos.GoToNext()).ponFuente(f) ly0 = Colocacion.H().control(bt).relleno().control( self.btTablero).control(self.btComprueba).control( self.btGotoNextLevel) lyBase = Colocacion.H().control(self.gbTablero).control( self.gbSolucion) layout = Colocacion.V().otro(ly0).otro(lyBase) self.setLayout(layout) self.recuperarVideo() self.gotoNextLevel()
def __init__(self, wparent, cpu): self.cpu = cpu self.posicion = cpu.partida.iniPosicion configuracion = cpu.configuracion self.wparent = wparent QtGui.QWidget.__init__(self, wparent) liAcciones = ( (_("Save"), Iconos.GrabarComo(), self.save), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Start position"), Iconos.Inicio(), self.inicial), None, (_("Clear board"), Iconos.Borrar(), self.limpiaTablero), (_("Paste FEN position"), Iconos.Pegar16(), self.pegar), (_("Copy FEN position"), Iconos.Copiar(), self.copiar), (_("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("VOYAGERPOS", 24) self.tablero = Tablero.PosTablero(self, confTablero) self.tablero.crea() self.tablero.ponMensajero(self.mueve) self.tablero.mensBorrar = self.borraCasilla self.tablero.mensCrear = self.creaCasilla self.tablero.mensRepetir = self.repitePieza self.tablero.ponDispatchDrop(self.dispatchDrop) self.tablero.baseCasillasSC.setAcceptDrops(True) self.rbWhite = Controles.RB(self, _("White")) self.rbBlack = Controles.RB(self, _("Black")) self.cbWoo = Controles.CHB(self, _("White") + " O-O", True) self.cbWooo = Controles.CHB(self, _("White") + " O-O-O", True) self.cbBoo = Controles.CHB(self, _("Black") + " O-O", True) self.cbBooo = Controles.CHB(self, _("Black") + " O-O-O", True) lbEnPassant = Controles.LB(self, _("En passant") + ":") self.edEnPassant = Controles.ED(self).controlrx( "(-|[a-h][36])").anchoFijo(30) self.edMovesPawn, lbMovesPawn = QTUtil2.spinBoxLB( self, 0, 0, 999, etiqueta=_("Halfmove clock"), maxTam=50) self.edFullMoves, lbFullMoves = QTUtil2.spinBoxLB( self, 1, 1, 999, etiqueta=_("Fullmove number"), maxTam=50) # COLOCACION ------------------------------------------------------------------------------------------- hbox = Colocacion.H().relleno().control( self.rbWhite).espacio(15).control(self.rbBlack).relleno() gbColor = Controles.GB(self, _("Next move"), hbox) ly = Colocacion.G().control(self.cbWoo, 0, 0).control(self.cbBoo, 0, 1) ly.control(self.cbWooo, 1, 0).control(self.cbBooo, 1, 1) gbEnroques = Controles.GB(self, _("Castling moves possible"), ly) ly = Colocacion.G() ly.controld(lbMovesPawn, 0, 0, 1, 3).control(self.edMovesPawn, 0, 3) ly.controld(lbEnPassant, 1, 0).control(self.edEnPassant, 1, 1) ly.controld(lbFullMoves, 1, 2).control(self.edFullMoves, 1, 3) gbOtros = Controles.GB(self, "", ly) ly = Colocacion.V().control(self.tb).control(self.tablero) ly.control(gbColor).control(gbEnroques).control(gbOtros) ly.margen(1) self.setLayout(ly) self.ultimaPieza = "P" self.piezas = self.tablero.piezas self.resetPosicion() self.ponCursor() self.queueVoice = [] self.bufferVoice = ""
def __init__(self, owner, fenIni, fenFin, liMV, info): QTVarios.WDialogo.__init__(self, owner, _("Moves between two positions"), Iconos.Puente(), "puente") self.owner = owner self.historico = owner.historico self.procesador = owner.procesador self.configuration = self.procesador.configuration self.liMV = liMV self.fenIni = fenIni self.fenFin = fenFin nivel = len(liMV) # Boards config_board = self.configuration.config_board("PUENTE", 32) cpIni = Position.Position() cpIni.read_fen(fenIni) is_white = cpIni.is_white self.boardIni = Board.BoardEstatico(self, config_board) self.boardIni.crea() self.boardIni.ponerPiezasAbajo(is_white) self.boardIni.set_position(cpIni) cpFin = Position.Position() cpFin.read_fen(fenFin) self.boardFin = Board.BoardEstatico(self, config_board) self.boardFin.crea() self.boardFin.ponerPiezasAbajo(is_white) # esta bien self.boardFin.set_position(cpFin) # Rotulo informacion self.lbInformacion = Controles.LB(self, self.textoLBInformacion( info, cpIni)).align_center() # Rotulo vtime self.lbTiempo = Controles.LB(self, "").align_center() # Movimientos self.liwm = [] conj_piezas = self.boardIni.piezas ly = Colocacion.V().margen(4).relleno() for i in range(nivel): wm = WEdMove(self, conj_piezas, is_white) self.liwm.append(wm) is_white = not is_white ly.control(wm) ly.relleno() gbMovs = Controles.GB(self, _("Next moves"), ly).ponFuente( Controles.TipoLetra(puntos=10, peso=75)) # Botones f = Controles.TipoLetra(puntos=12, peso=75) self.btComprobar = (Controles.PB(self, _("Check"), self.comprobar, plano=False).ponIcono( Iconos.Check(), icon_size=32).ponFuente(f)) self.btSeguir = (Controles.PB(self, _("Continue"), self.seguir, plano=False).ponIcono( Iconos.Pelicula_Seguir(), icon_size=32).ponFuente(f)) self.btTerminar = (Controles.PB(self, _("Close"), self.terminar, plano=False).ponIcono( Iconos.MainMenu(), icon_size=32).ponFuente(f)) self.btCancelar = (Controles.PB(self, _("Cancel"), self.terminar, plano=False).ponIcono( Iconos.Cancelar(), icon_size=32).ponFuente(f)) # Layout lyC = (Colocacion.V().control(self.btCancelar).control( self.btTerminar).relleno().control(gbMovs).relleno(1).control( self.btComprobar).control(self.btSeguir).relleno()) lyTM = Colocacion.H().control(self.boardIni).otro(lyC).control( self.boardFin).relleno() ly = Colocacion.V().otro(lyTM).controlc(self.lbInformacion).controlc( self.lbTiempo).relleno().margen(3) self.setLayout(ly) self.restore_video() self.adjustSize() # Tiempo self.time_base = time.time() self.btSeguir.hide() self.btTerminar.hide() self.liwm[0].activa() self.ultimaCelda = None
def __init__(self, owner, file): self.litourneys = Everest.str_file(file) self.configuration = owner.configuration titulo = _("New expedition") icono = Iconos.Trekking() extparam = "newexpedition" QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) self.selected = None # Torneo li = [("%s (%d)" % (_F(tourney["TOURNEY"]), len(tourney["GAMES"])), tourney) for tourney in self.litourneys] li.sort(key=lambda x: x[0]) self.cbtourney, lbtourney = QTUtil2.comboBoxLB(self, li, li[0], _("Expedition")) btmas = Controles.PB(self, "", self.mas).ponIcono(Iconos.Mas22()) lytourney = Colocacion.H().control(lbtourney).control( self.cbtourney).control(btmas).relleno(1) # tolerance self.sbtolerance_min, lbtolerance_min = QTUtil2.spinBoxLB( self, 20, 0, 99999, _("From")) self.sbtolerance_min.capture_changes(self.tolerance_changed) self.sbtolerance_max, lbtolerance_max = QTUtil2.spinBoxLB( self, 1000, 0, 99999, _("To")) lbexplanation = Controles.LB( self, _("Maximum lost points for having to repeat active game")) ly = Colocacion.H().relleno(2).control(lbtolerance_min).control( self.sbtolerance_min).relleno(1) ly.control(lbtolerance_max).control(self.sbtolerance_max).relleno(2) layout = Colocacion.V().otro(ly).control(lbexplanation) gbtolerance = Controles.GB(self, _("Tolerance"), layout) # tries self.sbtries_min, lbtries_min = QTUtil2.spinBoxLB( self, 2, 1, 99999, _("From")) self.sbtries_min.capture_changes(self.tries_changed) self.sbtries_max, lbtries_max = QTUtil2.spinBoxLB( self, 15, 1, 99999, _("To")) lbexplanation = Controles.LB( self, _("Maximum repetitions to return to the previous game")) ly = Colocacion.H().relleno(2).control(lbtries_min).control( self.sbtries_min).relleno(1) ly.control(lbtries_max).control(self.sbtries_max).relleno(2) layout = Colocacion.V().otro(ly).control(lbexplanation) gbtries = Controles.GB(self, _("Tries"), layout) # color liColors = ((_("Default"), "D"), (_("White"), "W"), (_("Black"), "B")) self.cbcolor = Controles.CB(self, liColors, "D") layout = Colocacion.H().relleno(1).control(self.cbcolor).relleno(1) gbcolor = Controles.GB(self, _("Color"), layout) tb = QTVarios.LCTB(self) tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar) tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar) layout = Colocacion.V().control(tb).otro(lytourney).control( gbtolerance).control(gbtries).control(gbcolor) self.setLayout(layout)
def __init__(self, tableroOriginal): pantalla = tableroOriginal.parent() titulo = _("Colors") icono = Iconos.EditarColores() extparam = "WColores" QTVarios.WDialogo.__init__(self, pantalla, titulo, icono, extparam) self.tableroOriginal = tableroOriginal self.configuracion = VarGen.configuracion self.confTablero = tableroOriginal.confTablero.copia( tableroOriginal.confTablero._id) self.siBase = tableroOriginal.confTablero._id == "BASE" # Temas ############################################################################################################################# liOpciones = [(_("Your themes"), self.configuracion.ficheroTemas)] for x in Util.listdir("Themes"): if x.endswith("lktheme"): ctema = x[:-8] liOpciones.append((ctema, "Themes/" + x)) self.cbTemas = Controles.CB(self, liOpciones, liOpciones[0][1]).capturaCambiado( self.cambiadoTema) self.lbSecciones = Controles.LB(self, _("Section") + ":") self.cbSecciones = Controles.CB(self, [], None).capturaCambiado( self.cambiadoSeccion) lyTemas = Colocacion.G() self.liBT_Temas = [] for i in range(12): for j in range(6): bt = BotonTema(self, self.ponTema) lyTemas.control(bt, i, j) bt.ponTema(None) self.liBT_Temas.append(bt) def creaLB(txt): return Controles.LB(self, txt + ": ").alinDerecha() # Casillas lbTrans = Controles.LB(self, _("Degree of transparency")) lbPNG = Controles.LB(self, _("Image")) # # Blancas lbBlancas = creaLB(_("White squares")) self.btBlancas = BotonColor(self, self.confTablero.colorBlancas, self.actualizaTablero) self.btBlancasPNG = BotonImagen(self, self.confTablero.png64Blancas, self.actualizaTablero, self.btBlancas) self.dialBlancasTrans = DialNum(self, self.confTablero.transBlancas, self.actualizaTablero) # # Negras lbNegras = creaLB(_("Black squares")) self.btNegras = BotonColor(self, self.confTablero.colorNegras, self.actualizaTablero) self.btNegrasPNG = BotonImagen(self, self.confTablero.png64Negras, self.actualizaTablero, self.btNegras) self.dialNegrasTrans = DialNum(self, self.confTablero.transNegras, self.actualizaTablero) # Background lbFondo = creaLB(_("Background")) self.btFondo = BotonColor(self, self.confTablero.colorFondo, self.actualizaTablero) self.btFondoPNG = BotonImagen(self, self.confTablero.png64Fondo, self.actualizaTablero, self.btFondo) self.chbExtended = Controles.CHB( self, _("Extended to outer border"), self.confTablero.extendedColor()).capturaCambiado( self, self.extendedColor) # Actual self.chbTemas = Controles.CHB( self, _("Default"), self.confTablero.siDefTema()).capturaCambiado( self, self.defectoTemas) if self.siBase: self.chbTemas.ponValor(False) self.chbTemas.setVisible(False) # Exterior lbExterior = creaLB(_("Outer Border")) self.btExterior = BotonColor(self, self.confTablero.colorExterior, self.actualizaTablero) # Texto lbTexto = creaLB(_("Coordinates")) self.btTexto = BotonColor(self, self.confTablero.colorTexto, self.actualizaTablero) # Frontera lbFrontera = creaLB(_("Inner Border")) self.btFrontera = BotonColor(self, self.confTablero.colorFrontera, self.actualizaTablero) # Flechas lbFlecha = creaLB(_("Move indicator")) self.lyF = BotonFlecha(self, self.confTablero.fTransicion, self.confTablero.flechaDefecto, self.actualizaTablero) lbFlechaAlternativa = creaLB(_("Arrow alternative")) self.lyFAlternativa = BotonFlecha( self, self.confTablero.fAlternativa, self.confTablero.flechaAlternativaDefecto, self.actualizaTablero) lbFlechaActivo = creaLB(_("Active moves")) self.lyFActual = BotonFlecha(self, self.confTablero.fActivo, self.confTablero.flechaActivoDefecto, self.actualizaTablero) lbFlechaRival = creaLB(_("Opponent moves")) self.lyFRival = BotonFlecha(self, self.confTablero.fRival, self.confTablero.flechaRivalDefecto, self.actualizaTablero) lyActual = Colocacion.G() lyActual.control(self.chbTemas, 0, 0) lyActual.controlc(lbPNG, 0, 2).controlc(lbTrans, 0, 3) lyActual.controld(lbBlancas, 1, 0).control(self.btBlancas, 1, 1).otroc(self.btBlancasPNG, 1, 2).otroc(self.dialBlancasTrans, 1, 3) lyActual.controld(lbNegras, 2, 0).control(self.btNegras, 2, 1).otroc(self.btNegrasPNG, 2, 2).otroc(self.dialNegrasTrans, 2, 3) lyActual.controld(lbFondo, 3, 0).control(self.btFondo, 3, 1).otroc( self.btFondoPNG, 3, 2).control(self.chbExtended, 3, 3) lyActual.controld(lbExterior, 4, 0).control(self.btExterior, 4, 1) lyActual.controld(lbTexto, 5, 0).control(self.btTexto, 5, 1) lyActual.controld(lbFrontera, 6, 0).control(self.btFrontera, 6, 1) lyActual.controld(lbFlecha, 7, 0).otro(self.lyF, 7, 1, 1, 4) lyActual.controld(lbFlechaAlternativa, 8, 0).otro(self.lyFAlternativa, 8, 1, 1, 4) lyActual.controld(lbFlechaActivo, 9, 0).otro(self.lyFActual, 9, 1, 1, 4) lyActual.controld(lbFlechaRival, 10, 0).otro(self.lyFRival, 10, 1, 1, 4) gbActual = Controles.GB(self, _("Active theme"), lyActual) lySecciones = Colocacion.H().control(self.lbSecciones).control( self.cbSecciones).relleno() ly = Colocacion.V().control(self.cbTemas).otro(lySecciones).otro( lyTemas).control(gbActual).relleno() gbTemas = Controles.GB(self, "", ly) gbTemas.setFlat(True) # mas opciones ############################################################################################################## def xDefecto(siDefecto): if self.siBase: siDefecto = False chb = Controles.CHB(self, _("Default"), siDefecto).capturaCambiado( self, self.defectoTableroM) if self.siBase: chb.setVisible(False) return chb def l2mas1(lyG, fila, a, b, c): if a: ly = Colocacion.H().controld(a).control(b) else: ly = Colocacion.H().control(b) lyG.otro(ly, fila, 0).control(c, fila, 1) # Coordenadas lyG = Colocacion.G() # _nCoordenadas lbCoordenadas = creaLB(_("Number")) liOpciones = [("0", 0), ("4", 4), ("2a", 2), ("2b", 3), ("2c", 5), ("2d", 6)] self.cbCoordenadas = Controles.CB( self, liOpciones, self.confTablero.nCoordenadas()).capturaCambiado( self.actualizaTableroM) self.chbDefCoordenadas = xDefecto(self.confTablero.siDefCoordenadas()) l2mas1(lyG, 0, lbCoordenadas, self.cbCoordenadas, self.chbDefCoordenadas) # _tipoLetra lbTipoLetra = creaLB(_("Font")) self.cbTipoLetra = QtGui.QFontComboBox() self.cbTipoLetra.setEditable(False) self.cbTipoLetra.setFontFilters(self.cbTipoLetra.ScalableFonts) self.cbTipoLetra.setCurrentFont( QtGui.QFont(self.confTablero.tipoLetra())) self.connect(self.cbTipoLetra, QtCore.SIGNAL("currentIndexChanged(int)"), self.actualizaTableroM) self.chbDefTipoLetra = xDefecto(self.confTablero.siDefTipoLetra()) l2mas1(lyG, 1, lbTipoLetra, self.cbTipoLetra, self.chbDefTipoLetra) # _cBold self.chbBold = Controles.CHB( self, _("Bold"), self.confTablero.siBold()).capturaCambiado(self, self.actualizaTableroM) self.chbDefBold = xDefecto(self.confTablero.siDefBold()) l2mas1(lyG, 2, None, self.chbBold, self.chbDefBold) # _tamLetra lbTamLetra = creaLB(_("Size") + " %") self.sbTamLetra = Controles.SB(self, self.confTablero.tamLetra(), 1, 200).tamMaximo(50).capturaCambiado( self.actualizaTableroM) self.chbDefTamLetra = xDefecto(self.confTablero.siDefTamLetra()) l2mas1(lyG, 3, lbTamLetra, self.sbTamLetra, self.chbDefTamLetra) # _sepLetras lbSepLetras = creaLB(_("Separation") + " %") self.sbSepLetras = Controles.SB( self, self.confTablero.sepLetras(), -1000, 1000).tamMaximo(50).capturaCambiado(self.actualizaTableroM) self.chbDefSepLetras = xDefecto(self.confTablero.siDefSepLetras()) l2mas1(lyG, 4, lbSepLetras, self.sbSepLetras, self.chbDefSepLetras) gbCoordenadas = Controles.GB(self, _("Coordinates"), lyG) lyOtros = Colocacion.G() # _nomPiezas li = [] lbPiezas = creaLB(_("Pieces")) for x in Util.listdir("Pieces"): if os.path.isdir("Pieces/%s" % x): li.append((x, x)) li.sort(key=lambda x: x[0]) self.cbPiezas = Controles.CB( self, li, self.confTablero.nomPiezas()).capturaCambiado( self.actualizaTableroM) self.chbDefPiezas = xDefecto(self.confTablero.siDefPiezas()) l2mas1(lyOtros, 0, lbPiezas, self.cbPiezas, self.chbDefPiezas) # _tamRecuadro lbTamRecuadro = creaLB(_("Outer Border Size") + " %") self.sbTamRecuadro = Controles.SB( self, self.confTablero.tamRecuadro(), 0, 10000).tamMaximo(50).capturaCambiado(self.actualizaTableroM) self.chbDefTamRecuadro = xDefecto(self.confTablero.siDefTamRecuadro()) l2mas1(lyOtros, 1, lbTamRecuadro, self.sbTamRecuadro, self.chbDefTamRecuadro) # _tamFrontera lbTamFrontera = creaLB(_("Inner Border Size") + " %") self.sbTamFrontera = Controles.SB( self, self.confTablero.tamFrontera(), 0, 10000).tamMaximo(50).capturaCambiado(self.actualizaTableroM) self.chbDefTamFrontera = xDefecto(self.confTablero.siDefTamFrontera()) l2mas1(lyOtros, 2, lbTamFrontera, self.sbTamFrontera, self.chbDefTamFrontera) ly = Colocacion.V().control(gbCoordenadas).espacio(50).otro( lyOtros).relleno() gbOtros = Controles.GB(self, "", ly) gbOtros.setFlat(True) # Tablero ########################################################################################################################## cp = ControlPosicion.ControlPosicion().leeFen( "2kr1b1r/2p1pppp/p7/3pPb2/1q3P2/2N1P3/PPP3PP/R1BQK2R w KQ - 0 1") self.tablero = Tablero.Tablero(self, self.confTablero, siMenuVisual=False) self.tablero.crea() self.tablero.ponPosicion(cp) self.rehazFlechas() liAcciones = [ (_("Accept"), Iconos.Aceptar(), "aceptar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, (_("Your themes"), Iconos.Temas(), "temas"), None, (_("Import"), Iconos.Mezclar(), "importar"), None, (_("Export"), Iconos.Grabar(), "exportar"), None, ] tb = Controles.TB(self, liAcciones) # tam tablero self.lbTamTablero = Controles.LB(self, "%d px" % self.tablero.width()) # Juntamos lyT = Colocacion.V().control(tb).espacio(15).control( self.tablero).controli(self.lbTamTablero).relleno(1).margen(3) self.tab = Controles.Tab() self.tab.nuevaTab(gbTemas, _("Themes")) self.tab.nuevaTab(gbOtros, _("Other options")) ly = Colocacion.H().otro(lyT).control(self.tab) self.setLayout(ly) self.elegido = None self.liTemas = self.leeTemas() self.temaActual = {} if self.liTemas: txtTM = self.confTablero.grabaTema() txtBS = self.confTablero.grabaBase() for tema in self.liTemas: if tema: if tema.get("TEXTO", "") == txtTM and txtBS == tema.get( "BASE", ""): self.temaActual = tema break self.cambiadoTema() self.defectoTemas() self.extendedColor() self.siActualizando = False self.recuperarVideo(siTam=False)
def __init__(self, owner, configuracion, bloqueApertura): icono = Iconos.Apertura() titulo = _("Select an opening") extparam = "selectOpening" QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) # Variables-------------------------------------------------------------------------- self.apStd = AperturasStd.apTrain self.configuracion = configuracion self.partida = Partida.Partida() self.bloqueApertura = bloqueApertura self.liActivas = [] # Tablero confTablero = configuracion.confTablero("APERTURAS", 32) self.tablero = Tablero.Tablero(self, confTablero) self.tablero.crea() self.tablero.ponMensajero(self.mueveHumano) # Current pgn self.lbPGN = Controles.LB(self, "").ponWrap().ponTipoLetra(puntos=10, peso=75) # Movimiento self.siMoviendoTiempo = False lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24) self.tbBM = tbBM # Tool bar tb = Controles.TBrutina(self) tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar) tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar) tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida) tb.new(_("Takeback"), Iconos.Atras(), self.atras) tb.new(_("Remove"), Iconos.Borrar(), self.borrar) # Lista Aperturas oColumnas = Columnas.ListaColumnas() dicTipos = {"b": Iconos.pmSun(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja()} oColumnas.nueva("TIPO", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos)) oColumnas.nueva("OPENING", _("Possible continuation"), 480) self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, altoFila=32) self.registrarGrid(self.grid) # # Derecha lyD = Colocacion.V().control(tb).control(self.grid) gbDerecha = Controles.GB(self, "", lyD) # # Izquierda lyI = Colocacion.V().control(self.tablero).otro(lyBM).control(self.lbPGN) gbIzquierda = Controles.GB(self, "", lyI) splitter = QtGui.QSplitter(self) splitter.addWidget(gbIzquierda) splitter.addWidget(gbDerecha) self.registrarSplitter(splitter, "splitter") # Completo ly = Colocacion.H().control(splitter).margen(3) self.setLayout(ly) self.ponActivas() self.resetPartida() self.actualizaPosicion() dic = {'_SIZE_': '916,444', 'SP_splitter': [356, 548]} self.recuperarVideo(dicDef=dic)
def __init__(self, wParent, categoria, configuracion): super(wDatos, self).__init__(wParent) self.setWindowTitle(_("New game")) self.setWindowIcon(Iconos.Datos()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) tb = QTUtil2.tbAcceptCancel(self) f = Controles.TipoLetra(puntos=12, peso=75) flb = Controles.TipoLetra(puntos=10) self.maxNivel, self.maxNivelHecho, self.maxPuntos = configuracion.maxNivelCategoria( categoria) # self.maxNivel = maxNivel = categoria.nivelHecho+1 # self.maxNivelHecho = categoria.hecho # self.maxPuntos = categoria.maxPuntos() self.ed = Controles.SB(self, self.maxNivel, 1, self.maxNivel).tamMaximo(40) lb = Controles.LB(self, categoria.nombre() + " " + _("Level")) lb.ponFuente(f) self.lbPuntos = Controles.LB(self).alinDerecha() self.connect(self.ed, QtCore.SIGNAL("valueChanged(int)"), self.nivelCambiado) siBlancas = not categoria.siHechoBlancas() self.rbBlancas = QtGui.QRadioButton(_("White")) self.rbBlancas.setChecked(siBlancas) self.rbNegras = QtGui.QRadioButton(_("Black")) self.rbNegras.setChecked(not siBlancas) self.connect(self.rbBlancas, QtCore.SIGNAL("clicked()"), self.ponMaxPuntos) self.connect(self.rbNegras, QtCore.SIGNAL("clicked()"), self.ponMaxPuntos) # Rival rival = configuracion.rival lbRMotor = Controles.LB( self, "<b>%s</b> : %s" % (_("Engine"), rival.nombre)).ponFuente(flb).ponWrap().anchoFijo(400) lbRAutor = Controles.LB( self, "<b>%s</b> : %s" % (_("Author"), rival.autor)).ponFuente(flb).ponWrap().anchoFijo(400) lbRWeb = Controles.LB( self, '<b>%s</b> : <a href="%s">%s</a>' % (_("Web"), rival.url, rival.url)).ponWrap().anchoFijo(400).ponFuente(flb) ly = Colocacion.V().control(lbRMotor).control(lbRAutor).control( lbRWeb).margen(10) gbR = Controles.GB(self, _("Opponent"), ly).ponFuente(f) # Tutor tutor = configuracion.tutor lbTMotor = Controles.LB( self, "<b>%s</b> : %s" % (_("Engine"), tutor.nombre)).ponFuente(flb).ponWrap().anchoFijo(400) lbTAutor = Controles.LB( self, "<b>%s</b> : %s" % (_("Author"), tutor.autor)).ponFuente(flb).ponWrap().anchoFijo(400) siURL = hasattr(tutor, "url") if siURL: lbTWeb = Controles.LB( self, '<b>%s</b> : <a href="%s">%s</a>' % ("Web", tutor.url, tutor.url)).ponWrap().anchoFijo(400).ponFuente(flb) ly = Colocacion.V().control(lbTMotor).control(lbTAutor) if siURL: ly.control(lbTWeb) ly.margen(10) gbT = Controles.GB(self, _("Tutor"), ly).ponFuente(f) hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(10).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(f) lyNivel = Colocacion.H().control(lb).control( self.ed).espacio(10).control(self.lbPuntos).relleno() vlayout = Colocacion.V().otro(lyNivel).espacio(10).control( gbColor).espacio(10).control(gbR).espacio(10).control(gbT).margen( 30) layout = Colocacion.V().control(tb).otro(vlayout).margen(3) self.setLayout(layout) self.ponMaxPuntos()
def __init__(self, procesador): icono = Iconos.ManualSave() extparam = "manualsave" titulo = _("Save positions to FNS/PGN") QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, icono, extparam) self.procesador = procesador self.configuracion = procesador.configuracion self.posicion = ControlPosicion.ControlPosicion() self.posicion.posInicial() self.gestor_motor = None self.pgn = None self.fns = None self.li_labels = [ ["Site", ""], ["Event", ""], ["Date", ""], ["White", ""], ["Black", ""], ["WhiteElo", ""], ["BlackElo", ""], ["Result", ""], ] self.li_labels.extend([["", ""] for x in range(10)]) self.li_analysis = [] self.analyzing = False self.partida = None # Toolbar liAcciones = ( (_("Close"), Iconos.MainMenu(), self.terminar), None, (_("External engines"), Iconos.Motores(), self.ext_engines), None, ) tb = Controles.TBrutina(self, liAcciones) # Board + botones + solucion + boton salvado ## bt_change_position = Controles.PB(self, " " + _("Change position"), self.change_position, plano=False) bt_change_position.ponIcono(Iconos.Datos(), 24) ## conf_tablero = self.configuracion.confTablero("MANUALSAVE", 32) self.tablero = Tablero.Tablero(self, conf_tablero) self.tablero.crea() self.tablero.ponerPiezasAbajo(True) ## lybt, bt = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24, siTiempo=False) ## self.em_solucion = Controles.EM( self, siHTML=False).altoMinimo(40).capturaCambios(self.reset_partida) ## self.bt_solucion = Controles.PB(self, " " + _("Save solution"), self.savesolucion, plano=False).ponIcono( Iconos.Grabar(), 24) self.bt_editar = Controles.PB(self, " " + _("Edit"), self.editar_solucion, plano=False).ponIcono(Iconos.PlayGame()) ly = Colocacion.V().control(self.em_solucion).control(self.bt_editar) gb = Controles.GB(self, _("Solution"), ly) ### lybtp = Colocacion.H().control(bt_change_position).espacio(20).control( self.bt_solucion) lyT = Colocacion.V().otro(lybtp).control( self.tablero).otro(lybt).control(gb) gb_left = Controles.GB(self, "", lyT) # Ficheros PGN + FNS lb_pgn = Controles.LB(self, _("PGN") + ": ") self.bt_pgn = Controles.PB(self, "", self.pgn_select, plano=False).anchoMinimo(300) bt_no_pgn = Controles.PB(self, "", self.pgn_unselect).ponIcono( Iconos.Delete()).anchoFijo(16) lb_fns = Controles.LB(self, _("FNS") + ": ") self.bt_fns = Controles.PB(self, "", self.fns_select, plano=False).anchoMinimo(300) bt_no_fns = Controles.PB(self, "", self.fns_unselect).ponIcono( Iconos.Delete()).anchoFijo(16) ## Codec lb_codec = Controles.LB(self, _("Encoding") + ": ") liCodecs = [ k for k in set(v for k, v in encodings.aliases.aliases.iteritems()) ] liCodecs.sort() liCodecs = [(k, k) for k in liCodecs] liCodecs.insert(0, ("%s: %s" % (_("By default"), _("UTF-8")), "default")) self.codec = "default" self.cb_codecs = Controles.CB(self, liCodecs, self.codec) ### ly0 = Colocacion.G().control(lb_pgn, 0, 0).control(self.bt_pgn, 0, 1).control(bt_no_pgn, 0, 2) ly0.control(lb_fns, 1, 0).control(self.bt_fns, 1, 1).control(bt_no_fns, 1, 2) ly1 = Colocacion.H().control(lb_codec).control( self.cb_codecs).relleno(1) ly = Colocacion.V().otro(ly0).otro(ly1) gb_files = Controles.GB(self, _("File to save"), ly) # Labels + correlativo oColumnas = Columnas.ListaColumnas() oColumnas.nueva("LABEL", _("Label"), 80, edicion=Delegados.LineaTextoUTF8(), siCentrado=True) oColumnas.nueva("VALUE", _("Value"), 280, edicion=Delegados.LineaTextoUTF8()) self.grid_labels = Grid.Grid(self, oColumnas, siEditable=True, xid=1) n = self.grid_labels.anchoColumnas() self.grid_labels.setFixedWidth(n + 20) self.registrarGrid(self.grid_labels) ## lb_number = Controles.LB(self, _("Correlative number") + ": ") self.sb_number = Controles.SB(self, 0, 0, 99999999).tamMaximo(50) lb_number_help = Controles.LB( self, _("Replace symbol # in Value column (#=3, ###=003)")) lb_number_help.setWordWrap(True) ly_number = Colocacion.H().control(lb_number).control( self.sb_number).control(lb_number_help, 4) ly = Colocacion.V().control(self.grid_labels).otro(ly_number) gb_labels = Controles.GB(self, _("PGN labels"), ly) # Analysis + grid + start/stop + multiPV self.bt_start = Controles.PB(self, "", self.start).ponIcono( Iconos.Pelicula_Seguir(), 32) self.bt_stop = Controles.PB(self, "", self.stop).ponIcono( Iconos.Pelicula_Pausa(), 32) self.bt_stop.hide() lb_engine = Controles.LB(self, _("Engine") + ":") liMotores = self.configuracion.comboMotoresCompleto() self.cb_engine = Controles.CB( self, liMotores, self.configuracion.tutor.clave).capturaCambiado(self.reset_motor) lb_multipv = Controles.LB(self, _("Multi PV") + ": ") self.sb_multipv = Controles.SB(self, 1, 1, 500).tamMaximo(50) ## oColumnas = Columnas.ListaColumnas() oColumnas.nueva("PDT", _("Evaluation"), 100, siCentrado=True) oColumnas.nueva("PGN", _("Solution"), 360) self.grid_analysis = Grid.Grid(self, oColumnas, siSelecFilas=True) self.registrarGrid(self.grid_analysis) ## lb_analysis_help = Controles.LB( self, _("Double click to send analysis line to solution")) ### ly_lin1 = Colocacion.H().control(self.bt_start).control( self.bt_stop).control(lb_engine).control(self.cb_engine) ly_lin1.relleno(1).control(lb_multipv).control(self.sb_multipv) ly = Colocacion.V().otro(ly_lin1).control( self.grid_analysis).control(lb_analysis_help) gb_analysis = Controles.GB(self, _("Analysis"), ly) # ZONA splitter_right = QtGui.QSplitter(self) splitter_right.setOrientation(QtCore.Qt.Vertical) splitter_right.addWidget(gb_files) splitter_right.addWidget(gb_labels) splitter_right.addWidget(gb_analysis) self.registrarSplitter(splitter_right, "RIGHT") ## splitter = QtGui.QSplitter(self) splitter.addWidget(gb_left) splitter.addWidget(splitter_right) self.registrarSplitter(splitter, "ALL") layout = Colocacion.V().control(tb).control(splitter).margen(5) self.setLayout(layout) self.inicializa()
def __init__(self, oBase, ventana, segundosPensando, is_white, cPuntos, max_recursion): super(WAnalisisVariantes, self).__init__(ventana) self.oBase = oBase # Creamos los controles self.setWindowTitle(_("Variations")) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowMinimizeButtonHint) self.setWindowIcon(Iconos.Tutor()) f = Controles.TipoLetra(puntos=12, peso=75) flb = Controles.TipoLetra(puntos=10) lbPuntuacionAnterior = Controles.LB( self, cPuntos).alinCentrado().ponFuente(flb) self.lbPuntuacionNueva = Controles.LB(self).alinCentrado().ponFuente( flb) config_board = Code.configuracion.config_board("ANALISISVARIANTES", 32) self.tablero = Tablero.Tablero(self, config_board) self.tablero.crea() self.tablero.ponerPiezasAbajo(is_white) self.tableroT = Tablero.Tablero(self, config_board) self.tableroT.crea() self.tableroT.ponerPiezasAbajo(is_white) btTerminar = Controles.PB(self, _("Close"), self.close).ponPlano(False) btReset = Controles.PB(self, _("Another change"), oBase.reset).ponIcono( Iconos.MoverLibre()).ponPlano(False) liMasAcciones = (("FEN:%s" % _("Copy to clipboard"), "MoverFEN", Iconos.Clipboard()), ) lytbTutor, self.tb = QTVarios.lyBotonesMovimiento( self, "", siLibre=max_recursion > 0, liMasAcciones=liMasAcciones) self.max_recursion = max_recursion - 1 self.segundos, lbSegundos = QTUtil2.spinBoxLB(self, segundosPensando, 1, 999, maxTam=40, etiqueta=_("Second(s)")) # Creamos los layouts lyVariacion = Colocacion.V().control(lbPuntuacionAnterior).control( self.tablero) gbVariacion = Controles.GB(self, _("Proposed change"), lyVariacion).ponFuente(f).alinCentrado() lyTutor = Colocacion.V().control(self.lbPuntuacionNueva).control( self.tableroT) gbTutor = Controles.GB(self, _("Tutor's prediction"), lyTutor).ponFuente(f).alinCentrado() lyBT = Colocacion.H().control(btTerminar).control( btReset).relleno().control(lbSegundos).control(self.segundos) layout = Colocacion.G().control(gbVariacion, 0, 0).control(gbTutor, 0, 1) layout.otro(lyBT, 1, 0).otro(lytbTutor, 1, 1) self.setLayout(layout) self.move(ventana.x() + 20, ventana.y() + 20)
def __init__(self, procesador, titulo): super().__init__(parent=procesador.pantalla, titulo=titulo, icono=Iconos.Libre(), extparam="entMaquina") self.configuracion = procesador.configuracion self.procesador = procesador self.personalidades = Personalidades.Personalidades( self, self.configuracion) self.motores = Motores.Motores(self.configuracion) # Toolbar liAcciones = [ (_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Configurations"), Iconos.Configurar(), self.configuraciones), None, ] tb = Controles.TBrutina(self, liAcciones) # Tab tab = Controles.Tab() def nuevoG(): lyG = Colocacion.G() lyG.filaActual = 0 return lyG gbStyle = """ QGroupBox { font: bold 16px; background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/ border: 1px solid gray; border-radius: 3px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top center; /* position at the top center */ padding: 0 3px; } """ def _label(lyG, txt, ly, rutinaCHB=None, siCheck=False): gb = Controles.GB(self, txt, ly) if rutinaCHB: gb.conectar(rutinaCHB) elif siCheck: gb.setCheckable(True) gb.setChecked(False) gb.setStyleSheet(gbStyle) lyG.controlc(gb, lyG.filaActual, 0) lyG.filaActual += 1 return gb # TAB General lyG = nuevoG() # Blancas o negras self.rbBlancas = Controles.RB(self, "").activa() self.rbBlancas.setIcon( QTVarios.fsvg2ico("Pieces/Chessicons/wp.svg", 64)) self.rbNegras = Controles.RB(self, "") self.rbNegras.setIcon(QTVarios.fsvg2ico("Pieces/Chessicons/bp.svg", 64)) self.rbRandom = Controles.RB(self, _("Random")) hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(30).control( self.rbNegras).espacio(30).control(self.rbRandom).relleno() _label(lyG, _("Select color"), hbox) # Motores liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) # # Rival self.rival = self.configuracion.rivalInicial self.rivalTipo = Motores.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False) self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50) self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth) lbTiempoSegundosR = Controles.LB2P(self, _("Time")) lbNivel = Controles.LB2P(self, _("Depth")) # # Ajustar rival liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = Controles.CB(self, liAjustes, kAjustarMejor).capturaCambiado( self.ajustesCambiado) lbAjustarRival = Controles.LB2P(self, _("Set strength")) btAjustarRival = Controles.PB(self, _("Personality"), self.cambiaPersonalidades, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) # Resign lbResign = Controles.LB2P(self, _("Resign/draw by engine")) liResign = ((_("Very early"), -100), (_("Early"), -300), (_("Average"), -500), (_("Late"), -800), (_("Very late"), -1000), (_("Never"), -9999999)) self.cbResign = Controles.CB(self, liResign, -800) lyH1 = Colocacion.H().control(self.btRival).espacio(20) lyH1.control(lbTiempoSegundosR).control(self.edRtiempo) lyH1.control(lbNivel).control(self.cbRdepth).relleno() lyH2 = Colocacion.H().control(lbAjustarRival).control( self.cbAjustarRival).control(btAjustarRival).relleno() lyH3 = Colocacion.H().control(lbResign).control( self.cbResign).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3) _label(lyG, _("Opponent"), ly) gb = Controles.GB(self, "", lyG) tab.nuevaTab(gb, _("Basic configuration")) # TAB Ayudas lbAyudas = Controles.LB2P(self, _("Available hints")) self.sbAyudas = Controles.SB(self, 7, 0, 999).tamMaximo(50) self.cbAtras = Controles.CHB(self, _("Takeback"), True) self.cbChance = Controles.CHB(self, _("Second chance"), True) btTutorChange = Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False).ponIcono(Iconos.Tutor(), tamIcon=16) liThinks = [(_("Nothing"), -1), (_("Score"), 0)] for i in range(1, 5): liThinks.append( ("%d %s" % (i, _("ply") if i == 1 else _("plies")), i)) liThinks.append((_("All"), 9999)) lb = Controles.LB(self, _("It is showed") + ":") self.cbThoughtTt = Controles.CB(self, liThinks, -1) self.cbContinueTt = Controles.CHB( self, _("The tutor thinks while you think"), True) lbBoxHeight = Controles.LB2P(self, _("Box height")) self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50) ly1 = Colocacion.H().control(lb).control(self.cbThoughtTt).relleno() ly2 = Colocacion.H().control(lbBoxHeight).control( self.sbBoxHeight).relleno() ly = Colocacion.V().otro(ly1).control( self.cbContinueTt).espacio(16).otro(ly2).relleno() gbThoughtTt = Controles.GB(self, _("Thought of the tutor"), ly) gbThoughtTt.setStyleSheet(gbStyle) lb = Controles.LB(self, _("It is showed") + ":") self.cbThoughtOp = Controles.CB(self, liThinks, -1) lbArrows = Controles.LB2P(self, _("Arrows to show")) self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50) ly1 = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno() ly2 = Colocacion.H().control(lbArrows).control(self.sbArrows).relleno() ly = Colocacion.V().otro(ly1).otro(ly2).relleno() gbThoughtOp = Controles.GB(self, _("Thought of the opponent"), ly) gbThoughtOp.setStyleSheet(gbStyle) self.chbSummary = Controles.CHB( self, _("Save a summary when the game is finished in the main comment"), False) lyH1 = Colocacion.H().relleno() lyH1.control(lbAyudas).control(self.sbAyudas).relleno() lyH1.control(self.cbAtras).relleno() lyH1.control(self.cbChance).relleno() lyH1.control(btTutorChange).relleno() # lyV1 = Colocacion.V().control(gbThoughtOp) lyH3 = Colocacion.H().relleno() lyH3.control(gbThoughtOp).relleno() lyH3.control(gbThoughtTt).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH3).control( self.chbSummary).margen(16) gb = Controles.GB(self, "", ly) tab.nuevaTab(gb, _("Help configuration")) # TAB Tiempo lyG = nuevoG() self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB( self, 15, 0, 999, maxTam=50, etiqueta=_("Total minutes")) self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB( self, 6, -999, 999, maxTam=54, etiqueta=_("Seconds added per move")) self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=70, etiqueta=_("Extra minutes for the player")) self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=54, etiqueta=_("Zeitnot: alarm sounds when remaining seconds")) lyH1 = Colocacion.H() lyH1.control(self.lbMinutos).control(self.edMinutos).espacio(30) lyH1.control(self.lbSegundos).control(self.edSegundos).relleno() lyH2 = Colocacion.H() lyH2.control(self.lbMinExtra).control(self.edMinExtra).relleno() lyH3 = Colocacion.H() lyH3.control(self.lbZeitnot).control(self.edZeitnot).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3) self.chbTiempo = _label(lyG, _("Time"), ly, siCheck=True) gb = Controles.GB(self, "", lyG) tab.nuevaTab(gb, _("Time")) # TAB Initial moves lyG = nuevoG() # Posicion self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False) self.fen = "" self.btPosicionQuitar = Controles.PB( self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()) self.btPosicionPegar = Controles.PB(self, "", self.posicionPegar).ponIcono( Iconos.Pegar16()).ponToolTip( _("Paste FEN position")) hbox = Colocacion.H().relleno().control(self.btPosicionQuitar).control( self.btPosicion).control(self.btPosicionPegar).relleno() _label(lyG, _("Start position"), hbox) # Aperturas self.btApertura = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.editarApertura).ponPlano(False) self.bloqueApertura = None self.btAperturasFavoritas = Controles.PB( self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos()) self.btAperturasQuitar = Controles.PB( self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No()) hbox = Colocacion.H().relleno().control( self.btAperturasQuitar).control(self.btApertura).control( self.btAperturasFavoritas).relleno() _label(lyG, _("Opening"), hbox) # Libros fvar = self.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.recuperaVar(fvar) # Comprobamos que todos esten accesibles self.listaLibros.comprueba() li = [(x.nombre, x) for x in self.listaLibros.lista] libInicial = li[0][1] if li else None self.cbBooks = QTUtil2.comboBoxLB(self, li, libInicial) self.btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.chbBookMandatory = Controles.CHB(self, _("Mandatory"), False) # Respuesta rival li = ( (_("Selected by the player"), "su"), (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ) self.cbBooksRR = QTUtil2.comboBoxLB(self, li, "mp") self.lbBooksRR = Controles.LB2P(self, _("Opponent's move")) hbox = Colocacion.H().relleno().control(self.cbBooks).control( self.btNuevoBook).control(self.chbBookMandatory).relleno() hboxRR = Colocacion.H().relleno().control(self.lbBooksRR).control( self.cbBooksRR).relleno() hboxV = Colocacion.V().otro(hbox).otro(hboxRR) self.chbBook = _label(lyG, _("Book"), hboxV, siCheck=True) ly = Colocacion.V().otro(lyG).relleno() gb = Controles.GB(self, "", ly) tab.nuevaTab(gb, _("Initial moves")) layout = Colocacion.V().control(tb).control(tab).relleno().margen(3) self.setLayout(layout) self.liAperturasFavoritas = [] self.btAperturasFavoritas.hide() dic = Util.recuperaDIC(self.configuracion.ficheroEntMaquina) if not dic: dic = {} self.muestraDic(dic) self.ajustesCambiado() # self.ayudasCambiado() self.ponRival() self.recuperarVideo()
def __init__(self, gestor, elo, titulo, icono, tipo): QTVarios.WDialogo.__init__(self, gestor.main_window, titulo, icono, tipo.lower()) self.siMicElo = tipo == "MICELO" self.siMicPer = tipo == "MICPER" self.siMic = self.siMicElo or self.siMicPer self.gestor = gestor self.colorNoJugable = QTUtil.qtColorRGB(241, 226, 226) self.colorMenor = QTUtil.qtColorRGB(245, 245, 245) self.colorMayor = None self.elo = elo self.tipo = tipo # Toolbar li_acciones = [ (_("Choose"), Iconos.Aceptar(), self.elegir), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Random opponent"), Iconos.FAQ(), self.selectRandom), None, ] if self.siMicElo: li_acciones.append((_("Reset"), Iconos.Reiniciar(), self.reset)) li_acciones.append(None) self.tb = QTVarios.LCTB(self, li_acciones) self.liMotores = self.gestor.list_engines(elo) self.liMotoresActivos = self.liMotores liFiltro = ( ("---", None), (">=", ">"), ("<=", "<"), ("+-100", "100"), ("+-200", "200"), ("+-400", "400"), ("+-800", "800"), ) self.cbElo = Controles.CB(self, liFiltro, None).capturaCambiado(self.filtrar) minimo = 9999 maximo = 0 for mt in self.liMotores: if mt.siJugable: if mt.elo < minimo: minimo = mt.elo if mt.elo > maximo: maximo = mt.elo self.sbElo, lbElo = QTUtil2.spinBoxLB(self, elo, minimo, maximo, maxTam=50, etiqueta=_("Elo")) self.sbElo.capturaCambiado(self.filtrar) if self.siMic: liCaract = [] st = set() for mt in self.liMotores: mt.liCaract = li = mt.id_info.split("\n") mt.txtCaract = ", ".join([_F(x) for x in li]) for x in li: if not (x in st): st.add(x) liCaract.append((_F(x), x)) liCaract.sort(key=lambda x: x[1]) liCaract.insert(0, ("---", None)) self.cbCaract = Controles.CB(self, liCaract, None).capturaCambiado(self.filtrar) ly = Colocacion.H().control(lbElo).control(self.cbElo).control( self.sbElo) if self.siMic: ly.control(self.cbCaract) ly.relleno(1) gbRandom = Controles.GB(self, "", ly) # Lista o_columns = Columnas.ListaColumnas() o_columns.nueva("NUMERO", _("N."), 35, centered=True) o_columns.nueva("MOTOR", _("Name"), 140) o_columns.nueva("ELO", _("Elo"), 60, siDerecha=True) if not self.siMicPer: o_columns.nueva("GANA", _("Win"), 80, centered=True) o_columns.nueva("TABLAS", _("Draw"), 80, centered=True) o_columns.nueva("PIERDE", _("Lost"), 80, centered=True) if self.siMic: o_columns.nueva("INFO", _("Information"), 300, centered=True) self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, siCabeceraMovible=False, altoFila=24) n = self.grid.anchoColumnas() self.grid.setMinimumWidth(n + 20) self.register_grid(self.grid) f = Controles.TipoLetra(puntos=9) self.grid.ponFuente(f) self.grid.gotop() # Layout lyH = Colocacion.H().control(self.tb).control(gbRandom) layout = Colocacion.V().otro(lyH).control(self.grid).margen(3) self.setLayout(layout) self.filtrar() self.restore_video()
def __init__(self, wParent, configuracion, dic, siGestorSolo): super(WCambioRival, self).__init__(wParent) if not dic: dic = {} self.setWindowTitle(_("Change opponent")) self.setWindowIcon(Iconos.Motor()) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = configuracion self.personalidades = Personalidades.Personalidades( self, configuracion) # Toolbar liAcciones = [ (_("Accept"), Iconos.Aceptar(), "aceptar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, ] tb = Controles.TB(self, liAcciones) # Blancas o negras self.rbBlancas = Controles.RB(self, _("White")).activa() self.rbNegras = Controles.RB(self, _("Black")) # Atras self.cbAtras = Controles.CHB(self, "", True) # Motores self.motores = Motores.Motores(configuracion) liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) # # Rival self.rival = configuracion.rivalInicial self.rivalTipo = Motores.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False) self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50) self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth) lbTiempoSegundosR = Controles.LB2P(self, _("Time")) lbNivel = Controles.LB2P(self, _("Depth")) # # Ajustar rival liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = Controles.CB(self, liAjustes, kAjustarMejor).capturaCambiado( self.ajustesCambiado) lbAjustarRival = Controles.LB2P(self, _("Set strength")) btAjustarRival = Controles.PB(self, "", self.cambiaPersonalidades, plano=False).ponIcono(Iconos.Nuevo(), tamIcon=16) btAjustarRival.ponToolTip(_("Personalities")) # Layout # Color hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(30).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Play with"), hbox) # Atras hbox = Colocacion.H().espacio(10).control(self.cbAtras) gbAtras = Controles.GB(self, _("Takeback"), hbox).alinCentrado() ## Color + Atras hAC = Colocacion.H().control(gbColor).control(gbAtras) if siGestorSolo: # gbColor.hide() gbAtras.hide() # Motores # Rival ly = Colocacion.G() ly.controlc(self.btRival, 0, 0, 1, 4) ly.controld(lbTiempoSegundosR, 1, 0).controld(self.edRtiempo, 1, 1) ly.controld(lbNivel, 1, 2).control(self.cbRdepth, 1, 3) lyH = Colocacion.H().control(lbAjustarRival).control( self.cbAjustarRival).control(btAjustarRival).relleno() ly.otroc(lyH, 2, 0, 1, 4) gbR = Controles.GB(self, _("Opponent"), ly) lyResto = Colocacion.V() lyResto.otro(hAC).espacio(3) lyResto.control(gbR).espacio(1) lyResto.margen(8) layout = Colocacion.V().control(tb).otro(lyResto).relleno().margen(3) self.setLayout(layout) self.dic = dic self.recuperaDic() self.ajustesCambiado() self.ponRival()
def __init__(self, owner, tactica, ncopia=None): QtGui.QWidget.__init__(self) self.owner = owner self.tacticaINI = tactica if ncopia is not None: regHistorico = tactica.historico()[ncopia] else: regHistorico = None # Total por ficheros self.liFTOTAL = tactica.calculaTotales() total = sum(self.liFTOTAL) # N. puzzles if regHistorico: num = regHistorico["PUZZLES"] else: num = tactica.PUZZLES if not num or num > total: num = total lbPuzzles = Controles.LB(self, _("Max number of puzzles in each block") + ": ") self.sbPuzzles = Controles.SB(self, num, 1, total) # Reference lbReference = Controles.LB(self, _("Reference") + ": ") self.edReference = Controles.ED(self) # Iconos icoMas = Iconos.Add() icoMenos = Iconos.Delete() icoCancel = Iconos.CancelarPeque() icoReset = Iconos.MoverAtras() def tbGen(prev): liAcciones = ((_("Add"), icoMas, "%s_add" % prev), (_("Delete"), icoMenos, "%s_delete" % prev), None, (_("Delete all"), icoCancel, "%s_delete_all" % prev), None, (_("Reset"), icoReset, "%s_reset" % prev), None, ) tb = Controles.TB(self, liAcciones, tamIcon=16, siTexto=False) return tb f = Controles.TipoLetra(peso=75) # Repeticiones de cada puzzle if regHistorico: self.liJUMPS = regHistorico["JUMPS"][:] else: self.liJUMPS = tactica.JUMPS[:] tb = tbGen("jumps") oCol = Columnas.ListaColumnas() oCol.nueva("NUMERO", _("Repetition"), 80, siCentrado=True) oCol.nueva("JUMPS_SEPARATION", _("Separation"), 80, siCentrado=True, edicion=Delegados.LineaTexto(siEntero=True)) self.grid_jumps = Grid.Grid(self, oCol, siSelecFilas=True, siEditable=True, xid="j") self.grid_jumps.setMinimumWidth(self.grid_jumps.anchoColumnas() + 20) ly = Colocacion.V().control(tb).control(self.grid_jumps) gbJumps = Controles.GB(self, _("Repetitions of each puzzle"), ly).ponFuente(f) self.grid_jumps.gotop() # Repeticion del bloque if regHistorico: self.liREPEAT = regHistorico["REPEAT"][:] else: self.liREPEAT = tactica.REPEAT[:] tb = tbGen("repeat") oCol = Columnas.ListaColumnas() oCol.nueva("NUMERO", _("Block"), 40, siCentrado=True) self.liREPEATtxt = (_("Original"), _("Random"), _("Previous")) oCol.nueva("REPEAT_ORDER", _("Order"), 100, siCentrado=True, edicion=Delegados.ComboBox(self.liREPEATtxt)) self.grid_repeat = Grid.Grid(self, oCol, siSelecFilas=True, siEditable=True, xid="r") self.grid_repeat.setMinimumWidth(self.grid_repeat.anchoColumnas() + 20) ly = Colocacion.V().control(tb).control(self.grid_repeat) gbRepeat = Controles.GB(self, _("Blocks"), ly).ponFuente(f) self.grid_repeat.gotop() # Penalizaciones if regHistorico: self.liPENAL = regHistorico["PENALIZATION"][:] else: self.liPENAL = tactica.PENALIZATION[:] tb = tbGen("penal") oCol = Columnas.ListaColumnas() oCol.nueva("NUMERO", _("N."), 20, siCentrado=True) oCol.nueva("PENAL_POSITIONS", _("Positions"), 100, siCentrado=True, edicion=Delegados.LineaTexto(siEntero=True)) oCol.nueva("PENAL_%", _("Affected"), 100, siCentrado=True) self.grid_penal = Grid.Grid(self, oCol, siSelecFilas=True, siEditable=True, xid="p") self.grid_penal.setMinimumWidth(self.grid_penal.anchoColumnas() + 20) ly = Colocacion.V().control(tb).control(self.grid_penal) gbPenal = Controles.GB(self, _("Penalties"), ly).ponFuente(f) self.grid_penal.gotop() # ShowText if regHistorico: self.liSHOWTEXT = regHistorico["SHOWTEXT"][:] else: self.liSHOWTEXT = tactica.SHOWTEXT[:] tb = tbGen("show") oCol = Columnas.ListaColumnas() self.liSHOWTEXTtxt = (_("No"), _("Yes")) oCol.nueva("NUMERO", _("N."), 20, siCentrado=True) oCol.nueva("SHOW_VISIBLE", _("Visible"), 100, siCentrado=True, edicion=Delegados.ComboBox(self.liSHOWTEXTtxt)) oCol.nueva("SHOW_%", _("Affected"), 100, siCentrado=True) self.grid_show = Grid.Grid(self, oCol, siSelecFilas=True, siEditable=True, xid="s") self.grid_show.setMinimumWidth(self.grid_show.anchoColumnas() + 20) ly = Colocacion.V().control(tb).control(self.grid_show) gbShow = Controles.GB(self, _("Show text associated with each puzzle"), ly).ponFuente(f) self.grid_show.gotop() # Files if regHistorico: self.liFILES = regHistorico["FILESW"][:] else: self.liFILES = [] for num, (fich, w, d, h) in enumerate(tactica.filesw): if not d or d < 1: d = 1 if not h or h > self.liFTOTAL[num] or h < 1: h = self.liFTOTAL[num] if d > h: d, h = h, d self.liFILES.append([fich, w, d, h]) oCol = Columnas.ListaColumnas() oCol.nueva("FILE", _("File"), 220, siCentrado=True) oCol.nueva("WEIGHT", _("Weight"), 100, siCentrado=True, edicion=Delegados.LineaTexto(siEntero=True)) oCol.nueva("TOTAL", _("Total"), 100, siCentrado=True) oCol.nueva("FROM", _("From"), 100, siCentrado=True, edicion=Delegados.LineaTexto(siEntero=True)) oCol.nueva("TO", _("To"), 100, siCentrado=True, edicion=Delegados.LineaTexto(siEntero=True)) self.grid_files = Grid.Grid(self, oCol, siSelecFilas=True, siEditable=True, xid="f") self.grid_files.setMinimumWidth(self.grid_files.anchoColumnas() + 20) ly = Colocacion.V().control(self.grid_files) gbFiles = Controles.GB(self, _("FNS files"), ly).ponFuente(f) self.grid_files.gotop() # Layout lyReference = Colocacion.H().control(lbReference).control(self.edReference) lyPuzzles = Colocacion.H().control(lbPuzzles).control(self.sbPuzzles) ly = Colocacion.G() ly.otro(lyPuzzles, 0, 0).otro(lyReference, 0, 1) ly.filaVacia(1, 5) ly.controld(gbJumps, 2, 0).control(gbPenal, 2, 1) ly.filaVacia(3, 5) ly.controld(gbRepeat, 4, 0) ly.control(gbShow, 4, 1) ly.filaVacia(5, 5) ly.control(gbFiles, 6, 0, 1, 2) layout = Colocacion.V().espacio(10).otro(ly) self.setLayout(layout) self.grid_repeat.gotop()
def __init__(self, owner, configuration, opening_block): icono = Iconos.Opening() titulo = _("Select an opening") extparam = "selectOpening" QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) # Variables-------------------------------------------------------------------------- self.apStd = OpeningsStd.apTrain self.configuration = configuration self.game = Game.Game() self.opening_block = opening_block self.liActivas = [] # Board config_board = configuration.config_board("APERTURAS", 32) self.board = Board.Board(self, config_board) self.board.crea() self.board.set_dispatcher(self.player_has_moved) # Current pgn self.lbPGN = Controles.LB(self, "").set_wrap().ponTipoLetra(puntos=10, peso=75) # Movimiento self.is_moving_time = False lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, icon_size=24) self.tbBM = tbBM # Tool bar tb = Controles.TBrutina(self) tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar) tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar) tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida) tb.new(_("Takeback"), Iconos.Atras(), self.atras) tb.new(_("Remove"), Iconos.Borrar(), self.borrar) # Lista Openings o_columns = Columnas.ListaColumnas() dicTipos = { "b": Iconos.pmSun(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja() } o_columns.nueva("TYPE", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos)) o_columns.nueva("OPENING", _("Possible continuation"), 480) self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, altoFila=32) self.register_grid(self.grid) # # Derecha lyD = Colocacion.V().control(tb).control(self.grid) gbDerecha = Controles.GB(self, "", lyD) # # Izquierda lyI = Colocacion.V().control(self.board).otro(lyBM).control(self.lbPGN) gbIzquierda = Controles.GB(self, "", lyI) splitter = QtWidgets.QSplitter(self) splitter.addWidget(gbIzquierda) splitter.addWidget(gbDerecha) self.register_splitter(splitter, "splitter") # Completo ly = Colocacion.H().control(splitter).margen(3) self.setLayout(ly) self.ponActivas() self.resetPartida() self.actualizaPosicion() dic = {"_SIZE_": "916,444", "SP_splitter": [356, 548]} self.restore_video(dicDef=dic)