예제 #1
0
class VistaCartas:
    # tamaño de la ventana
    X = 1000
    Y = 700

    def __init__(self, parentWindow):
        self.juego = JuegoCartas()
        self.fechaInicio = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        self.root = Toplevel()
        self.parentWindow = parentWindow
        self.root.title("FLEX. COGNITIVA.")
        self.root.config(heigh=self.Y, width=self.X)
        self.root.configure(bg='white')
        self.nivelActual = None
        self.terminado = False
        self.segundos = 0
        self.root.resizable(width=False, height=False)
        self.hilo2 = threading.Thread(target=self.ejecutarCronometro)
        self.hilo2.start()

        self.imagesRoutes = []
        for e in self.juego.cartasBase:
            self.imagesRoutes.append(e.ruta)
        self.imageOne = PhotoImage(file=self.imagesRoutes[0])
        self.imageTwo = PhotoImage(file=self.imagesRoutes[1])
        self.imageThree = PhotoImage(file=self.imagesRoutes[2])
        self.imageFour = PhotoImage(file=self.imagesRoutes[3])

        self.imageLevel = PhotoImage(
            file="game4/assets/images/circulo,azul,1.png")

        windowWidth = self.root.winfo_reqwidth()
        windowHeight = self.root.winfo_reqheight()

        positionRight = int(self.root.winfo_screenwidth() / 2 -
                            windowWidth / 2)
        positionDown = int(self.root.winfo_screenheight() / 2 -
                           windowHeight / 2)

        self.root.geometry("+{}+{}".format(positionRight, positionDown))

        self.nivelActualStr = "Nivel 1"
        self.label1 = Label(self.root, text=self.nivelActualStr)
        self.label1.config(font=("Righteous", 30), bg="white")
        self.label1.pack()
        self.label1.place(anchor=CENTER, x=self.X / 2, y=50)

        self.boton1 = Button(self.root,
                             image=self.imageOne,
                             relief=RAISED,
                             bd=0,
                             bg="white")
        self.boton1.configure(
            command=lambda: self.presionarBoton(self.imagesRoutes[0]))
        self.boton1.pack()
        self.boton1.place(anchor=CENTER,
                          x=self.X / 2 - 250,
                          y=self.Y / 2 - 100)
        self.boton2 = Button(self.root,
                             image=self.imageTwo,
                             relief=RAISED,
                             bd=0,
                             bg="white")
        self.boton2.configure(
            command=lambda: self.presionarBoton(self.imagesRoutes[1]))
        self.boton2.pack()
        self.boton2.place(anchor=CENTER, x=self.X / 2 - 85, y=self.Y / 2 - 100)
        self.boton3 = Button(self.root,
                             image=self.imageThree,
                             relief=RAISED,
                             bd=0,
                             bg="white")
        self.boton3.configure(
            command=lambda: self.presionarBoton(self.imagesRoutes[2]))
        self.boton3.pack()
        self.boton3.place(anchor=CENTER, x=self.X / 2 + 85, y=self.Y / 2 - 100)
        self.boton4 = Button(self.root,
                             image=self.imageFour,
                             relief=RAISED,
                             bd=0,
                             bg="white")
        self.boton4.configure(
            command=lambda: self.presionarBoton(self.imagesRoutes[3]))
        self.boton4.pack()
        self.boton4.place(anchor=CENTER,
                          x=self.X / 2 + 250,
                          y=self.Y / 2 - 100)

        self.label2 = Label(self.root, image=self.imageLevel, bd=0, bg="white")
        self.label2.configure()
        self.label2.pack()
        self.label2.place(anchor=CENTER, x=self.X / 2, y=self.Y / 2 + 180)
        #Aciertos acumulados
        self.label3 = Label(self.root, text="Aciertos: ")
        self.label3.config(font=("Righteous", 20), bg="white")
        self.label3.pack()
        self.label3.place(anchor=CENTER, x=self.X - 200, y=500)

        self.label4 = Label(self.root, text="2")
        self.label4.config(font=("Righteous", 20), bg="white")
        self.label4.pack()
        self.label4.place(anchor=CENTER, x=self.X - 130, y=500)

        self.pintarNivel()

        self.root.mainloop()

    def pintarNivel(self):
        self.nivelActual = self.juego.obtenerNivel()
        if self.nivelActual is None:
            self.terminado = True
            self.crearResultados()
        else:
            self.pintarRonda()

    def crearResultados(self):
        segundos = self.segundos % 60
        minutos = int(self.segundos / 60)
        aciertos, fallos = self.juego.calcularResultados()
        stringMBOX = "Total aciertos: " + str(
            aciertos) + ". \nTotal Errores: " + str(
                fallos) + "\nTiempo transcurrido: " + str(
                    minutos) + "m:" + str(segundos) + "s."
        mbox.showinfo("Juego completado", stringMBOX)
        stringResultado = "[Nivel 1] Fecha: " + self.fechaInicio + ", Aciertos: " + str(
            aciertos) + ", Errores: " + str(fallos) + ", Minutos: " + str(
                minutos) + ", Segundos: " + str(segundos) + "\n"
        guardarLog(stringResultado)
        self.root.destroy()
        self.parentWindow.deiconify()

    def presionarBoton(self, ruta):
        self.nivelActual.validarJugada(ruta)
        if self.nivelActual.ganoNivel():
            self.pintarNivel()
        else:
            self.pintarRonda()

    def pintarRonda(self):
        self.label1.configure(text="Nivel " + str(self.nivelActual.numNivel))
        self.label4.configure(text=self.nivelActual.contAciertos)
        carta = self.nivelActual.cargarCarta()
        self.imageLevel.configure(file=carta.ruta)
        self.label2.configure(image=self.imageLevel)

    def iniciarHilo(self):
        self.hilo2 = threading.Thread(target=self.reproducir)
        self.hilo2.start()

    def ejecutarCronometro(self):
        while (not self.terminado):
            time.sleep(1)
            self.segundos += 1
예제 #2
0
class App(Tk):
    """
    Main app.

    Put an icon in the system tray with a right click menu to
    create notes.
    """
    def __init__(self):
        Tk.__init__(self)
        self.withdraw()
        self.notes = {}
        self.img = PhotoImage(file=cst.IM_ICON)
        self.icon = PhotoImage(master=self, file=cst.IM_ICON_48)
        self.iconphoto(True, self.icon)

        self.ewmh = ewmh.EWMH()

        style = Style(self)
        style.theme_use("clam")

        self.close1 = PhotoImage("img_close", file=cst.IM_CLOSE)
        self.close2 = PhotoImage("img_closeactive", file=cst.IM_CLOSE_ACTIVE)
        self.roll1 = PhotoImage("img_roll", file=cst.IM_ROLL)
        self.roll2 = PhotoImage("img_rollactive", file=cst.IM_ROLL_ACTIVE)

        self.protocol("WM_DELETE_WINDOW", self.quit)
        self.icon = tktray.Icon(self, docked=True)

        # --- Menu
        self.menu_notes = Menu(self.icon.menu, tearoff=False)
        self.hidden_notes = {cat: {} for cat in CONFIG.options("Categories")}
        self.menu_show_cat = Menu(self.icon.menu, tearoff=False)
        self.menu_hide_cat = Menu(self.icon.menu, tearoff=False)
        self.icon.configure(image=self.img)
        self.icon.menu.add_command(label=_("New Note"), command=self.new)
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_('Show All'), command=self.show_all)
        self.icon.menu.add_cascade(label=_('Show Category'),
                                   menu=self.menu_show_cat)
        self.icon.menu.add_cascade(label=_('Show Note'),
                                   menu=self.menu_notes,
                                   state="disabled")
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_('Hide All'), command=self.hide_all)
        self.icon.menu.add_cascade(label=_('Hide Category'),
                                   menu=self.menu_hide_cat)
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_("Preferences"), command=self.config)
        self.icon.menu.add_command(label=_("Note Manager"),
                                   command=self.manage)
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_("Backup Notes"),
                                   command=self.backup)
        self.icon.menu.add_command(label=_("Restore Backup"),
                                   command=self.restore)
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_("Export"),
                                   command=self.export_notes)
        self.icon.menu.add_command(label=_("Import"),
                                   command=self.import_notes)
        self.icon.menu.add_separator()
        self.icon.menu.add_command(label=_('Check for Updates'),
                                   command=lambda: UpdateChecker(self))
        self.icon.menu.add_command(label=_('About'),
                                   command=lambda: About(self))
        self.icon.menu.add_command(label=_('Quit'), command=self.quit)

        # --- Restore notes
        self.note_data = {}
        if os.path.exists(PATH_DATA):
            with open(PATH_DATA, "rb") as fich:
                dp = pickle.Unpickler(fich)
                note_data = dp.load()
                for i, key in enumerate(note_data):
                    self.note_data["%i" % i] = note_data[key]
            backup()
            for key in self.note_data:
                data = self.note_data[key]
                cat = data["category"]
                if not CONFIG.has_option("Categories", cat):
                    CONFIG.set("Categories", cat, data["color"])
                if data["visible"]:
                    self.notes[key] = Sticky(self, key, **data)
                else:
                    self.add_note_to_menu(key, data["title"], cat)
        self.nb = len(self.note_data)
        self.update_menu()
        self.update_notes()
        self.make_notes_sticky()

        # --- class bindings
        # newline depending on mode
        self.bind_class("Text", "<Return>", self.insert_newline)
        # char deletion taking into account list type
        self.bind_class("Text", "<BackSpace>", self.delete_char)
        # change Ctrl+A to select all instead of go to the beginning of the line
        self.bind_class('Text', '<Control-a>', self.select_all_text)
        self.bind_class('TEntry', '<Control-a>', self.select_all_entry)
        # bind Ctrl+Y to redo
        self.bind_class('Text', '<Control-y>', self.redo_event)
        # unbind Ctrl+I and Ctrl+B
        self.bind_class('Text', '<Control-i>', lambda e: None)
        self.bind_class('Text', '<Control-b>', lambda e: None)
        # highlight checkboxes when inside text selection
        self.bind_class("Text", "<ButtonPress-1>", self.highlight_checkboxes,
                        True)
        self.bind_class("Text", "<ButtonRelease-1>", self.highlight_checkboxes,
                        True)
        self.bind_class("Text", "<B1-Motion>", self.highlight_checkboxes, True)
        evs = [
            '<<SelectAll>>', '<<SelectLineEnd>>', '<<SelectLineStart>>',
            '<<SelectNextChar>>', '<<SelectNextLine>>', '<<SelectNextPara>>',
            '<<SelectNextWord>>', '<<SelectNone>>', '<<SelectPrevChar>>',
            '<<SelectPrevLine>>', '<<SelectPrevPara>>', '<<SelectPrevWord>>'
        ]
        for ev in evs:
            self.bind_class("Text", ev, self.highlight_checkboxes, True)

        # check for updates
        if CONFIG.getboolean("General", "check_update"):
            UpdateChecker(self)

    # --- class bindings methods
    def highlight_checkboxes(self, event):
        txt = event.widget
        try:
            deb = cst.sorting(txt.index("sel.first"))
            fin = cst.sorting(txt.index("sel.last"))
            for ch in txt.children.values():
                try:
                    i = cst.sorting(txt.index(ch))
                    if i >= deb and i <= fin:
                        ch.configure(style="sel.TCheckbutton")
                    else:
                        ch.configure(style=txt.master.id + ".TCheckbutton")
                except TclError:
                    pass
        except TclError:
            for ch in txt.children.values():
                try:
                    i = cst.sorting(txt.index(ch))
                    ch.configure(style=txt.master.id + ".TCheckbutton")
                except TclError:
                    pass

    def redo_event(self, event):
        try:
            event.widget.edit_redo()
        except TclError:
            # nothing to redo
            pass

    def select_all_entry(self, event):
        event.widget.selection_range(0, "end")

    def select_all_text(self, event):
        event.widget.tag_add("sel", "1.0", "end-1c")
        self.highlight_checkboxes(event)

    def delete_char(self, event):
        txt = event.widget
        deb_line = txt.get("insert linestart", "insert")
        tags = txt.tag_names("insert")
        if txt.tag_ranges("sel"):
            if txt.tag_nextrange("enum", "sel.first", "sel.last"):
                update = True
            else:
                update = False
            txt.delete("sel.first", "sel.last")
            if update:
                txt.master.update_enum()
        elif txt.index("insert") != "1.0":
            if re.match('^\t[0-9]+\.\t$', deb_line) and 'enum' in tags:
                txt.delete("insert linestart", "insert")
                txt.insert("insert", "\t\t")
                txt.master.update_enum()
            elif deb_line == "\t•\t" and 'list' in tags:
                txt.delete("insert linestart", "insert")
                txt.insert("insert", "\t\t")
            elif deb_line == "\t\t":
                txt.delete("insert linestart", "insert")
            elif "todolist" in tags and txt.index("insert") == txt.index(
                    "insert linestart+1c"):
                try:
                    ch = txt.window_cget("insert-1c", "window")
                    txt.delete("insert-1c")
                    txt.children[ch.split('.')[-1]].destroy()
                    txt.insert("insert", "\t\t")
                except TclError:
                    txt.delete("insert-1c")
            else:
                txt.delete("insert-1c")

    def insert_newline(self, event):
        mode = event.widget.master.mode.get()
        if mode == "list":
            event.widget.insert("insert", "\n\t•\t")
            event.widget.tag_add("list", "1.0", "end")
        elif mode == "todolist":
            event.widget.insert("insert", "\n")
            ch = Checkbutton(event.widget,
                             takefocus=False,
                             style=event.widget.master.id + ".TCheckbutton")
            event.widget.window_create("insert", window=ch)
            event.widget.tag_add("todolist", "1.0", "end")
        elif mode == "enum":
            event.widget.configure(autoseparators=False)
            event.widget.edit_separator()
            event.widget.insert("insert", "\n\t0.\t")
            event.widget.master.update_enum()
            event.widget.edit_separator()
            event.widget.configure(autoseparators=True)
        else:
            event.widget.insert("insert", "\n")

    def make_notes_sticky(self):
        for w in self.ewmh.getClientList():
            if w.get_wm_name()[:7] == 'mynotes':
                self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
        self.ewmh.display.flush()

    def add_note_to_menu(self, nb, note_title, category):
        """add note to 'show notes' menu. """

        try:
            name = self.menu_notes.entrycget(category.capitalize(), 'menu')
            if not isinstance(name, str):
                name = str(name)
            menu = self.menu_notes.children[name.split('.')[-1]]
            end = menu.index("end")
            if end is not None:
                # le menu n'est pas vide
                titles = self.hidden_notes[category].values()
                titles = [t for t in titles if t.split(" ~#")[0] == note_title]
                if titles:
                    title = "%s ~#%i" % (note_title, len(titles) + 1)
                else:
                    title = note_title
            else:
                title = note_title
        except TclError:
            # cat is not in the menu
            menu = Menu(self.menu_notes, tearoff=False)
            self.menu_notes.add_cascade(label=category.capitalize(), menu=menu)
            title = note_title
        menu.add_command(label=title, command=lambda: self.show_note(nb))
        self.icon.menu.entryconfigure(4, state="normal")
        self.hidden_notes[category][nb] = title

    def backup(self):
        """Create a backup at the location indicated by user."""
        initialdir, initialfile = os.path.split(PATH_DATA_BACKUP % 0)
        fichier = asksaveasfilename(defaultextension=".backup",
                                    filetypes=[],
                                    initialdir=initialdir,
                                    initialfile="notes.backup0",
                                    title=_('Backup Notes'))
        if fichier:
            try:
                with open(fichier, "wb") as fich:
                    dp = pickle.Pickler(fich)
                    dp.dump(self.note_data)
            except Exception as e:
                report_msg = e.strerror != 'Permission denied'
                showerror(_("Error"), _("Backup failed."),
                          traceback.format_exc(), report_msg)

    def restore(self, fichier=None, confirmation=True):
        """Restore notes from backup."""
        if confirmation:
            rep = askokcancel(
                _("Warning"),
                _("Restoring a backup will erase the current notes."),
                icon="warning")
        else:
            rep = True
        if rep:
            if fichier is None:
                fichier = askopenfilename(defaultextension=".backup",
                                          filetypes=[],
                                          initialdir=LOCAL_PATH,
                                          initialfile="",
                                          title=_('Restore Backup'))
            if fichier:
                try:
                    keys = list(self.note_data.keys())
                    for key in keys:
                        self.delete_note(key)
                    if not os.path.samefile(fichier, PATH_DATA):
                        copy(fichier, PATH_DATA)
                    with open(PATH_DATA, "rb") as myfich:
                        dp = pickle.Unpickler(myfich)
                        note_data = dp.load()
                    for i, key in enumerate(note_data):
                        data = note_data[key]
                        note_id = "%i" % i
                        self.note_data[note_id] = data
                        cat = data["category"]
                        if not CONFIG.has_option("Categories", cat):
                            CONFIG.set("Categories", cat, data["color"])
                        if data["visible"]:
                            self.notes[note_id] = Sticky(self, note_id, **data)
                    self.nb = len(self.note_data)
                    self.update_menu()
                    self.update_notes()
                except FileNotFoundError:
                    showerror(
                        _("Error"),
                        _("The file {filename} does not exists.").format(
                            filename=fichier))
                except Exception as e:
                    showerror(_("Error"), str(e), traceback.format_exc(), True)

    def show_all(self):
        """Show all notes."""
        for cat in self.hidden_notes.keys():
            keys = list(self.hidden_notes[cat].keys())
            for key in keys:
                self.show_note(key)

    def show_cat(self, category):
        """Show all notes belonging to category."""
        keys = list(self.hidden_notes[category].keys())
        for key in keys:
            self.show_note(key)

    def hide_all(self):
        """Hide all notes."""
        keys = list(self.notes.keys())
        for key in keys:
            self.notes[key].hide()

    def hide_cat(self, category):
        """Hide all notes belonging to category."""
        keys = list(self.notes.keys())
        for key in keys:
            if self.note_data[key]["category"] == category:
                self.notes[key].hide()

    def manage(self):
        """Launch note manager."""
        Manager(self)

    def config(self):
        """Launch the setting manager."""
        conf = Config(self)
        self.wait_window(conf)
        col_changes, name_changes = conf.get_changes()
        if col_changes or name_changes:
            self.update_notes(col_changes, name_changes)
            self.update_menu()
            alpha = CONFIG.getint("General", "opacity") / 100
            for note in self.notes.values():
                note.attributes("-alpha", alpha)
                note.update_title_font()
                note.update_text_font()
                note.update_titlebar()

    def delete_cat(self, category):
        """Delete all notes belonging to category."""
        keys = list(self.notes.keys())
        for key in keys:
            if self.note_data[key]["category"] == category:
                self.notes[key].delete(confirmation=False)

    def delete_note(self, nb):
        if self.note_data[nb]["visible"]:
            self.notes[nb].delete(confirmation=False)
        else:
            cat = self.note_data[nb]["category"]
            name = self.menu_notes.entrycget(cat.capitalize(), 'menu')
            if not isinstance(name, str):
                name = str(name)
            menu = self.menu_notes.children[name.split('.')[-1]]
            index = menu.index(self.hidden_notes[cat][nb])
            menu.delete(index)
            if menu.index("end") is None:
                # the menu is empty
                self.menu_notes.delete(cat.capitalize())
                if self.menu_notes.index('end') is None:
                    self.icon.menu.entryconfigure(4, state="disabled")
            del (self.hidden_notes[cat][nb])
            del (self.note_data[nb])
            self.save()

    def show_note(self, nb):
        """Display the note corresponding to the 'nb' key in self.note_data."""
        self.note_data[nb]["visible"] = True
        cat = self.note_data[nb]["category"]
        name = self.menu_notes.entrycget(cat.capitalize(), 'menu')
        if not isinstance(name, str):
            name = str(name)
        menu = self.menu_notes.children[name.split('.')[-1]]
        index = menu.index(self.hidden_notes[cat][nb])
        del (self.hidden_notes[cat][nb])
        self.notes[nb] = Sticky(self, nb, **self.note_data[nb])
        menu.delete(index)
        if menu.index("end") is None:
            # the menu is empty
            self.menu_notes.delete(cat.capitalize())
            if self.menu_notes.index('end') is None:
                self.icon.menu.entryconfigure(4, state="disabled")
        self.make_notes_sticky()

    def update_notes(self, col_changes={}, name_changes={}):
        """Update the notes after changes in the categories."""
        categories = CONFIG.options("Categories")
        categories.sort()
        self.menu_notes.delete(0, "end")
        self.hidden_notes = {cat: {} for cat in categories}
        for key in self.note_data:
            cat = self.note_data[key]["category"]
            if cat in name_changes:
                cat = name_changes[cat]
                self.note_data[key]["category"] = cat
                if self.note_data[key]["visible"]:
                    self.notes[key].change_category(cat)
            elif cat not in categories:
                default = CONFIG.get("General", "default_category")
                default_color = CONFIG.get("Categories", default)
                if self.note_data[key]["visible"]:
                    self.notes[key].change_category(default)
                self.note_data[key]["category"] = default
                self.note_data[key]["color"] = default_color
                cat = default
            if cat in col_changes:
                old_color, new_color = col_changes[cat]
                if self.note_data[key]["color"] == old_color:
                    self.note_data[key]["color"] = new_color
                    if self.note_data[key]["visible"]:
                        self.notes[key].change_color(cst.INV_COLORS[new_color])
            if not self.note_data[key]['visible']:
                self.add_note_to_menu(key, self.note_data[key]["title"],
                                      self.note_data[key]['category'])
            else:
                self.notes[key].update_menu_cat(categories)
        self.save()
        if self.menu_notes.index("end") is not None:
            self.icon.menu.entryconfigure(4, state="normal")
        else:
            self.icon.menu.entryconfigure(4, state="disabled")

    def update_menu(self):
        """Populate self.menu_show_cat and self.menu_hide_cat with the categories."""
        self.menu_hide_cat.delete(0, "end")
        self.menu_show_cat.delete(0, "end")
        categories = CONFIG.options("Categories")
        categories.sort()
        for cat in categories:
            self.menu_show_cat.add_command(
                label=cat.capitalize(), command=lambda c=cat: self.show_cat(c))
            self.menu_hide_cat.add_command(
                label=cat.capitalize(), command=lambda c=cat: self.hide_cat(c))

    def save(self):
        """Save the data."""
        with open(PATH_DATA, "wb") as fich:
            dp = pickle.Pickler(fich)
            dp.dump(self.note_data)

    def new(self):
        """Create a new note."""
        key = "%i" % self.nb
        self.notes[key] = Sticky(self, key)
        data = self.notes[key].save_info()
        data["visible"] = True
        self.note_data[key] = data
        self.nb += 1
        self.make_notes_sticky()

    def export_notes(self):
        export = Export(self)
        self.wait_window(export)
        categories_to_export, only_visible = export.get_export()
        if categories_to_export:
            initialdir, initialfile = os.path.split(PATH_DATA_BACKUP % 0)
            fichier = asksaveasfilename(defaultextension=".html",
                                        filetypes=[
                                            (_("HTML file (.html)"), "*.html"),
                                            (_("Text file (.txt)"), "*.txt"),
                                            (_("All files"), "*")
                                        ],
                                        initialdir=initialdir,
                                        initialfile="",
                                        title=_('Export Notes As'))
            if fichier:
                try:
                    if os.path.splitext(fichier)[-1] == ".html":
                        # --- html export
                        cats = {cat: [] for cat in categories_to_export}
                        for key in self.note_data:
                            cat = self.note_data[key]["category"]
                            if cat in cats and (
                                (not only_visible)
                                    or self.note_data[key]["visible"]):
                                cats[cat].append(
                                    (self.note_data[key]["title"],
                                     cst.note_to_html(self.note_data[key],
                                                      self)))
                        text = ""
                        for cat in cats:
                            cat_txt = "<h1 style='text-align:center'>" + _(
                                "Category: {category}").format(
                                    category=cat) + "<h1/>\n"
                            text += cat_txt
                            text += "<br>"
                            for title, txt in cats[cat]:
                                text += "<h2 style='text-align:center'>%s</h2>\n" % title
                                text += txt
                                text += "<br>\n"
                                text += "<hr />"
                                text += "<br>\n"
                            text += '<hr style="height: 8px;background-color:grey" />'
                            text += "<br>\n"
                        with open(fichier, "w") as fich:
                            fich.write('<body style="max-width:30em">\n')
                            fich.write(
                                text.encode(
                                    'ascii',
                                    'xmlcharrefreplace').decode("utf-8"))
                            fich.write("\n</body>")
#                if os.path.splitext(fichier)[-1] == ".txt":
                    else:
                        # --- txt export
                        # export notes to .txt: all formatting is lost
                        cats = {cat: [] for cat in categories_to_export}
                        for key in self.note_data:
                            cat = self.note_data[key]["category"]
                            if cat in cats and (
                                (not only_visible)
                                    or self.note_data[key]["visible"]):
                                cats[cat].append(
                                    (self.note_data[key]["title"],
                                     cst.note_to_txt(self.note_data[key])))
                        text = ""
                        for cat in cats:
                            cat_txt = _("Category: {category}").format(
                                category=cat) + "\n"
                            text += cat_txt
                            text += "=" * len(cat_txt)
                            text += "\n\n"
                            for title, txt in cats[cat]:
                                text += title
                                text += "\n"
                                text += "-" * len(title)
                                text += "\n\n"
                                text += txt
                                text += "\n\n"
                                text += "-" * 30
                                text += "\n\n"
                            text += "#" * 30
                            text += "\n\n"
                        with open(fichier, "w") as fich:
                            fich.write(text)
#                    else:
#        # --- pickle export
#                        note_data = {}
#                        for key in self.note_data:
#                            if self.note_data[key]["category"] in categories_to_export:
#                                if (not only_visible) or self.note_data[key]["visible"]:
#                                    note_data[key] = self.note_data[key]
#
#                        with open(fichier, "wb") as fich:
#                            dp = pickle.Pickler(fich)
#                            dp.dump(note_data)
                except Exception as e:
                    report_msg = e.strerror != 'Permission denied'
                    showerror(_("Error"), str(e), traceback.format_exc(),
                              report_msg)

    def import_notes(self):
        fichier = askopenfilename(defaultextension=".backup",
                                  filetypes=[(_("Notes (.notes)"), "*.notes"),
                                             (_("All files"), "*")],
                                  initialdir=LOCAL_PATH,
                                  initialfile="",
                                  title=_('Import'))
        if fichier:
            try:
                with open(fichier, "rb") as fich:
                    dp = pickle.Unpickler(fich)
                    note_data = dp.load()
                for i, key in enumerate(note_data):
                    data = note_data[key]
                    note_id = "%i" % (i + self.nb)
                    self.note_data[note_id] = data
                    cat = data["category"]
                    if not CONFIG.has_option("Categories", cat):
                        CONFIG.set("Categories", cat, data["color"])
                        self.hidden_notes[cat] = {}
                    if data["visible"]:
                        self.notes[note_id] = Sticky(self, note_id, **data)
                self.nb = int(max(self.note_data.keys(),
                                  key=lambda x: int(x))) + 1
                self.update_menu()
                self.update_notes()
            except Exception:
                message = _("The file {file} is not a valid .notes file."
                            ).format(file=fichier)
                showerror(_("Error"), message, traceback.format_exc())

    def cleanup(self):
        """Remove unused latex images."""
        img_stored = os.listdir(cst.PATH_LATEX)
        img_used = []
        for data in self.note_data.values():
            img_used.extend(list(data.get("latex", {}).keys()))
        for img in img_stored:
            if img not in img_used:
                os.remove(os.path.join(cst.PATH_LATEX, img))

    def quit(self):
        self.destroy()
예제 #3
0
class VistaJuegoGlobos:
    # tamaño de la ventana
    X = 1000
    Y = 710
    TIEMPO_RESP = 3  # 3000ms

    def __init__(self, parentWindow):
        self.juego = JuegoGlobos()
        print(str(len(self.juego.niveles)))
        self.fechaInicio = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        self.root = Toplevel()
        self.parentWindow = parentWindow
        self.root.title("Control Inhibitorio")
        self.root.config(heigh=self.Y, width=self.X)
        self.root.configure(bg='white')
        self.nivelActual = None  #Objeto de tipo nivel
        self.segundos = 0
        self.terminado = False
        self.hilo2 = threading.Thread(target=self.ejecutarCronometro)
        self.hilo2.start()
        self.root.resizable(width=False, height=False)

        windowWidth = self.root.winfo_reqwidth()
        windowHeight = self.root.winfo_reqheight()

        positionRight = int(self.root.winfo_screenwidth() / 2 -
                            windowWidth / 2)
        positionDown = int(self.root.winfo_screenheight() / 2 -
                           windowHeight / 2)

        self.root.geometry("+{}+{}".format(positionRight, positionDown))
        self.nivelActualStr = "Nivel "
        self.label1 = Label(self.root, text=self.nivelActualStr)
        self.label1.config(font=("Righteous", 30), bg="white")
        self.label1.pack()
        self.label1.place(anchor=CENTER, x=self.X / 2, y=50)

        self.img1 = PhotoImage(file="game1/assets/blue.png")
        self.img2 = PhotoImage(file="game1/assets/blue.png")
        self.img3 = PhotoImage(file="game1/assets/blue.png")
        self.img4 = PhotoImage(file="game1/assets/blue.png")
        self.img5 = PhotoImage(file="game1/assets/blue.png")
        self.img6 = PhotoImage(file="game1/assets/blue.png")
        self.img7 = PhotoImage(file="game1/assets/blue.png")
        self.img8 = PhotoImage(file="game1/assets/blue.png")

        self.cuadro1 = Label(self.root, image=self.img1, bg="white")
        self.cuadro1.pack()
        self.cuadro1.place(anchor=CENTER, x=(self.X / 2) - 225, y=200)
        self.cuadro2 = Label(self.root, image=self.img2, bg="white")
        self.cuadro2.pack()
        self.cuadro2.place(anchor=CENTER, x=(self.X / 2) - 75, y=200)
        self.cuadro3 = Label(self.root, image=self.img3, bg="white")
        self.cuadro3.pack()
        self.cuadro3.place(anchor=CENTER, x=(self.X / 2) + 75, y=200)
        self.cuadro4 = Label(self.root, image=self.img4, bg="white")
        self.cuadro4.pack()
        self.cuadro4.place(anchor=CENTER, x=(self.X / 2) + 225, y=200)
        self.cuadro5 = Label(self.root, image=self.img5, bg="white")
        self.cuadro5.pack()
        self.cuadro5.place(anchor=CENTER, x=(self.X / 2) - 225, y=450)
        self.cuadro6 = Label(self.root, image=self.img6, bg="white")
        self.cuadro6.pack()
        self.cuadro6.place(anchor=CENTER, x=(self.X / 2) - 75, y=450)
        self.cuadro7 = Label(self.root, image=self.img7, bg="white")
        self.cuadro7.pack()
        self.cuadro7.place(anchor=CENTER, x=(self.X / 2) + 75, y=450)
        self.cuadro8 = Label(self.root, image=self.img8, bg="white")
        self.cuadro8.pack()
        self.cuadro8.place(anchor=CENTER, x=(self.X / 2) + 225, y=450)

        self.botonGo = Button(self.root,
                              text="Go",
                              bd=1,
                              relief=GROOVE,
                              bg=BLUE,
                              fg="white",
                              font=("Arial", 16),
                              command=self.accionBoton)
        self.botonGo.pack()
        self.botonGo.place(anchor=CENTER,
                           x=self.X / 2,
                           y=620,
                           width=150,
                           heigh=50)

        self.pintarNivel()

        self.root.mainloop()

    def pintarNivel(self):
        self.nivelActual = self.juego.obtenerNivel()
        if self.nivelActual is None:
            self.terminado = True
            self.crearResultados()
        else:
            self.label1.configure(text="Nivel " + str(self.juego.nivelActual))
            self.img1.configure(file=self.nivelActual.globos[0].ruta)
            self.img2.configure(file=self.nivelActual.globos[1].ruta)
            self.img3.configure(file=self.nivelActual.globos[2].ruta)
            self.img4.configure(file=self.nivelActual.globos[3].ruta)
            self.img5.configure(file=self.nivelActual.globos[4].ruta)
            self.img6.configure(file=self.nivelActual.globos[5].ruta)
            self.img7.configure(file=self.nivelActual.globos[6].ruta)
            self.img8.configure(file=self.nivelActual.globos[7].ruta)

            self.cuadro1.configure(image=self.img1)
            self.cuadro2.configure(image=self.img2)
            self.cuadro3.configure(image=self.img3)
            self.cuadro4.configure(image=self.img4)
            self.cuadro5.configure(image=self.img5)
            self.cuadro6.configure(image=self.img6)
            self.cuadro7.configure(image=self.img7)
            self.cuadro8.configure(image=self.img8)

    def crearResultados(self):
        aciertos, fallos = self.juego.calcularResultados()
        stringMBOX = "Total aciertos: " + str(
            aciertos) + ". \nTotal Errores: " + str(fallos) + "."
        mbox.showinfo("Juego completado", stringMBOX)
        stringResultado = "[Nivel 1] Fecha: " + self.fechaInicio + ", Aciertos: " + str(
            aciertos) + ", Errores: " + str(fallos) + "\n"
        guardarLog(stringResultado)
        self.root.destroy()
        self.parentWindow.deiconify()

    def accionBoton(self):
        self.nivelActual.presionarBotonGo()
        self.reiniciar()

    def reiniciar(self):
        self.segundos = 0
        self.pintarNivel()

    def ejecutarCronometro(self):
        while (not self.terminado):
            time.sleep(0.1)
            self.segundos += 0.1
            if self.segundos >= self.TIEMPO_RESP:
                self.reiniciar()
예제 #4
0
class DiceGenerator(EasyFrame):
    def __init__(self):
        EasyFrame.__init__(self, "Kismet")
        
        self.dice = ['d1.png', 'd2.png', 'd3.png', 'd4.png', 'd5.png', 'd6.png']
        
        g = '#1B5E20'
        w = '#FFFFFF'
        
        self.setResizable(True)
        self.setSize(600, 600)
        self.setBackground(g)
                           
        self.c1 = self.addButton(text = '   1   ', row = 0, column = 0,
                                 command = self.one)
        self.c1.configure(width = 5, font = 5)
        self.dieone = 0
        
        self.c2 = self.addButton(text = '2', row = 0, column = 1,
                                 command = self.two)
        self.c2.configure(width = 5, font = 5)
        self.dietwo = 0
        
        self.c3 = self.addButton(text = '3', row = 0, column = 2,
                                 command = self.three)
        self.c3.configure(width = 5, font = 5)
        self.diethree = 0
        
        self.c4 = self.addButton(text = '4', row = 0, column = 3,
                                 command = self.four)
        self.c4.configure(width = 5, font = 5)
        self.diefour = 0
        
        self.c5 = self.addButton(text = '5', row = 0, column = 4,
                                 command = self.five)
        self.c5.configure(width = 5, font = 5)
        self.diefive = 0
                       
        self.die1 = self.addLabel(text = '-', row = 1,
                      column = 0, sticky = 'E' + 'W',
                      foreground = g, background = g)
        self.die2 = self.addLabel(text = '-', row = 1,
                      column = 1, sticky = 'E' + 'W',
                      foreground = g, background = g)
        self.die3 = self.addLabel(text = '-', row = 1,
                      column = 2, sticky = 'E' + 'W',
                      foreground = g, background = g)
        self.die4 = self.addLabel(text = '-', row = 1,
                      column = 3, sticky = 'E' + 'W',
                      foreground = g, background = g)
        self.die5 = self.addLabel(text = '-', row = 1,
                      column = 4, sticky = 'E' + 'W',
                      foreground = g, background = g)

        self.image1 = PhotoImage(file = self.dice[5])
        self.image2 = PhotoImage(file = self.dice[5])
        self.image3 = PhotoImage(file = self.dice[5])
        self.image4 = PhotoImage(file = self.dice[5])
        self.image5 = PhotoImage(file = self.dice[5])
        
        self.die1["image"] = self.image1
        self.die2["image"] = self.image2
        self.die3["image"] = self.image3
        self.die4["image"] = self.image4
        self.die5["image"] = self.image5
        
        self.generate = self.addButton(text = 'Roll!', row = 2,
                                       column = 0, columnspan = 2,
                                       command = self.generate)
        self.generate.configure(height = 2, width = 10)
        
        self.tot = self.addLabel(text = "Total:", row = 2, column = 2, sticky = "E",
                                 foreground = '#000000', background = g)
        self.tot.configure(font = 10)
                                 
        self.total = self.addIntegerField(value = 0, row = 2,
                                          column = 3, sticky = "W",
                                          width = 5, state="disabled")
        self.total.configure(font = 10)
        self.generate.configure(width = 10)
        
        '''SCORECARD'''
        self.aceslabel = self.addLabel(text = 'Aces', row = 3, column = 0,
                                       background = w, sticky = 'E',
                                       font = 5)
        self.aceslabel.configure(width = 10)
        
        self.twoslabel = self.addLabel(text = 'Deuces', row = 4, column = 0,
                      background = w, sticky = 'E',
                      font = 3)
        self.twoslabel.configure(width = 10)
        
        self.threeslabel = self.addLabel(text = 'Treys', row = 5, column = 0,
                      background = w, sticky = 'E',
                      font = 3)
        self.threeslabel.configure(width = 10)
        
        self.fourslabel = self.addLabel(text = 'Fours', row = 6, column = 0,
                      background = w, sticky = 'E',
                      font = 3)
        self.fourslabel.configure(width = 10)
        
        self.fiveslabel = self.addLabel(text = 'Fives', row = 7, column = 0,
                      background = w, sticky = 'E',
                      font = 3)
        self.fiveslabel.configure(width = 10)
        
        self.sixeslabel = self.addLabel(text = 'Sixes', row = 8, column = 0,
                      background = w, sticky = 'E',
                      font = 3)
        self.sixeslabel.configure(width = 10)
        
        self.totallabel = self.addLabel(text = 'Total-->', row = 9, column = 0,
                      columnspan = 1, sticky = "E",
                      background = w, font = 5)
        self.totallabel.configure(width = 10)
        
        self.bonuslabel = self.addLabel(text = 'BONUS', row = 10, column = 0,
                      columnspan = 1, background = '#000000',
                      foreground = '#FFFFFF', font = 10,
                      sticky = 'E')
        self.bonuslabel.configure(width = 10)
        
        self.ones = self.addIntegerField(value = 0, row = 3, column = 1,
                                         state = 'disable', sticky = 'W')
        self.ones.configure(width = 3, font = 5)
        
        self.twos = self.addIntegerField(value = 0, row = 4, column = 1,
                                         state = 'disable', sticky = 'W')
        self.twos.configure(width = 3, font = 5)
        
        self.threes = self.addIntegerField(value = 0, row = 5, column = 1,
                                         state = 'disable', sticky = 'W')
        self.threes.configure(width = 3, font = 5)
        
        self.fours = self.addIntegerField(value = 0, row = 6, column = 1,
                                         state = 'disable', sticky = 'W')
        self.fours.configure(width = 3, font = 5)
        
        self.fives = self.addIntegerField(value = 0, row = 7, column = 1,
                                         state = 'disable', sticky = 'W')
        self.fives.configure(width = 3, font = 5)
        
        self.sixes = self.addIntegerField(value = 0, row = 8, column = 1,
                                         state = 'disable', sticky = 'W')
        self.sixes.configure(width = 3, font = 5)
        
        self.totalscore = self.addIntegerField(value = 0, row = 9, column = 1,
                                         state = 'disable', sticky = 'W')
        self.totalscore.configure(width = 3, font = 5)
        
        self.bonus = self.addIntegerField(value = 0, row = 10, column = 1,
                                         state = 'disable', sticky = 'W')
        self.bonus.configure(width = 3, font = 5)
        
    def generate(self):
        
        dielist = [self.dieone, self.dietwo, self.diethree, self.diefour, self.diefive]
        imagelist = [self.image1, self.image2, self.image3, self.image4, self.image5]
        
        for i in range(10):
            x1 = random.randint(0, 5)
            y1 = random.randint(0, 5)
            z1 = random.randint(0, 5)
            a1 = random.randint(0, 5)
            b1 = random.randint(0, 5)
            
#            shakelist = [x1, y1, z1, a1, b1]
            
#            for i in range(5):
#                if dielist[i] == 0:
#                    imagelist[i].configure(file = self.dice[shakelist[i]])
#                    time.sleep(.05)
#                    self.update()
            
            if self.dieone == 0:
                self.image1.configure(file = self.dice[x1])
            if self.dietwo == 0:
                self.image2.configure(file = self.dice[y1])
            if self.diethree == 0:
                self.image3.configure(file = self.dice[z1])
            if self.diefour == 0:
                self.image4.configure(file = self.dice[a1])
            if self.diefive == 0:
                self.image5.configure(file = self.dice[b1])
                
            time.sleep(.02)
            self.update()
        
        
        if self.dieone == 0:
            self.x = random.randint(0, 5)
        if self.dietwo == 0:
            self.y = random.randint(0, 5)
        if self.diethree == 0:
            self.z = random.randint(0, 5)
        if self.diefour == 0:
            self.a = random.randint(0, 5)
        if self.diefive == 0:
            self.b = random.randint(0, 5)
        
        lyst = [self.x, self.y, self.z, self.a, self.b]
        
        ones = 0
        twos = 0
        threes = 0
        fours = 0
        fives = 0
        sixes = 0
        
        for i in lyst:
            if i == 0:
                ones += 1
            elif i == 1:
                twos += 2
            elif i == 2:
                threes += 3
            elif i == 3:
                fours += 4
            elif i == 4:
                fives += 5
            elif i == 5:
                sixes += 6
                
        self.ones.setValue(ones)
        self.twos.setValue(twos)
        self.threes.setValue(threes)
        self.fours.setValue(fours)
        self.fives.setValue(fives)
        self.sixes.setValue(sixes)
        
        for i in range(5):
            if dielist[i] == 0:
                imagelist[i].configure(file = self.dice[lyst[i]])
                lyst[i] = lyst[i] + 1
            elif self.dieone > 0:
                lyst[i] = 0
            
        tot = 0
        for i in lyst:
            tot += i
        
        self.total.setValue(tot)
    
    def one(self):
        if self.dieone == 0:
            self.dieone += 1
            self.die1.configure(state = "disable")
        elif self.dieone > 0:
            self.dieone = 0
            self.die1.configure(state = "normal")

    def two(self):
        if self.dietwo == 0:
            self.dietwo += 1
            self.die2.configure(state = "disable")
        elif self.dietwo > 0:
            self.dietwo = 0
            self.die2.configure(state = "normal")
            
    def three(self):
        if self.diethree == 0:
            self.diethree += 1
            self.die3.configure(state = "disable")
        elif self.diethree > 0:
            self.diethree = 0
            self.die3.configure(state = "normal")
            
    def four(self):
        if self.diefour == 0:
            self.diefour += 1
            self.die4.configure(state = "disable")
        elif self.diefour > 0:
            self.diefour = 0
            self.die4.configure(state = "normal")
            
    def five(self):
        if self.diefive == 0:
            self.diefive += 1
            self.die5.configure(state = "disable")
        elif self.diefive > 0:
            self.diefive = 0
            self.die5.configure(state = "normal")
예제 #5
0
class VistaJuegoVelPro:
    # tamaño de la ventana
    X = 1280
    Y = 710

    def __init__(self, parentWindow, tipo):
        self.juego = VelocidadProcesamiento(tipo)
        self.fechaInicio = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        self.root = Toplevel()
        self.parentWindow = parentWindow
        self.root.title("Velocidad Procesamiento")
        self.root.config(heigh=self.Y, width=self.X)
        self.root.configure(bg='white')
        self.nivelActual = None
        self.segundos = 0
        self.terminado = False
        self.hilo2 = threading.Thread(target=self.ejecutarCronometro)
        self.hilo2.start()
        self.root.resizable(width=False, height=False)

        windowWidth = self.root.winfo_reqwidth()
        windowHeight = self.root.winfo_reqheight()

        positionRight = int(self.root.winfo_screenwidth() / 2 -
                            windowWidth / 2)
        positionDown = int(self.root.winfo_screenheight() / 2 -
                           windowHeight / 2)

        self.root.geometry("+{}+{}".format(positionRight, positionDown))
        self.nivelActualStr = "Nivel "
        self.label1 = Label(self.root, text=self.nivelActualStr)
        self.label1.config(font=("Righteous", 30), bg="white")
        self.label1.pack()
        self.label1.place(anchor=CENTER, x=self.X / 2, y=50)

        self.img1 = PhotoImage(file="game2/assets/images/Avion.png")
        self.img2 = PhotoImage(file="game2/assets/images/Avion.png")
        self.img3 = PhotoImage(file="game2/assets/images/Avion.png")

        self.cuadro1 = Label(self.root, image=self.img1)
        self.cuadro1.pack()
        self.cuadro1.place(anchor=CENTER, x=(self.X / 2) - 420, y=250)
        self.cuadro2 = Label(self.root, image=self.img2)
        self.cuadro2.pack()
        self.cuadro2.place(anchor=CENTER, x=self.X / 2, y=250)
        self.cuadro3 = Label(self.root, image=self.img3)
        self.cuadro3.pack()
        self.cuadro3.place(anchor=CENTER, x=(self.X / 2) + 420, y=250)

        self.cuadroOpcion = None

        if self.juego.tipoJuego == VelocidadProcesamiento.JUEGO_UNO:
            self.imgOpcion = PhotoImage(file="game2/assets/icons/Avion.png")
            self.smaller_image = self.imgOpcion.subsample(
                2, 2)  #Resize del objeto PhotoImage
            self.cuadroOpcion = Label(self.root, image=self.smaller_image)
        else:
            self.txtOpcion = "_"
            self.cuadroOpcion = Label(self.root,
                                      text=self.txtOpcion,
                                      font=("Righteous", 50))
        self.cuadroOpcion.configure(bg="white")
        self.cuadroOpcion.pack()
        self.cuadroOpcion.place(anchor=CENTER, x=self.X / 2, y=445)

        self.botonZ = Button(self.root,
                             text="Z",
                             bd=1,
                             relief=GROOVE,
                             bg=BLUE,
                             fg="white",
                             font=("Arial", 16),
                             command=lambda: self.accionBoton(1))
        self.botonZ.pack()
        self.botonZ.place(anchor=CENTER,
                          x=300,
                          y=self.Y - 150,
                          width=150,
                          heigh=50)

        self.botonG = Button(self.root,
                             text="-",
                             bd=1,
                             relief=GROOVE,
                             bg=BLUE,
                             fg="white",
                             font=("Arial", 16),
                             command=lambda: self.accionBoton(2))
        self.botonG.pack()
        self.botonG.place(anchor=CENTER,
                          x=self.X - 300,
                          y=self.Y - 150,
                          width=150,
                          heigh=50)

        self.pintarNivel()

        self.root.mainloop()

    def accionBoton(self, tBoton):
        if tBoton == 1:
            self.nivelActual.resultado = self.nivelActual.RES_SI
        else:
            self.nivelActual.resultado = self.nivelActual.RES_NO
        self.pintarNivel()

    def pintarNivel(self):
        self.nivelActual = self.juego.obtenerNivel()
        if self.nivelActual is None:
            self.terminado = True
            self.crearResultados()
        else:
            #self.hack() #Trampa
            self.label1.configure(text="Nivel " +
                                  str(self.nivelActual.numNivel + 1))
            self.img1.configure(file=self.nivelActual.ilustraciones[0].ruta)
            self.img2.configure(file=self.nivelActual.ilustraciones[1].ruta)
            self.img3.configure(file=self.nivelActual.ilustraciones[2].ruta)

            self.cuadro1.configure(image=self.img1)
            self.cuadro2.configure(image=self.img2)
            self.cuadro3.configure(image=self.img3)

            if self.juego.tipoJuego == VelocidadProcesamiento.JUEGO_UNO:
                self.imgOpcion.configure(file=self.nivelActual.icono.ruta)
                self.smaller_image = self.imgOpcion.subsample(
                    2, 2)  #Resize del objeto PhotoImage
                self.cuadroOpcion.configure(image=self.smaller_image)
            else:
                self.cuadroOpcion.configure(
                    text=self.nivelActual.icono.palabra[0])

    def ejecutarCronometro(self):
        while (not self.terminado):
            time.sleep(1)
            self.segundos += 1

    def crearResultados(self):
        segundos = self.segundos % 60
        minutos = int(self.segundos / 60)
        aciertos, fallos = self.juego.calcularResultados()
        stringMBOX = "Total aciertos: " + str(
            aciertos) + ". \nTotal Errores: " + str(
                fallos) + "\nTiempo transcurrido: " + str(
                    minutos) + "m:" + str(segundos) + "s."
        mbox.showinfo("Juego completado", stringMBOX)
        stringResultado = "[Nivel " + str(
            self.juego.tipoJuego
        ) + "] Fecha: " + self.fechaInicio + ", Aciertos: " + str(
            aciertos) + ", Errores: " + str(fallos) + ", Minutos: " + str(
                minutos) + ", Segundos: " + str(segundos) + "\n"
        guardarLog(stringResultado)
        self.root.destroy()
        self.parentWindow.deiconify()

    def hack(self):
        os.system('cls')
        print(
            str(self.nivelActual.ilustraciones[0].palabras) + " " +
            str(self.nivelActual.ilustraciones[1].palabras) + " " +
            str(self.nivelActual.ilustraciones[2].palabras) + " ======== " +
            self.nivelActual.icono.palabra)