def __init__(self, wParent, procesador): icono = Iconos.DatabaseC() extparam = "database" titulo = _("Database of complete games") QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam) self.procesador = procesador self.configuracion = procesador.configuracion self.dbGames = DBgames.DBgames(self.configuracion.ficheroDBgames) dicVideo = self.recuperarDicVideo() self.bookGuide = BookGuide.BookGuide(self) self.wsummary = WBG_Summary.WSummary(procesador, self, self.dbGames, siMoves=False) self.wgames = WBG_Games.WGames(procesador, self, self.dbGames, self.wsummary, siMoves=False) self.registrarGrid(self.wsummary.grid) self.registrarGrid(self.wgames.grid) self.ultFocus = None self.tab = Controles.Tab() self.tab.nuevaTab(self.wgames, _("Games")) self.tab.nuevaTab(self.wsummary, _("Summary")) self.tab.dispatchChange(self.tabChanged) self.tab.ponTipoLetra(puntos=procesador.configuracion.puntosTB) self.infoMove = WBG_InfoMove.WInfomove(self, siMoves=False) self.splitter = splitter = QtGui.QSplitter() splitter.addWidget(self.tab) splitter.addWidget(self.infoMove) layout = Colocacion.H().control(splitter).margen(5) self.setLayout(layout) self.recuperarVideo(anchoDefecto=1200, altoDefecto=600) if not dicVideo: dicVideo = { 'SPLITTER': [800, 380], 'TREE_1': 25, 'TREE_2': 25, 'TREE_3': 50, 'TREE_4': 661, } sz = dicVideo.get("SPLITTER", None) if sz: self.splitter.setSizes(sz) self.inicializa()
def tg_importar_DB(self): path = QTVarios.select_ext(self, "lcg") if not path: return None dlTmp = QTVarios.ImportarFicheroDB(self) dlTmp.show() dbn = DBgames.DBgames(path) self.dbGames.appendDB(dbn, range(dbn.all_reccount()), dlTmp) self.actualiza(True) self.wsummary.reset()
def tg_exportar_DB(self): resp = self.tg_exportar("lcg") if not resp: return li, modo, path = resp if modo == "w" and Util.existeFichero(path): Util.borraFichero(path) Util.borraFichero(path+"_s1") dlTmp = QTVarios.ImportarFicheroDB(self) dlTmp.show() dbn = DBgames.DBgames(path) dbn.appendDB(self.dbGames, li, dlTmp)
def cambiaDBgames(self, fich): self.dbGames.close() self.dbGames = DBgames.DBgames(self.configuracion.ficheroDBgames) self.setdbGames() self.wsummary.actualizaPV("")
def file(self): menu = QTVarios.LCMenu(self) menu.opcion("saveas", _("Save a copy"), Iconos.GrabarComo()) menu.separador() menu.opcion("restorefrom", _("Restore from"), Iconos.Recuperar()) menu.separador() submenu = menu.submenu(_("Create new"), Iconos.Nuevo()) submenu.opcion("new_UNED", _("UNED chess school"), Iconos.Uned()) submenu.separador() submenu.opcion("new_UWE", _("Uwe Auerswald"), Iconos.Uwe()) submenu.separador() submenu.opcion("new_SM", _("Singular moves"), Iconos.Singular()) menu.separador() submenu = menu.submenu(_("Export to"), Iconos.DatabaseMas()) submenu.opcion("save_pgn", _("A PGN file"), Iconos.FichPGN()) submenu.separador() submenu.opcion("save_db", _("Database"), Iconos.DatabaseC()) resp = menu.lanza() if resp is None: return if resp == "saveas": liGen = [(None, None)] config = FormLayout.Editbox(_("Name"), ancho=160) liGen.append((config, "")) resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self, icon=Iconos.GrabarComo()) if resultado: accion, liResp = resultado fich = nombre = liResp[0] if nombre.lower()[-4:] != ".wsm": fich += ".wsm" path = os.path.join(self.configuracion.carpeta, fich) ok = True if Util.existeFichero(path): ok = QTUtil2.pregunta( self, _X( _("The file %1 already exists, what do you want to do?" ), fich), etiSi=_("Overwrite"), etiNo=_("Cancel")) if ok: shutil.copy(self.dbwashing.file, path) elif resp == "restorefrom": li = [] for fich in os.listdir(self.configuracion.carpeta): if fich.endswith(".wsm") and fich != self.dbwashing.filename: li.append(fich[:-4]) if not li: QTUtil2.mensaje(self, _("There is no file")) return menu = QTVarios.LCMenu(self) for fich in li: menu.opcion(fich, fich, Iconos.PuntoRojo()) resp = menu.lanza() if resp: if QTUtil2.pregunta( self, "%s\n%s" % (_("Current data will be removed and overwritten."), _("Are you sure?"))): shutil.copy( os.path.join(self.configuracion.carpeta, resp + ".wsm"), self.dbwashing.file) self.wreload = True self.guardarVideo() self.accept() elif resp.startswith("new_"): tactic = resp[4:] if QTUtil2.pregunta( self, "%s\n%s" % (_("Current data will be removed and overwritten."), _("Are you sure?"))): self.dbwashing.new(tactic) self.wreload = True self.guardarVideo() self.accept() elif resp.startswith("save_"): def other_pc(): for engine in self.washing.liEngines: if engine.state == Washing.ENDED: game = self.dbwashing.restoreGame(engine) pc = Partida.PartidaCompleta() pc.leeOtra(game) dt = engine.date if engine.date else Util.hoy() if engine.color: white = self.configuracion.jugador black = engine.nombre result = "1-0" whiteelo = str(self.configuracion.elo) blackelo = engine.elo else: black = self.configuracion.jugador white = engine.nombre result = "0-1" blackelo = str(self.configuracion.elo) whiteelo = engine.elo tags = [ ["Site", "Lucas Chess"], ["Event", _("The Washing Machine")], ["Date", "%d-%d-%d" % (dt.year, dt.month, dt.day)], ["White", white], ["Black", black], ["WhiteElo", whiteelo], ["BlackElo", blackelo], ["Result", result], ] ap = game.apertura if ap: tags.append(["ECO", ap.eco]) tags.append(["Opening", ap.trNombre]) pc.setTags(tags) yield pc if resp == "save_db": ext = "lcg" path = QTUtil2.salvaFichero( self, _("Database of complete games"), self.configuracion.ficheroDBgames, _("File") + " %s (*.%s)" % (ext, ext), False) if path: if not path.lower().endswith(".lcg"): path += ".lcg" me = QTUtil2.mensEspera.inicio(self, _("Saving...")) dbn = DBgames.DBgames(path) for pc in other_pc(): dbn.inserta(pc) me.final() QTUtil2.mensaje(self, _X(_("Saved to %1"), path)) else: w = PantallaSavePGN.WSaveVarios(self, self.configuracion) if w.exec_(): ws = PantallaSavePGN.FileSavePGN(self, w.dic_result) if ws.open(): ws.um() for n, pc in enumerate(other_pc()): if n or not ws.is_new: ws.write("\n\n") ws.write(pc.pgn()) ws.close() ws.um_final()
def cambiaDBgames(self, fich): self.dbGames.close() self.dbGames = DBgames.DBgames(self.configuracion.ficheroDBgames) self.setdbGames()
def __init__(self, wParent, procesador, fenM2inicial=None, pvInicial=None): icono = Iconos.BookGuide() extparam = "edicionMyOwnBook" titulo = _("Personal Opening Guide") QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam) self.procesador = procesador self.configuracion = procesador.configuracion self.fenM2inicial = fenM2inicial self.pvInicial = pvInicial self.bookGuide = BookGuide.BookGuide(self) self.dbGames = DBgames.DBgames(self.configuracion.ficheroDBgames) dicVideo = self.recuperarDicVideo() self.wmoves = WBG_Moves.WMoves(procesador, self) self.wsummary = WBG_Summary.WSummary(procesador, self, self.dbGames) self.wgames = WBG_Games.WGames(procesador, self, self.dbGames, self.wsummary) self.registrarGrid(self.wsummary.grid) self.registrarGrid(self.wgames.grid) self.ultFocus = None self.splitterMoves = QtGui.QSplitter(self) self.splitterMoves.setOrientation(QtCore.Qt.Vertical) self.splitterMoves.addWidget(self.wmoves) self.splitterMoves.addWidget(self.wsummary) self.tab = Controles.Tab() self.tab.nuevaTab(self.splitterMoves, _("Moves")) self.tab.nuevaTab(self.wgames, _("Games")) self.tab.dispatchChange(self.tabChanged) self.infoMove = WBG_InfoMove.WInfomove(self) self.splitter = splitter = QtGui.QSplitter(self) splitter.addWidget(self.infoMove) splitter.addWidget(self.tab) layout = Colocacion.H().control(splitter).margen(5) self.setLayout(layout) self.wmoves.tree.setFocus() self.recuperarVideo(anchoDefecto=1175) if not dicVideo: dicVideo = { 'SPLITTER': [380, 816], 'TREE_1': 25, 'TREE_2': 25, 'TREE_3': 50, 'TREE_4': 661, 'SPLITTERMOVES': [344, 244] } sz = dicVideo.get("SPLITTER", None) if sz: self.splitter.setSizes(sz) for x in range(1, 6): w = dicVideo.get("TREE_%d" % x, None) if w: self.wmoves.tree.setColumnWidth(x, w) self.inicializa()
def conversion_complete(filepath): db = DBgames.DBgames(filepath) conversion(db)