def __init__(self, master, text_widget): self.text_widget = text_widget self.go_to_master = Toplevel(master) self.go_to_master.transient(master) self.go_to_master.grab_set() self.go_to_master.withdraw() self.go_to_master.after(0, self.go_to_master.deiconify) self.go_to_master.title('Go To Line') self.go_to_master.iconbitmap( include.resource_path('included_files\\transparent.ico')) pos_x, pos_y = master.winfo_x() + 55, master.winfo_y() + 170 self.go_to_master.geometry('{}x{}+{}+{}'.format( 250, 100, pos_x, pos_y)) self.go_to_master.focus_set() self.go_to_label_entry_frame = Frame(self.go_to_master) self.go_to_label = ttk.Label(self.go_to_label_entry_frame, text='Line Number:') self.go_to_entry = ttk.Entry(self.go_to_label_entry_frame, width=37) self.go_to_label.grid(row=0, column=0, sticky='w') self.go_to_entry.grid(row=1, column=0) self.go_to_entry.focus_set() self.go_to_label_entry_frame.place(x=10, y=7) self.buttons_frame = Frame(self.go_to_master) self.go_to_button = ttk.Button(self.buttons_frame, text='Go To', width=10, command=self.go_to) self.cancel_button = ttk.Button(self.buttons_frame, text='Cancel', width=10, command=self.go_to_master.destroy) self.go_to_button.grid(row=0, column=0, padx=8) self.cancel_button.grid(row=0, column=1) self.buttons_frame.place(x=80, y=65) self.shortcut = shortcut.ShortCut(self.go_to_master) self.go_to_entry.bind('<Control-h>', self.entry_bind) self.go_to_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut( self.go_to_button, 'Enter', True)) self.go_to_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.cancel_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut( self.cancel_button, 'Esc', True)) self.cancel_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.go_to_master.bind('<Return>', self.go_to) self.go_to_master.bind('<Escape>', lambda e: self.go_to_master.destroy()) self.go_to_master.mainloop()
def __init__(self, master, text_widget): self.changed = False self.find_index = None self.word_indexes = [] self.direction_var, self.match_case_var, self.wrap_around_var = IntVar( ), IntVar(), IntVar() self.master = master self.text_widget = text_widget self.transparent_ico = include.resource_path( 'included_files\\transparent.ico') self.find_master = Toplevel() self.find_master.transient(self.master) self.find_master.grab_set() self.dummy_text_widget = Text(self.find_master) self.find_master.withdraw() self.find_master.after(0, self.find_master.deiconify) self.find_master.title('Find') self.find_master.iconbitmap(self.transparent_ico) self.pos_x, self.pos_y = self.master.winfo_x( ) + 55, self.master.winfo_y() + 170 self.find_master.geometry('{}x{}+{}+{}'.format(355, 123, self.pos_x, self.pos_y)) self.find_master.resizable(0, 0) self.label_entry_frame = Frame(self.find_master) self.buttons_frame = Frame(self.find_master) self.find_what_label = ttk.Label(self.label_entry_frame, text='Find what:') self.find_what_entry = ttk.Entry(self.label_entry_frame, width=34) self.find_what_label.grid(row=0, column=0) self.find_what_entry.grid(row=0, column=1, padx=5) self.label_entry_frame.place(x=0, y=5) self.find_what_entry.focus_set() self.style = ttk.Style() self.style.configure('my.TButton', font=('Helvetica', 8)) self.find_next_button = ttk.Button(self.buttons_frame, text='Find Next', width=9, style='my.TButton', command=self.find) self.cancel_button = ttk.Button(self.buttons_frame, text='Cancel', width=9, style='my.TButton', command=self.exit) self.find_next_button.grid(row=0, column=0, ipadx=3) self.cancel_button.grid(row=1, column=0, pady=5, ipadx=3) self.buttons_frame.place(x=280, y=5) self.direction_var.set(2) self.ttk_label_frame = LabelFrame(self.find_master, text="Direction", padx=5, pady=5) self.up_radio_buttons = ttk.Radiobutton(self.ttk_label_frame, text='Up', takefocus=False, value=1, variable=self.direction_var) self.down_radio_buttons = ttk.Radiobutton(self.ttk_label_frame, text='Down', takefocus=False, value=2, variable=self.direction_var) self.up_radio_buttons.pack(side=LEFT) self.down_radio_buttons.pack(side=LEFT) self.ttk_label_frame.place(x=165, y=30) self.check_button_frame = Frame(self.find_master) self.match_case_check_button = ttk.Checkbutton( self.check_button_frame, text='Match case', variable=self.match_case_var, takefocus=False) self.wrap_around_case_check_button = ttk.Checkbutton( self.check_button_frame, text='Wrap around', variable=self.wrap_around_var, takefocus=False) self.match_case_check_button.pack(anchor='w') self.wrap_around_case_check_button.pack(anchor='w', pady=5) self.check_button_frame.place(x=5, y=70) self.shortcut = shortcut.ShortCut(self.find_master) self.find_next_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut(self.find_next_button, 'F3')) self.find_next_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.cancel_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut(self.cancel_button, 'ESC')) self.cancel_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.insert_selected_text() self.find_master.bind('<F3>', self.find) self.cancel_button.bind('<Return>', self.exit) self.find_next_button.bind('<Return>', self.find) self.find_master.protocol('WM_DELETE_WINDOW', self.exit) self.find_master.bind('<Escape>', self.exit) self.find_what_entry.bind('<Control-h>', self.entry_bind) self.find_master.mainloop()
def __init__(self, master, text_widget): self.find_index = None self.word_indexes = [] self.transparent_ico = include.resource_path( 'included_files\\transparent.ico') self.master = master self.text_widget = text_widget self.dummy_text_widget = Text(master) self.match_var, self.wrap_var = IntVar(), IntVar() self.wrap_var.set(1) self.replace_master = Toplevel() self.replace_master.grab_set() self.hide_show = include.hide_or_show_maximize_minimize( self.replace_master) # Hiding minimize and maximize button self.replace_master.after(0, self.hide_show.hide_minimize_maximize) self.replace_master.withdraw() self.replace_master.after(0, self.replace_master.deiconify) self.replace_master.title('Replace') self.replace_master.iconbitmap(self.transparent_ico) self.pos_x, self.pos_y = self.master.winfo_x( ) + 55, self.master.winfo_y() + 170 self.replace_master.geometry('{}x{}+{}+{}'.format( 350, 155, self.pos_x, self.pos_y)) self.replace_master.resizable(0, 0) self.find_what_frame = Frame(self.replace_master) self.find_what_label = ttk.Label(self.find_what_frame, text='Find what:') self.replace_find_what_entry = ttk.Entry(self.find_what_frame, width=31) self.find_what_label.grid(row=0, column=0) self.replace_find_what_entry.focus_set() self.replace_find_what_entry.grid(row=0, column=1, padx=18) self.find_what_frame.place(x=0, y=5) self.replace_with_frame = Frame(self.replace_master) self.replace_with_label = ttk.Label(self.replace_with_frame, text='Replace what:') self.replace_with_entry = ttk.Entry(self.replace_with_frame, width=31) self.replace_with_label.grid(row=0, column=0) self.replace_with_entry.grid(row=0, column=1, pady=5) self.replace_with_frame.place(x=0, y=30) self.buttons_frame = Frame(self.replace_master) self.style = ttk.Style() self.style.configure('my.TButton', font=('Helvetica', 8)) self.find_next_button = ttk.Button(self.buttons_frame, text='Find Next', width=9, style='my.TButton', command=self.find_next) self.replace_button = ttk.Button(self.buttons_frame, text='Replace', width=9, style='my.TButton', command=self.replace) self.replace_all_button = ttk.Button(self.buttons_frame, text='Replace All', width=9, style='my.TButton', command=self.replace_all) self.cancel_button = ttk.Button(self.buttons_frame, text='Cancel', width=9, style='my.TButton', command=self.exit) self.find_next_button.grid(row=0, column=0, ipadx=3) self.replace_button.grid(row=1, column=0, ipadx=3, pady=5) self.replace_all_button.grid(row=2, column=0, ipadx=3) self.cancel_button.grid(row=3, column=0, ipadx=3, pady=5) self.buttons_frame.place(x=275, y=5) self.check_button_frame = Frame(self.replace_master) self.match_case_checkbutton = ttk.Checkbutton(self.check_button_frame, text='Match case', variable=self.match_var, takefocus=False) self.wrap_around_case_checkbutton = ttk.Checkbutton( self.check_button_frame, text='Wrap around', variable=self.wrap_var, takefocus=False) self.match_case_checkbutton.pack(anchor='w') self.wrap_around_case_checkbutton.pack(anchor='w', pady=5) self.check_button_frame.place(x=5, y=100) self.shortcut = shortcut.ShortCut(self.replace_master) self.find_next_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut(self.find_next_button, 'F3')) self.find_next_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.replace_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut( self.replace_button, 'Ctrl+Shift+H')) self.replace_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.replace_all_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut( self.replace_all_button, 'Ctrl+Alt+Enter')) self.replace_all_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.cancel_button.bind( '<Enter>', lambda e: self.shortcut.show_shortcut(self.cancel_button, 'Esc')) self.cancel_button.bind('<Leave>', lambda e: self.shortcut.destroy()) self.insert_selected_text() self.replace_master.bind('<Control-Alt-Return>', self.replace_all) self.replace_master.bind('<Control-H>', self.replace) self.replace_master.bind('<Escape>', self.exit) self.replace_with_entry.bind('<Control-h>', self.entry_bind) self.replace_find_what_entry.bind('<Control-h>', self.entry_bind) self.find_next_button.bind('<Return>', self.find_next) self.replace_button.bind('<Return>', self.replace) self.replace_all_button.bind('<Return>', self.replace_all) self.cancel_button.bind('<Return>', self.exit) self.replace_master.protocol('WM_DELETE_WINDOW', self.exit) self.replace_master.mainloop()
def __init__(self, master): self.build_number = '1.0.9' self.master = master self.author_page_link = 'http://github.com/ghanteyyy' self.source_code_link = 'https://github.com/ghanteyyy/nppy/tree/master/PROJECT GUIs/ZPAD' self.top_level = Toplevel(self.master) self.top_level.transient(self.master) self.top_level.grab_set() self.top_level.withdraw() self.initial_position() self.top_level.after(0, self.top_level.deiconify) self.top_level.title('About') self.top_level.iconbitmap( include.resource_path('included_files\\transparent.ico')) self.search = search.Search(self.top_level) self.description_frame = Frame(self.top_level, bg='white') self.build_label = Label(self.description_frame, text='Build:', bg='white') self.build_number_label = Label(self.description_frame, text=self.build_number, bg='white') self.author_label = Label(self.description_frame, text='Author:', bg='white') self.author_name_button = Button(self.description_frame, text='\t\tghanteyyy', bg='white', activebackground='white', activeforeground='black', fg='black', bd=0, command=self.author_page) self.source_code_label = Label(self.description_frame, text='Source Code:', bg='white') self.source_code_button = Button(self.description_frame, text='\t\tZPAD', bg='white', activebackground='white', activeforeground='black', fg='black', bd=0, command=self.source_code_page) self.build_label.grid(row=0, column=0, sticky='w') self.build_number_label.grid(row=0, column=1, sticky='e') self.author_label.grid(row=1, column=0, sticky='w') self.author_name_button.grid(row=1, column=1, sticky='e') self.source_code_label.grid(row=2, column=0, sticky='w') self.source_code_button.grid(row=2, column=1, sticky='e') self.description_frame.pack(pady=20) self.show_link_frame = Frame(self.top_level) self.link_label = Label(self.show_link_frame, bg='white') self.link_label.grid(row=0, column=1) self.show_link_frame.pack(side=LEFT) self.ok_frame = Frame(self.top_level) self.ok_button = ttk.Button(self.ok_frame, text='Ok', command=self.top_level.destroy) self.ok_button.grid(row=0, column=0) self.ok_frame.pack(side=RIGHT) self.author_name_button.bind( '<Enter>', lambda e: self.enter(self.author_name_button, self. author_page_link)) self.author_name_button.bind( '<Leave>', lambda e: self.leave(self.author_name_button)) self.source_code_button.bind( '<Enter>', lambda e: self.enter(self.source_code_button, self. source_code_link)) self.source_code_button.bind( '<Leave>', lambda e: self.leave(self.source_code_button)) self.author_label.bind( '<Enter>', lambda e: self.enter(self.author_label, self.author_page_link)) self.author_label.bind('<Leave>', lambda e: self.leave(self.author_label)) self.source_code_label.bind( '<Enter>', lambda e: self.enter(self.source_code_label, self. source_code_link)) self.source_code_label.bind( '<Leave>', lambda e: self.leave(self.source_code_label)) self.author_label.bind('<Button-1>', self.author_page) self.source_code_label.bind('<Button-1>', self.source_code_page) self.top_level.bind('<Return>', lambda e: self.top_level.destroy()) self.top_level.bind('<Escape>', lambda e: self.top_level.destroy()) self.top_level.config(bg='white') self.top_level.mainloop()
def __init__(self, master, _font): self.font = _font self.master = master self.transparent_ico = include.resource_path('included_files\\transparent.ico') self.top_level = Toplevel(self.master) self.top_level.transient(self.master) self.top_level.withdraw() self.top_level.title('Font') self.top_level.grab_set() self.top_level.iconbitmap(self.transparent_ico) self.top_level.resizable(0, 0) self.pos_x, self.pos_y = self.master.winfo_x() + 30, self.master.winfo_y() + 60 self.top_level.geometry(f'415x245+{self.pos_x}+{self.pos_y}') self.font_families = list(font.families(self.top_level)) self.font_families.sort() self.font_families = self.font_families[26:] self.non_duplicates_fonts() self.lower_font_name = [f.lower() for f in self.font_families] self.font_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic', 'Underline', 'Overstrike'] self.lower_font_style = [s.lower() for s in self.font_styles] self.font_sizes = [str(i) for i in range(9, 73)] self.container_frame = Frame(self.top_level) self.container_frame.pack(padx=5) self.font_families_frame = Widgets(self.top_level, self.container_frame, 'Font:', self.font_families, 29, 27) self.font_style_frame = Widgets(self.top_level, self.container_frame, 'Font Style:', self.font_styles, 21, 19) self.font_size_frame = Widgets(self.top_level, self.container_frame, 'Size:', self.font_sizes, 9, 7) for frame in [self.font_families_frame, self.font_style_frame, self.font_size_frame]: frame.entry.bind('<Up>', frame.up_direction) frame.entry.bind('<Tab>', frame.tab_completion) frame.entry.bind('<BackSpace>', frame.backspace) frame.entry.bind('<Down>', frame.down_direction) frame.entry.bind('<KeyPress>', frame.key_pressed) frame.entry.bind('<KeyRelease>', frame.key_released) frame.entry.bind('<Escape>', lambda e: self.top_level.destroy()) self.sample_labelframe = LabelFrame(self.top_level, text='Sample') self.pixel = PhotoImage(width=1, height=1) self.sample_label = Label(self.sample_labelframe, text='AaBbYyZz', compound='center', image=self.pixel, width=200, height=40, takefocus=False) self.sample_label.grid(row=0, column=0) self.sample_labelframe.pack() self.bottom_frame = Frame(self.top_level) self.ok_button = ttk.Button(self.bottom_frame, text='OK', command=self.apply_and_save_details) self.cancel_button = ttk.Button(self.bottom_frame, text='Cancel', command=self.top_level.destroy) self.ok_button.pack(side=LEFT) self.cancel_button.pack(side=LEFT, padx=5) self.bottom_frame.pack(side=RIGHT, pady=5) self.set_to_default() self.font_families_frame.entry.bind('<Return>', self.apply_and_save_details) self.font_style_frame.entry.bind('<Return>', self.apply_and_save_details) self.font_style_frame.entry.bind('<Return>', self.apply_and_save_details) self.entry_listbox = {self.font_families_frame.entry: self.font_families_frame.listbox, self.font_style_frame.entry: self.font_style_frame.listbox, self.font_size_frame.entry: self.font_size_frame.listbox} self.non_duplicates_fonts() self.master.after(0, self.top_level.deiconify) self.top_level.bind('<Key>', self.up_down) self.top_level.after(250, lambda: set_selection(self.font_families_frame.entry, self.font_families_frame.entry_var)) self.top_level.after(100, self.config_sample_label) self.top_level.mainloop()
def __init__(self, master, _font): self.master = master self.transparent_ico = include.resource_path( 'included_files\\transparent.ico') self.top_level = Toplevel(self.master) self.top_level.withdraw() self.top_level.title('Font') self.top_level.grab_set() self.top_level.iconbitmap(self.transparent_ico) self.top_level.resizable(0, 0) self.hide_show = include.hide_or_show_maximize_minimize(self.top_level) self.pos_x, self.pos_y = self.master.winfo_x( ) + 30, self.master.winfo_y() + 60 self.top_level.geometry(f'415x245+{self.pos_x}+{self.pos_y}') self.font_families = list(font.families(self.top_level)) self.font_families.sort() self.font_families = self.font_families[26:] self.non_duplicates_fonts() self.font_styles = [ 'Regular', 'Italic', 'Bold', 'Bold Italic', 'Underline', 'Overstrike' ] self.font_sizes = [str(i) for i in range(9, 73)] self.container_frame = Frame(self.top_level) self.container_frame.pack(padx=5) self.font_families_frame = Widgets(self.top_level, self.container_frame, 'Font:', self.font_families, 29, 27) self.font_style_frame = Widgets(self.top_level, self.container_frame, 'Font Style:', self.font_styles, 21, 19) self.font_size_frame = Widgets(self.top_level, self.container_frame, 'Size:', self.font_sizes, 9, 7) self.sample_labelframe = LabelFrame(self.top_level, text='Sample') self.pixel = PhotoImage(width=1, height=1) self.sample_label = Label(self.sample_labelframe, text='AaBbYyZz', compound='center', image=self.pixel, width=200, height=40) self.sample_label.grid(row=0, column=0) self.sample_labelframe.pack() self.ok_cmd = select_font.Commands(self.top_level, _font, self.sample_label, self.font_families_frame, self.font_style_frame, self.font_size_frame) self.bottom_frame = Frame(self.top_level) self.ok_button = ttk.Button(self.bottom_frame, text='OK', command=self.ok_cmd.cmd) self.cancel_button = ttk.Button(self.bottom_frame, text='Cancel', command=self.top_level.destroy) self.ok_button.pack(side=LEFT) self.cancel_button.pack(side=LEFT, padx=5) self.bottom_frame.pack(side=RIGHT, pady=5) self.ffsmuic = select_font.Bindings(self.top_level, self.font_style_frame) self.ffssmuic = select_font.Bindings(self.top_level, self.font_size_frame) self.fffmuic = select_font.Bindings(self.top_level, self.font_families_frame) self.ok_cmd.set_to_default() self.font_families_frame.entry.bind('<Return>', self.ok_cmd.cmd) self.font_style_frame.entry.bind('<Return>', self.ok_cmd.cmd) self.font_style_frame.entry.bind('<Return>', self.ok_cmd.cmd) self.font_families_frame.entry_var.trace('w', self.fffmuic.key_bind) self.font_style_frame.entry_var.trace('w', self.ffsmuic.key_bind) self.font_size_frame.entry_var.trace('w', self.ffssmuic.key_bind) self.non_duplicates_fonts() self.master.after(0, self.top_level.deiconify) self.master.after(0, lambda: self.hide_show.hide_minimize_maximize()) self.top_level.bind('<Escape>', lambda e: self.top_level.destroy()) self.top_level.after( 250, lambda: select_font.set_selection( self.font_families_frame.entry, self.font_families_frame. entry_var)) self.top_level.after(100, self.ok_cmd.config_sample_label) self.top_level.mainloop()