def borrarPersonal(self): tgm = self.cbPersonal.valor() if tgm is None: return if not QTUtil2.pregunta(self, _X(_("Delete %1?"), tgm)): return base = os.path.join(self.configuracion.dirPersonalTraining, "%s.gm" % tgm) for x in "wbi": Util.borraFichero(base + x) self.liPersonal = GM.listaGMpersonal(self.configuracion.dirPersonalTraining) li = [(x[0], x[1]) for x in self.liPersonal] li.insert(0, ("-", None)) self.cbPersonal.rehacer(li, li[0][1]) self.compruebaP()
def borrarPersonal(self): tgm = self.cbPersonal.valor() if tgm is None: return if not QTUtil2.pregunta(self, _X(_("Delete %1?"), tgm)): return base = os.path.join(self.configuracion.dirPersonalTraining, "%s.gm" % tgm) for x in "wbi": Util.borraFichero(base + x) self.liPersonal = GM.listaGMpersonal(self.configuracion.dirPersonalTraining) li = [(x[0], x[1] ) for x in self.liPersonal] li.insert(0, ("-", None)) self.cbPersonal.rehacer(li, li[0][1]) self.compruebaP()
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): 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(), "aceptar" ), None, ( _("Cancel"), Iconos.Cancelar(), "cancelar" ), None, ( _("One game"), Iconos.Uno(), "unJuego" ), None, ( _("Import"), Iconos.ImportarGM(), "importar" ) ] tb = Controles.TB(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")) 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).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)