def __init__(self, owner, procesador): title = _("In one line") titulo = _("Turn on the lights") + ": " + title extparam = "tolconfoneline" icono = Iconos.TOLchange() QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) self.tol = TurnOnLights.read_oneline_tol() self.procesador = procesador lbNumPos = Controles.LB2P(self, _("Number of positions")) liBlocks = [(str(x), x) for x in range(6, 60, 6)] self.cbNumPos = Controles.CB(self, liBlocks, self.tol.num_pos) lbtipo = Controles.LB2P(self, _("Mode")) liTipos = [(_("Calculation mode"), True), (_("Memory mode"), False)] self.cbTipo = Controles.CB(self, liTipos, self.tol.calculation_mode) lbfile = Controles.LB2P(self, _("File")) pbfile = Controles.PB(self, "", self.newfile).ponIcono(Iconos.Buscar()) self.lbshowfile = Controles.LB(self, self.tol.fns) lyfile = Colocacion.H().control(pbfile).control( self.lbshowfile).relleno(1) self.chbauto = Controles.CHB(self, _("Redo each day automatically"), self.tol.auto_day) tb = Controles.TBrutina(self) tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar) tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar) # Colocamos --------------------------------------------------------------- ly = Colocacion.G() ly.controld(lbNumPos, 1, 0).control(self.cbNumPos, 1, 1) ly.controld(lbtipo, 2, 0).control(self.cbTipo, 2, 1) ly.controld(lbfile, 3, 0).otro(lyfile, 3, 1) ly.control(self.chbauto, 4, 0, 1, 2) layout = Colocacion.V().control(tb).espacio(10).otro(ly) self.setLayout(layout) self.recuperarVideo(siTam=True)
def __init__(self, owner, theme, your_themes): super(WNameTheme, self).__init__(owner) self.theme = theme li_sections = [theme["SECCION"] for theme in your_themes if "SECCION" in theme] self.li_sections = list(set(li_sections)) self.li_sections.sort() self.setWindowTitle(_("Theme")) self.setWindowIcon(Iconos.Temas()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) lb_name = Controles.LB2P(self, _("Name")) self.ed_name = Controles.ED(self, theme.get("NOMBRE", "")) ly_name = Colocacion.H().control(lb_name).control(self.ed_name) lb_section = Controles.LB2P(self, _("Section")) self.ed_section = Controles.ED(self, theme.get("SECCION", "")) bt_section = Controles.PB(self, "", self.mira_section).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Section lists")) ly_section = Colocacion.H().control(lb_section).control(self.ed_section).espacio(-10).control(bt_section).relleno(1) self.chb_pieces_set = Controles.CHB(self, _("Change piece set"), theme.get("CHANGE_PIECES", True)) li_acciones = [(_("Save"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None] self.tb = QTVarios.LCTB(self, li_acciones) layout = Colocacion.V().control(self.tb).espacio(16) layout.otro(ly_name).espacio(16) layout.otro(ly_section).espacio(16) layout.control(self.chb_pieces_set) layout.margen(6) self.setLayout(layout) self.ed_name.setFocus() if not self.li_sections: bt_section.hide()
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.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = configuracion self.personalidades = Personalidades.Personalidades(self, configuracion) # Toolbar li_acciones = [ (_("Accept"), Iconos.Aceptar(), "aceptar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, ] tb = Controles.TB(self, li_acciones) # Blancas o negras self.rbBlancas = Controles.RB(self, _("White")).activa() self.rbNegras = Controles.RB(self, _("Black")) # Motores self.motores = SelectEngines.SelectEngines(configuracion) liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) # # Rival self.rival = configuracion.x_rival_inicial self.rivalTipo = SelectEngines.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, ADJUST_BETTER).capturaCambiado(self.ajustesCambiado) lbAjustarRival = Controles.LB2P(self, _("Set strength")) self.btAjustarRival = Controles.PB(self, "", self.cambiaPersonalidades, plano=False).ponIcono( Iconos.Nuevo(), tamIcon=16 ) self.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) # #Color hAC = Colocacion.H().control(gbColor) # 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(self.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, procesador, titulo, save_at_end): QTVarios.WDialogo.__init__(self, procesador.main_window, titulo, Iconos.Libre(), "entMaquina") font = Controles.TipoLetra(puntos=procesador.configuracion.x_menu_points) self.save_at_end = save_at_end self.setFont(font) self.configuracion = procesador.configuracion self.procesador = procesador self.personalidades = Personalidades.Personalidades(self, self.configuracion) self.motores = SelectEngines.SelectEngines(self.configuracion) # Toolbar li_acciones = [ (_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Configurations"), Iconos.Configurar(), self.configuraciones), None, ] tb = QTVarios.LCTB(self, li_acciones) # Tab tab = Controles.Tab() tab.dispatchChange(self.cambiada_tab) self.tab_advanced = 4 # está en la posición 4 self.tab_advanced_active = ( False ) # Para no tener que leer las opciones uci to_sq que no sean necesarias, afecta a gridNumDatos def nueva_tab(layout, titulo): ly = Colocacion.V() ly.otro(layout) ly.relleno() w = QtWidgets.QWidget(self) w.setLayout(ly) w.setFont(font) tab.nuevaTab(w, titulo) def nuevoG(): ly_g = Colocacion.G() ly_g.filaActual = 0 ly_g.setMargin(10) return ly_g 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; padding: 18px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; /* position at the top center */ padding: 8px; border: 1px solid gray; } """ def _label(ly_g, txt, xlayout, rutinaCHB=None, siCheck: object = False): groupbox = Controles.GB(self, txt, xlayout) if rutinaCHB: groupbox.conectar(rutinaCHB) elif siCheck: groupbox.setCheckable(True) groupbox.setChecked(False) groupbox.setStyleSheet(gbStyle) groupbox.setMinimumWidth(640) groupbox.setFont(font) ly_g.controlc(groupbox, ly_g.filaActual, 0) ly_g.filaActual += 1 return groupbox # ################################################################################################################################## # TAB General # ################################################################################################################################## lyG = nuevoG() # # Motores # ## Rival self.rival = self.procesador.XTutor().confMotor self.rivalTipo = SelectEngines.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False).ponFuente(font).altoFijo(48) lbTiempoSegundosR = Controles.LB2P(self, _("Fixed time in seconds")).ponFuente(font) self.edRtiempo = ( Controles.ED(self).tipoFloat().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoTiempo) ) bt_cancelar_tiempo = Controles.PB(self, "", rutina=self.cancelar_tiempo).ponIcono(Iconos.S_Cancelar()) ly_tiempo = Colocacion.H().control(self.edRtiempo).control(bt_cancelar_tiempo).relleno(1) lb_depth = Controles.LB2P(self, _("Fixed depth")).ponFuente(font) self.edRdepth = Controles.ED(self).tipoInt().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoDepth) bt_cancelar_depth = Controles.PB(self, "", rutina=self.cancelar_depth).ponIcono(Iconos.S_Cancelar()) ly_depth = Colocacion.H().control(self.edRdepth).control(bt_cancelar_depth).relleno(1) ly = Colocacion.G() ly.controld(lbTiempoSegundosR, 0, 0).otro(ly_tiempo, 0, 1) ly.controld(lb_depth, 1, 0).otro(ly_depth, 1, 1) self.gb_thinks = Controles.GB(self, _("Limits of engine thinking"), ly) self.gb_thinks.setStyleSheet( """ QGroupBox { font: bold %d; 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; padding: 18px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-position: top center; /* position at the top center */ padding: 8px; border: 1px solid gray; } """ % procesador.configuracion.x_menu_points ) lyV = Colocacion.V().espacio(20).control(self.btRival).espacio(20).control(self.gb_thinks) _label(lyG, _("Opponent"), lyV) # # Color self.rbBlancas = Controles.RB(self, "").activa() self.rbBlancas.setIcon(Iconos.PeonBlanco()) self.rbBlancas.setIconSize(QtCore.QSize(32, 32)) self.rbNegras = Controles.RB(self, "") self.rbNegras.setIcon(Iconos.PeonNegro()) self.rbNegras.setIconSize(QtCore.QSize(32, 32)) self.rbRandom = Controles.RB(self, _("Random")) self.rbRandom.setFont(Controles.TipoLetra(puntos=16)) hbox = ( Colocacion.H() .relleno() .control(self.rbBlancas) .espacio(30) .control(self.rbNegras) .espacio(30) .control(self.rbRandom) .relleno() ) _label(lyG, _("Side you play with"), hbox) nueva_tab(lyG, _("Basic configuration")) # ################################################################################################################################## # TAB Ayudas # ################################################################################################################################## self.chbSummary = Controles.CHB( self, _("Save a summary when the game is finished in the main comment"), False ).ponFuente(font) self.chbTakeback = Controles.CHB( self, _("Option takeback activated"), True ).ponFuente(font) # # Tutor lbAyudas = Controles.LB2P(self, _("Available hints")).ponFuente(font) liAyudas = [(_("Maximum"), 999)] for i in range(1, 21): liAyudas.append((str(i), i)) for i in range(25, 51, 5): liAyudas.append((str(i), i)) self.cbAyudas = Controles.CB(self, liAyudas, 999).ponFuente(font) self.chbChance = Controles.CHB(self, _("Second chance"), True).ponFuente(font) btTutorChange = ( Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False) .ponIcono(Iconos.Tutor(), tamIcon=16) .ponFuente(font) ) 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)) lbThoughtTt = Controles.LB(self, _("It is showed") + ":").ponFuente(font) self.cbThoughtTt = Controles.CB(self, liThinks, -1).ponFuente(font) self.chbContinueTt = Controles.CHB(self, _("The tutor thinks while you think"), True).ponFuente(font) lbBoxHeight = Controles.LB2P(self, _("Box height")).ponFuente(font) self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font) lbArrows = Controles.LB2P(self, _("Arrows with the best moves")).ponFuente(font) self.sbArrowsTt = Controles.SB(self, 3, 0, 999).tamMaximo(50).ponFuente(font) lyT1 = Colocacion.H().control(lbAyudas).control(self.cbAyudas).relleno() lyT1.control(self.chbChance).relleno().control(btTutorChange) lyT2 = Colocacion.H().control(self.chbContinueTt).relleno() lyT2.control(lbBoxHeight).control(self.sbBoxHeight).relleno() lyT3 = Colocacion.H().control(lbThoughtTt).control(self.cbThoughtTt).relleno() lyT3.control(lbArrows).control(self.sbArrowsTt) ly = Colocacion.V().otro(lyT1).espacio(16).otro(lyT2).otro(lyT3).relleno() self.gbTutor = Controles.GB(self, _("Activate the tutor's help"), ly) self.gbTutor.setCheckable(True) self.gbTutor.setStyleSheet(gbStyle) lb = Controles.LB(self, _("It is showed") + ":").ponFuente(font) self.cbThoughtOp = Controles.CB(self, liThinks, -1).ponFuente(font) lbArrows = Controles.LB2P(self, _("Arrows to show")).ponFuente(font) self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font) ly = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno() ly.control(lbArrows).control(self.sbArrows).relleno() gbThoughtOp = Controles.GB(self, _("Opponent's thought information"), ly) gbThoughtOp.setStyleSheet(gbStyle) ly = Colocacion.V().espacio(16).control(self.gbTutor).control(gbThoughtOp) ly.espacio(16).control(self.chbSummary).control(self.chbTakeback).margen(6) nueva_tab(ly, _("Help configuration")) # ################################################################################################################################## # TAB Tiempo # ################################################################################################################################## lyG = nuevoG() self.lbMinutos = Controles.LB(self, _("Total minutes") + ":").ponFuente(font) self.edMinutos = Controles.ED(self).tipoFloat(10.0).ponFuente(font).anchoFijo(50) self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB( self, 6, -999, 999, maxTam=54, etiqueta=_("Seconds added per move"), fuente=font ) self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=70, etiqueta=_("Extra minutes for the player"), fuente=font ) self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=54, etiqueta=_("Zeitnot: alarm sounds when remaining seconds"), fuente=font ) lyH = Colocacion.H() lyH.control(self.lbMinutos).control(self.edMinutos).espacio(30) lyH.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(lyH).otro(lyH2).otro(lyH3) self.chbTiempo = _label(lyG, _("Activate the time control"), ly, siCheck=True) nueva_tab(lyG, _("Time")) # ################################################################################################################################## # TAB Initial moves # ################################################################################################################################## lyG = nuevoG() # Posicion self.btPosicion = ( Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False).ponFuente(font) ) self.fen = "" self.btPosicionQuitar = Controles.PB(self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()).ponFuente(font) self.btPosicionPegar = ( Controles.PB(self, "", self.posicionPegar).ponIcono(Iconos.Pegar16()).ponToolTip(_("Paste FEN position")) ).ponFuente(font) 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) .ponFuente(font) ) 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.restore_pickle(fvar) self.listaLibros.comprueba() li_books = [(x.name, x) for x in self.listaLibros.lista] libInicial = li_books[0][1] if li_books else None li_resp_book = [ (_("Selected by the player"), "su"), (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ] ## Rival self.cbBooksR = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font) self.btNuevoBookR = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.cbBooksRR = QTUtil2.comboBoxLB(self, li_resp_book, "mp").ponFuente(font) self.lbDepthBookR = Controles.LB2P(self, _("Max depth")).ponFuente(font) self.edDepthBookR = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30) hbox = ( Colocacion.H() .control(self.cbBooksR) .control(self.btNuevoBookR) .relleno() .control(self.cbBooksRR) .relleno() .control(self.lbDepthBookR) .control(self.edDepthBookR) ) self.chbBookR = _label(lyG, "%s: %s" % (_("Activate book"), _("Opponent")), hbox, siCheck=True) ## Player self.cbBooksP = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font) self.btNuevoBookP = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.lbDepthBookP = Controles.LB2P(self, _("Max depth")).ponFuente(font) self.edDepthBookP = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30) hbox = ( Colocacion.H() .control(self.cbBooksP) .control(self.btNuevoBookP) .relleno() .control(self.lbDepthBookP) .control(self.edDepthBookP) ) self.chbBookP = _label( lyG, "%s: %s" % (_("Activate book"), self.configuracion.nom_player()), hbox, siCheck=True ) nueva_tab(lyG, _("Initial moves")) # ################################################################################################################################## # TAB avanzada # ################################################################################################################################## lyG = nuevoG() liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = ( Controles.CB(self, liAjustes, ADJUST_BETTER).capturaCambiado(self.ajustesCambiado).ponFuente(font) ) lbAjustarRival = Controles.LB2P(self, _("Set strength")).ponFuente(font) self.btAjustarRival = ( Controles.PB(self, _("Personality"), self.cambiaPersonalidades, plano=True) .ponIcono(Iconos.Mas(), tamIcon=16) .ponFuente(font) ) # ## Resign lbResign = Controles.LB2P(self, _("Resign/draw by engine")).ponFuente(font) liResign = ( (_("Very early"), -100), (_("Early"), -300), (_("Average"), -500), (_("Late"), -800), (_("Very late"), -1000), (_("Never"), -9999999), ) self.cbResign = Controles.CB(self, liResign, -800).ponFuente(font) self.lb_path_engine = Controles.LB(self, "").ponWrap() o_columns = Columnas.ListaColumnas() o_columns.nueva("OPTION", _("UCI option"), 240, centered=True) o_columns.nueva("VALUE", _("Value"), 200, centered=True, edicion=Delegados.MultiEditor(self)) self.grid_uci = Grid.Grid(self, o_columns, siEditable=True) self.grid_uci.ponFuente(font) self.register_grid(self.grid_uci) lyH2 = ( Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(self.btAjustarRival).relleno() ) lyH3 = Colocacion.H().control(lbResign).control(self.cbResign).relleno() ly = Colocacion.V().otro(lyH2).otro(lyH3).espacio(16).control(self.lb_path_engine).control(self.grid_uci) _label(lyG, _("Opponent"), ly) nueva_tab(lyG, _("Advanced")) layout = Colocacion.V().control(tb).control(tab).relleno().margen(3) self.setLayout(layout) self.liAperturasFavoritas = [] self.btAperturasFavoritas.hide() dic = Util.restore_pickle(self.configuracion.ficheroEntMaquina) if not dic: dic = {} self.restore_dic(dic) self.ajustesCambiado() # self.ayudasCambiado() self.ponRival() self.restore_video()
def __init__(self, procesador, titulo): QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, Iconos.Libre(), "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, wParent, nombre_torneo): torneo = self.torneo = Tournament.Tournament(nombre_torneo) titulo = nombre_torneo icono = Iconos.Torneos() extparam = "untorneo_v1" QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam) self.configuracion = Code.configuracion # Datos self.liEnActual = [] self.xjugar = None self.liResult = None self.last_change = Util.today() self.li_results = [] # Toolbar tb = Controles.TBrutina(self, tamIcon=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-configuracion -------------------------------------------------- w = QtWidgets.QWidget() # Adjudicator lb_resign = Controles.LB( self, "%s (%s): " % (_("Minimum centipawns to assign winner"), _("0=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=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.configuracion.comboMotoresMultiPV10() self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB( self, self.liMotores, torneo.adjudicator(), _("Engine")) self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat( 1.0).anchoFijo(50).ponFloat(torneo.adjudicator_time()) 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.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.restore_pickle(fvar) # Comprobamos que todos esten accesibles self.listaLibros.comprueba() li = [(x.name, x.path) for x in self.listaLibros.lista] li.insert(0, ("* " + _("None"), "-")) self.cbBooks = Controles.CB(self, li, torneo.book()) btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=False).ponIcono(Iconos.Nuevo(), tamIcon=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) # 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) 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, tamIcon=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, tamIcon=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, ] tbEnGt = Controles.TBrutina(self, li_acciones, tamIcon=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.setposition("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.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.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.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.chContrario).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, 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, w_parent, listaMotores, engine, siTorneo=False): super(WEngine, self).__init__(w_parent) self.setWindowTitle(engine.version) self.setWindowIcon(Iconos.Motor()) self.setWindowFlags( QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowMaximizeButtonHint ) scrollArea = wgen_options_engine(self, engine) self.motorExterno = engine self.liMotores = listaMotores self.siTorneo = siTorneo # Toolbar tb = QTUtil2.tbAcceptCancel(self) lbAlias = Controles.LB2P(self, _("Alias")) self.edAlias = Controles.ED(self, engine.key).anchoMinimo(360) lbNombre = Controles.LB2P(self, _("Name")) self.edNombre = Controles.ED(self, engine.name).anchoMinimo(360) lbInfo = Controles.LB(self, _("Information") + ": ") self.emInfo = Controles.EM(self, engine.id_info, siHTML=False).anchoMinimo(360).altoFijo(60) lbElo = Controles.LB(self, "ELO: ") self.sbElo = Controles.SB(self, engine.elo, 0, 4000) lbExe = Controles.LB(self, "%s: %s" % (_("File"), Util.relative_path(engine.path_exe))) if siTorneo: lbDepth = Controles.LB(self, _("Maximum depth") + ": ") self.sbDepth = Controles.SB(self, engine.depth, 0, 50) lbTime = Controles.LB(self, _("Maximum seconds to think") + ": ") self.sbTime = Controles.SB(self, engine.time, 0, 9999) lbBook = Controles.LB(self, _("Opening book") + ": ") fvar = Code.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"), "-")) li.insert(0, ("* " + _("Default"), "*")) self.cbBooks = Controles.CB(self, li, engine.book) btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=False).ponIcono(Iconos.Nuevo(), icon_size=16) # # Respuesta rival li = ( (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ) self.cbBooksRR = QTUtil2.comboBoxLB(self, li, engine.bookRR) lyBook = ( Colocacion.H() .control(lbBook) .control(self.cbBooks) .control(self.cbBooksRR) .control(btNuevoBook) .relleno() ) lyDT = ( Colocacion.H() .control(lbDepth) .control(self.sbDepth) .espacio(40) .control(lbTime) .control(self.sbTime) .relleno() ) lyTorneo = Colocacion.V().otro(lyDT).otro(lyBook) # Layout ly = Colocacion.G() ly.controld(lbAlias, 0, 0).control(self.edAlias, 0, 1) ly.controld(lbNombre, 1, 0).control(self.edNombre, 1, 1) ly.controld(lbInfo, 2, 0).control(self.emInfo, 2, 1) ly.controld(lbElo, 3, 0).control(self.sbElo, 3, 1) ly.control(lbExe, 4, 0, 1, 2) if siTorneo: ly.otro(lyTorneo, 5, 0, 1, 2) layout = Colocacion.V().control(tb).espacio(30).otro(ly).control(scrollArea) self.setLayout(layout) self.edAlias.setFocus()
def __init__(self, owner, configuracion, dic_data): super(WOptionsDatabase, self).__init__(owner) self.new = len(dic_data) == 0 self.dic_data = dic_data self.dic_data_resp = None def d_str(key): return dic_data.get(key, "") def d_true(key): return dic_data.get(key, True) def d_false(key): return dic_data.get(key, False) title = _("New database") if len(dic_data) == 0 else "%s: %s" % (_("Database"), d_str("NAME")) self.setWindowTitle(title) self.setWindowIcon(Iconos.DatabaseMas()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = configuracion self.resultado = None valid_rx = r'^[^<>:;,?"*|/\\]+' lb_name = Controles.LB2P(self, _("Name")) self.ed_name = Controles.ED(self, d_str("NAME")).controlrx(valid_rx) ly_name = Colocacion.H().control(lb_name).control(self.ed_name) folder = os.path.dirname(Util.relative_path(d_str("FILEPATH"))) folder = folder[len(configuracion.folder_databases()):] if folder.strip(): folder = folder.strip(os.sep) li = folder.split(os.sep) nli = len(li) group = li[0] subgroup1 = li[1] if nli > 1 else "" subgroup2 = li[2] if nli > 2 else "" else: group = "" subgroup1 = "" subgroup2 = "" lb_group = Controles.LB2P(self, _("Group")) self.ed_group = Controles.ED(self, group).controlrx(valid_rx) self.bt_group = ( Controles.PB(self, "", self.mira_group).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists")) ) ly_group = ( Colocacion.H().control(lb_group).control(self.ed_group).espacio(-10).control(self.bt_group).relleno(1) ) lb_subgroup_l1 = Controles.LB2P(self, _("Subgroup")) self.ed_subgroup_l1 = Controles.ED(self, subgroup1).controlrx(valid_rx) self.bt_subgroup_l1 = ( Controles.PB(self, "", self.mira_subgroup_l1).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists")) ) ly_subgroup_l1 = ( Colocacion.H() .espacio(40) .control(lb_subgroup_l1) .control(self.ed_subgroup_l1) .espacio(-10) .control(self.bt_subgroup_l1) .relleno(1) ) lb_subgroup_l2 = Controles.LB2P(self, "%s → %s" % (_("Subgroup"), _("Subgroup"))) self.ed_subgroup_l2 = Controles.ED(self, subgroup2).controlrx(valid_rx) self.bt_subgroup_l2 = ( Controles.PB(self, "", self.mira_subgroup_l2).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists")) ) ly_subgroup_l2 = ( Colocacion.H() .espacio(40) .control(lb_subgroup_l2) .control(self.ed_subgroup_l2) .espacio(-10) .control(self.bt_subgroup_l2) .relleno(1) ) x1 = -8 ly_group = Colocacion.V().otro(ly_group).espacio(x1).otro(ly_subgroup_l1).espacio(x1).otro(ly_subgroup_l2) gb_group = Controles.GB(self, "%s (%s)" % (_("Group"), "optional"), ly_group) lb_summary = Controles.LB2P(self, _("Summary depth (0=disable)")) self.sb_summary = Controles.SB(self, dic_data.get("SUMMARY_DEPTH", 12), 0, 999) ly_summary = Colocacion.H().control(lb_summary).control(self.sb_summary).relleno(1) self.external_folder = d_str("EXTERNAL_FOLDER") lb_external = Controles.LB2P(self, _("Store in an external folder")) self.bt_external = Controles.PB(self, self.external_folder, self.select_external, False) self.bt_external.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) ) ly_external = Colocacion.H().control(lb_external).control(self.bt_external) self.chb_complete = Controles.CHB(self, _("Allow complete games"), d_true("ALLOWS_COMPLETE_GAMES")) self.chb_positions = Controles.CHB(self, _("Allow positions"), d_true("ALLOWS_POSITIONS")) self.chb_duplicate = Controles.CHB(self, _("Allow duplicates"), d_false("ALLOWS_DUPLICATES")) self.chb_zeromoves = Controles.CHB(self, _("Allow without moves"), d_false("ALLOWS_ZERO_MOVES")) ly_res = ( Colocacion.V() .controlc(self.chb_complete) .controlc(self.chb_positions) .controlc(self.chb_duplicate) .controlc(self.chb_zeromoves) ) gb_restrictions = Controles.GB(self, _("Import restrictions"), ly_res) li_acciones = [ (_("Save"), Iconos.Aceptar(), self.save), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None, ] self.tb = QTVarios.LCTB(self, li_acciones) x0 = 16 layout = Colocacion.V().control(self.tb).espacio(x0) layout.otro(ly_name).espacio(x0).control(gb_group).espacio(x0) layout.otro(ly_summary).espacio(x0) layout.otro(ly_external).espacio(x0) layout.control(gb_restrictions) layout.margen(9) self.setLayout(layout) self.ed_name.setFocus()