def seek_folder(submenu, folder): for entry in os.scandir(folder): if entry.is_dir(): smenu = submenu.submenu(entry.name, Iconos.Carpeta()) seek_folder(smenu, entry.path) for entry in os.scandir(folder): if entry.is_file() and entry.name.lower().endswith(".svg"): ico = QTVarios.fsvg2ico(entry.path, 32) if ico: submenu.opcion(entry.path, entry.name[:-4], ico)
def miraDir(submenu, base, dr): if base: pathCarpeta = base + dr + "/" smenu = submenu.submenu(dr, Iconos.Carpeta()) else: pathCarpeta = dr + "/" smenu = submenu li = [] for fich in os.listdir(pathCarpeta): pathFich = pathCarpeta + fich if os.path.isdir(pathFich): miraDir(smenu, pathCarpeta, fich) elif pathFich.lower().endswith(".svg"): li.append((pathFich, fich)) for pathFich, fich in li: ico = QTVarios.fsvg2ico(pathFich, 32) if ico: smenu.opcion(pathFich, fich[:-4], ico)
def __init__(self, wParent): QtGui.QWidget.__init__(self, wParent) self.wParent = wParent self.jg = None self.partida = None configuracion = VarGen.configuracion puntos = configuracion.puntosPGN f = Controles.TipoLetra(puntos=puntos, peso=75) 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) btNAGS = Controles.PB(self, "", self.masNAGs).ponIcono(Iconos.Mas()).anchoFijo(22) 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]).control(btNAGS) 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).margen(3) self.gbComentario = Controles.GB(self, _("Comments"), ly).ponFuente(f) # Variantes self.variantes = Variantes(self) self.splitter = splitter = QtGui.QSplitter(self) self.splitter.setOrientation(QtCore.Qt.Vertical) splitter.addWidget(self.gbComentario) splitter.addWidget(self.variantes) layout = Colocacion.V() layout.control(self.lbApertura) layout.control(self.gbValoracion) layout.control(self.splitter) layout.margen(1) self.setLayout(layout)
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 ico(num_nag, tam): path = Code.path_resource("IntFiles", "NAGs", "$%d.svg" % num_nag) return QTVarios.fsvg2ico(path, tam)
def __init__(self, w_parent): QtWidgets.QWidget.__init__(self, w_parent) self.w_parent = w_parent self.move = None self.game = None configuration = Code.configuration puntos = configuration.x_pgn_fontpoints f = Controles.TipoLetra(puntos=puntos, peso=75) f9 = Controles.TipoLetra(puntos=puntos) ftxt = f9 # Opening self.lb_opening = (Controles.LB( self, "").ponFuente(f).align_center().set_foreground_backgound( "#eeeeee", "#474d59").set_wrap()) self.lb_opening.hide() # Valoracion li_options = [("-", None)] dic_nags = TrListas.dic_nags() nags_folder = Code.path_resource("IntFiles", "NAGs") ico_vacio = QTVarios.fsvg2ico("%s/$0.svg" % (nags_folder, ), 16) for x in dic_nags: if x: fsvg = "%s/$%d.svg" % (nags_folder, x) if os.path.isfile(fsvg): li_options.append(("$%d : %s" % (x, dic_nags[x]), x, QTVarios.fsvg2ico(fsvg, 16))) else: li_options.append( ("$%d : %s" % (x, dic_nags[x]), x, ico_vacio)) self.max_nags = 10 self.li_nags = [] for x in range(self.max_nags): cb = (Controles.CB(self, li_options, "").set_widthMinimo().capture_changes( self.valoration_changed).ponFuente(f9)) if x: cb.hide() self.li_nags.append(cb) bt_nags = Controles.PB(self, "", self.more_nags).ponIcono( Iconos.Mas()).anchoFijo(22) ly_h = Colocacion.H().control(self.li_nags[0]).control(bt_nags) ly = Colocacion.V().otro(ly_h) for x in range(1, self.max_nags): ly.control(self.li_nags[x]) self.gbValoracion = Controles.GB(self, _("Rating"), ly).ponFuente(f) # Comentarios self.comment = (Controles.EM(self, siHTML=False).capturaCambios( self.comment_changed).ponFuente(ftxt).anchoMinimo(200)) ly = Colocacion.H().control(self.comment).margen(3) self.gb_comments = Controles.GB(self, _("Comments"), ly).ponFuente(f) # Variations self.variantes = WVariations(self) self.splitter = splitter = QtWidgets.QSplitter(self) self.splitter.setOrientation(QtCore.Qt.Vertical) splitter.addWidget(self.gb_comments) splitter.addWidget(self.variantes) splitter.setSizes([1, 1]) layout = Colocacion.V() layout.control(self.lb_opening) layout.control(self.gbValoracion) layout.control(self.splitter) layout.margen(1) self.setLayout(layout) self.setMinimumWidth(220)
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(), self.tbMasVariante), None, ("%s+%s" % (_("Append"), _("Engine")), Iconos.MasR(), self.tbMasVarianteR), None, (_("Edit"), Iconos.ComentarioEditar(), self.tbEditarVariante), None, (_("Remove"), Iconos.Borrar(), self.tbBorrarVariante), None, ) tbVariantes = Controles.TBrutina(self, liAcciones, siTexto=False, tamIcon=16) self.variantes = Controles.EM(self, siHTML=False).capturaCambios( self.variantesCambiado).ponFuente(ftxt) self.variantes.capturaDobleClick(self.variantesDobleClick) self.variantes.setReadOnly(True) ly = Colocacion.V().control(tbVariantes).control(self.variantes) self.gbVariantes = Controles.GB(self, _("Variants"), ly).ponFuente(f) self.splitter = splitter = QtGui.QSplitter(self) self.splitter.setOrientation(QtCore.Qt.Vertical) splitter.addWidget(self.gbComentario) splitter.addWidget(self.gbVariantes) layout = Colocacion.V() layout.control(self.lbApertura) layout.control(self.gbValoracion) layout.control(self.splitter) # layout.control(self.gbComentario) # layout.control(self.gbVariantes) layout.margen(5) self.setLayout(layout)
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): 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)