Esempio n. 1
0
 def __init__(self, parent):
     self.parent = parent
     self.root = Tkinter.Tk()
     self.root.title(HEADERS["settings"][LANGUAGE])
     self.root.focus_force()
     self.frame = Tkinter.Frame(self.root)
     self.frame.grid(sticky=Tkinter.W + Tkinter.E + Tkinter.S + Tkinter.N)
     self.setting_entry = {}
     i = 0
     for setting in self.get_settings_list():
         label = Tkinter.Label(self.frame, text=setting[0])
         label.grid(row=i, column=0, sticky=Tkinter.W)
         entry = Tkinter.Entry(self.frame, width=50)
         entry.insert(0, setting[1])
         entry.grid(row=i, column=1, sticky=Tkinter.E)
         self.setting_entry.update({setting[0]: entry})
         i += 1
     self.root.protocol("WM_DELETE_WINDOW", self.on_close)
     self.save = Tkinter.Button(self.frame, text=BUTTONS["save"][LANGUAGE], command=self.save)
     self.save.grid(row=i + 1, column=1, sticky=Tkinter.E)
     self.cancel = Tkinter.Button(self.frame, text=BUTTONS["cancel"][LANGUAGE], command=self.cancel)
     self.cancel.grid(row=i + 1, column=1, sticky=Tkinter.W)
     self.help = Tkinter.Button(self.frame, text=BUTTONS["help"][LANGUAGE], command=self.help)
     self.help.grid(row=i + 1, column=0, sticky=Tkinter.W + Tkinter.E)
     center_window(
         entry.winfo_reqwidth() + label.winfo_reqwidth(),
         entry.winfo_reqheight() * len(self.setting_entry) + self.save.winfo_reqheight(),
         self.root,
     )
     self.root.mainloop()
Esempio n. 2
0
    def __init__(self):
        self.root = Tkinter.Tk()
        self.root.title(HEADERS['main'][LANGUAGE])

        self.frame = Tkinter.Frame(self.root)
        self.codes = Tkinter.Text(self.frame, font=("Helvetica", 12))
        self.scroll_bar = Tkinter.Scrollbar(self.frame)

        # Buttons for open windows
        self.settings = Tkinter.Button(self.root,
                                       text=BUTTONS['settings'][LANGUAGE],
                                       command=self.call_settings)
        self.code_generator = Tkinter.Button(self.root,
                                             text=BUTTONS['code_generator'][LANGUAGE],
                                             command=self.call_code_generator)
        self.anagrams = Tkinter.Button(self.root,
                                       text=BUTTONS['anagrams'][LANGUAGE],
                                       command=self.call_anagrams)

        # Operating with codes buttons
        self.enter_codes_randomly = Tkinter.IntVar(self.root)
        self.random_check_box = Tkinter.Checkbutton(self.root,
                                                    text=BUTTONS['enter_in_random_order'][LANGUAGE],
                                                    variable=self.enter_codes_randomly)
        self.copy_to_clipboard = Tkinter.Button(self.root,
                                                text=BUTTONS['copy_codes'][LANGUAGE],
                                                command=self.copy_to_clipboard)
        self.copy_from_clipboard = Tkinter.Button(self.root,
                                                  text=BUTTONS['paste_codes'][LANGUAGE],
                                                  command=self.copy_from_clipboard)
        self.clear_codes = Tkinter.Button(self.root,
                                          text=BUTTONS['clear'][LANGUAGE],
                                          command=self.clear_codes)
        self.start_brute_force = Tkinter.Button(self.root,
                                                text=BUTTONS['start_brute_force'][LANGUAGE],
                                                command=self.start_brute_force)
        # Packing elements
        self.frame.pack(fill=Tkinter.BOTH, expand=Tkinter.YES)
        self.start_brute_force.pack(side=Tkinter.RIGHT)
        self.random_check_box.pack(side=Tkinter.RIGHT)
        self.copy_from_clipboard.pack(side=Tkinter.RIGHT)
        self.copy_to_clipboard.pack(side=Tkinter.RIGHT)
        self.settings.pack(side=Tkinter.LEFT)
        self.code_generator.pack(side=Tkinter.LEFT)
        self.anagrams.pack(side=Tkinter.LEFT)
        self.clear_codes.pack(side=Tkinter.RIGHT)
        self.scroll_bar.pack(side=Tkinter.RIGHT, fill=Tkinter.BOTH)
        self.codes.pack(fill=Tkinter.BOTH, expand=Tkinter.YES)

        self.scroll_bar.config(command=self.codes.yview)
        self.codes.config(yscrollcommand=self.scroll_bar.set)
        center_window(self.codes.winfo_reqwidth() + self.scroll_bar.winfo_reqwidth(),
                      self.codes.winfo_reqheight() + self.settings.winfo_reqheight(), self.root)

        self.read_config()
        self.root.mainloop()
        self.write_config()
Esempio n. 3
0
    def __init__(self, parent):
        self.parent = parent
        self.root = Tkinter.Tk()
        self.root.title(HEADERS['anagrams'][LANGUAGE])
        self.root.focus_force()

        self.frame = Tkinter.Frame(self.root)
        self.frame.grid()
        self.root.protocol('WM_DELETE_WINDOW', self.on_close)

        label_letters = Tkinter.Label(self.frame, text=LABELS['anagrams_letters'][LANGUAGE])
        label_letters.grid(row=0, column=0)
        self.letters = Tkinter.Entry(self.frame, width=50)
        self.letters.grid(row=0, column=1)

        label_length = Tkinter.Label(self.frame, text=LABELS['length'][LANGUAGE])
        label_length.grid(row=1, column=0)
        self.length = Tkinter.Entry(self.frame, width=10)
        self.length.grid(row=1, column=1, sticky=Tkinter.W)

        label_reg = Tkinter.Label(self.frame, text=LABELS['mask'][LANGUAGE])
        label_reg.grid(row=2, column=0, sticky=Tkinter.W)
        self.regex = Tkinter.Entry(self.frame)
        self.regex.insert(0, '.*')
        self.regex.grid(row=2, column=1, sticky=Tkinter.W)

        self.use_mask = Tkinter.IntVar(self.root)
        use_mask = Tkinter.Checkbutton(self.frame, text=LABELS['use_mask'][LANGUAGE], variable=self.use_mask)
        use_mask.grid(row=2, column=1, sticky=Tkinter.E)

        self.strict_order = Tkinter.IntVar(self.root)
        strict_order = Tkinter.Checkbutton(self.frame, text=LABELS['leave_order'][LANGUAGE], variable=self.strict_order)
        strict_order.grid(row=1, column=1, sticky=Tkinter.E)

        label_preview = Tkinter.Label(self.frame, text=LABELS['search_result'][LANGUAGE])
        label_preview.grid(row=3, column=1, sticky=Tkinter.N)
        self.preview_box = Tkinter.Text(self.frame, font=("Helvetica", 12), height=10, width=30)
        self.preview_box.grid(row=4, column=1, sticky=Tkinter.S + Tkinter.W + Tkinter.E + Tkinter.N)
        self.scroll_bar = Tkinter.Scrollbar(self.frame)
        self.scroll_bar.grid(row=4, column=1, sticky=Tkinter.E + Tkinter.S + Tkinter.N)
        self.scroll_bar.config(command=self.preview_box.yview)
        self.preview_box.config(yscrollcommand=self.scroll_bar.set)

        label_db = Tkinter.Label(self.frame, text=LABELS['dictionary'][LANGUAGE])
        label_db.grid(row=3, column=0, sticky=Tkinter.W)

        dictionaries_db = default_settings.DATABASES
        names_db = default_settings.NAMES

        self.dictionary = Tkinter.StringVar(self.root)
        self.dictionary.set(names_db[dictionaries_db.index(default_settings.selected)])  # default value

        dictionaries = apply(Tkinter.OptionMenu, (self.frame, self.dictionary) + tuple(names_db))
        dictionaries.grid(row=4, column=0, sticky=Tkinter.W + Tkinter.E + Tkinter.N)

        def trace_dictionary(*args):
            i = 0
            chosen = False
            for name in names_db:
                if name.decode('utf-8') == self.dictionary.get():
                    default_settings.selected = dictionaries_db[i]
                    chosen = True
                i += 1
            if not chosen:
                default_settings.selected = dictionaries_db[0]

        self.dictionary.trace('w', trace_dictionary)

        self.preview_box.config(yscrollcommand=self.scroll_bar.set)

        do_anagram = Tkinter.Button(self.frame,
                                    text=BUTTONS['search_words'][LANGUAGE],
                                    command=self.preview)
        do_anagram.grid(row=5, column=1, sticky=Tkinter.E)

        add_button = Tkinter.Button(self.frame,
                                    text=BUTTONS['add_codes'][LANGUAGE],
                                    command=self.add_codes)
        add_button.grid(row=5, column=1)
        cancel_button = Tkinter.Button(self.frame,
                                       text=BUTTONS['cancel'][LANGUAGE],
                                       command=self.on_close)
        cancel_button.grid(row=5, column=0, sticky=Tkinter.W)

        help_button = Tkinter.Button(self.frame,
                                     text=BUTTONS['help'][LANGUAGE],
                                     command=self.help)
        help_button.grid(row=5, column=1, sticky=Tkinter.W)

        width = label_letters.winfo_reqwidth() + self.letters.winfo_reqwidth()
        height = self.length.winfo_reqheight() * 3 + label_db.winfo_reqheight() + \
                 self.preview_box.winfo_reqheight() + add_button.winfo_reqheight()
        center_window(width,
                      height, self.root)

        self.root.mainloop()
Esempio n. 4
0
    def __init__(self, parent):
        self.parent = parent
        self.root = Tkinter.Tk()
        self.root.title(HEADERS['code_generator'][LANGUAGE])
        self.root.focus_force()
        self.left_frame = Tkinter.Frame(self.root)
        self.left_frame.pack(side=Tkinter.LEFT)

        label = Tkinter.Label(self.left_frame, text=LABELS['symbols_to_generate'][LANGUAGE])
        label.pack(side=Tkinter.TOP, fill=Tkinter.X)
        self.letters_to_generate = Tkinter.Text(self.left_frame, font=("Helvetica", 12), height=10, width=30)
        self.letters_to_generate.pack(side=Tkinter.TOP)

        label_reg = Tkinter.Label(self.left_frame, text=LABELS['mask'][LANGUAGE])
        label_reg.pack(side=Tkinter.TOP, fill=Tkinter.X)
        self.regex = Tkinter.Entry(self.left_frame)
        self.regex.insert(0, '.*')
        self.regex.pack(side=Tkinter.TOP, fill=Tkinter.X)

        label_length = Tkinter.Label(self.left_frame, text=LABELS['codes_length'][LANGUAGE])
        label_length.pack(side=Tkinter.TOP, fill=Tkinter.X)
        self.length_from = Tkinter.Entry(self.left_frame)
        self.length_from.insert(0, '1')
        self.length_from.pack(side=Tkinter.TOP, fill=Tkinter.X)

        self.length_to = Tkinter.Entry(self.left_frame)
        self.length_to.insert(0, '1')
        self.length_to.pack(side=Tkinter.TOP, fill=Tkinter.X)

        label_preview = Tkinter.Label(self.left_frame, text=LABELS['preview'][LANGUAGE])
        label_preview.grid(row=0, column=0)
        label_preview.pack(side=Tkinter.TOP, fill=Tkinter.X)
        self.preview_box = Tkinter.Text(self.left_frame, font=("Helvetica", 12), height=10, width=30)
        self.preview_box.grid(row=0, column=1)

        self.scroll_bar = Tkinter.Scrollbar(self.left_frame)
        self.scroll_bar.pack(side=Tkinter.RIGHT, fill=Tkinter.BOTH)
        self.scroll_bar.config(command=self.preview_box.yview)
        self.preview_box.config(yscrollcommand=self.scroll_bar.set)
        self.preview_box.pack(side=Tkinter.TOP)

        upper_latin_button = Tkinter.Button(self.root,
                                            text=BUTTONS['add_latin'][LANGUAGE],
                                            command=self.add_upper_latin)
        upper_cyrillic_button = Tkinter.Button(self.root,
                                               text=BUTTONS['add_cyrillic'][LANGUAGE],
                                               command=self.add_upper_cyrillic)
        upper_ukrainian_button = Tkinter.Button(self.root,
                                                text=BUTTONS['add_ukrainian'][LANGUAGE],
                                                command=self.add_upper_ukrainian)
        digits_button = Tkinter.Button(self.root,
                                       text=BUTTONS['add_digits'][LANGUAGE],
                                       command=self.add_digits)
        punctuation_latin_button = Tkinter.Button(self.root,
                                                  text=BUTTONS['add_symbols'][LANGUAGE],
                                                  command=self.add_printable)

        upper_latin_button.pack(side=Tkinter.TOP, fill=Tkinter.X)
        upper_cyrillic_button.pack(side=Tkinter.TOP, fill=Tkinter.X)
        upper_ukrainian_button.pack(side=Tkinter.TOP, fill=Tkinter.X)
        digits_button.pack(side=Tkinter.TOP, fill=Tkinter.X)
        punctuation_latin_button.pack(side=Tkinter.TOP, fill=Tkinter.X)

        preview = Tkinter.Button(self.root,
                                 text=BUTTONS['preview'][LANGUAGE],
                                 command=self.preview)
        preview.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)
        add_button = Tkinter.Button(self.root,
                                    text=BUTTONS['add_codes'][LANGUAGE],
                                    command=self.add_codes)
        add_button.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)
        cancel_button = Tkinter.Button(self.root,
                                       text=BUTTONS['cancel'][LANGUAGE],
                                       command=self.on_close)
        cancel_button.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)

        total_height = self.letters_to_generate.winfo_reqheight() + \
                       self.preview_box.winfo_reqheight() + \
                       self.regex.winfo_reqheight() * 3 + \
                       label.winfo_reqheight() * 4

        total_width = self.preview_box.winfo_reqwidth() + add_button.winfo_reqwidth()

        self.root.protocol('WM_DELETE_WINDOW', self.on_close)

        center_window(total_width, total_height, self.root)

        self.root.mainloop()