def init_status_bar(self): sb = self.editwin.status_bar sb.set_label('ClassDefBrowser', text="Code Browser") L = sb.labels['ClassDefBrowser'] L.bind('<Button-1>', self.toggle_classdef) L.bind('<Button-3>', self.toggle_keyword) ToolTip(L, "Click to Show Classes and Definitions in buffer")
def tooltip(self, root, msg): if WITH_TOOLTIP: ToolTip(root, msg) else: pass
def build(self): """Initializes and builds application widgets.""" text_credits = 'V-WAD\ncopyright © {year}\nerrantbot\nversion ' \ '{ver}'.format(year=datetime.datetime.now().year, ver=__version__) self.img_1 = tk.PhotoImage(file='wad/data/python-powered-h-50x65.png') # create main credits label self.lbl_info = tk.Label(self, text=text_credits, font=('courier', 10, 'normal')) self.lbl_info.grid(row=0, column=0, sticky='w', padx=1, pady=1) # create python logo credit self.lbl_logo = tk.Label(self, image=self.img_1, cursor='hand2') self.lbl_logo.grid(row=0, column=1, sticky='e', padx=1, pady=1) self.logo_tip = ToolTip(self.lbl_logo, ["Check", "out", "www.python.org"]) # create credits text labelframe self.credits_labelframe = tk.LabelFrame(self, text='License information', foreground='brown') self.credits_labelframe.grid(row=1, column=0, padx=1, pady=1, sticky='we', columnspan=3) # create credits text display self.credits_display = tk.Text(self.credits_labelframe) self.scrollbar = tk.Scrollbar(self.credits_labelframe) self.credits_display.grid(row=0, column=0, padx=1, pady=1, columnspan=1) self.credits_display.insert(0.0, CREDITS) self.credits_display.config(state=tk.DISABLED, wrap=tk.WORD, height=5, width=33, font=('courier', 8, 'normal')) self.scrollbar.grid(row=0, column=1, padx=1, pady=1, sticky='ens') self.credits_display.config(yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.credits_display.yview) # create hyperlink labelframe self.credits_labelframe_2 = tk.LabelFrame(self, text='Icon credits', foreground='brown') self.credits_labelframe_2.grid(row=2, column=0, padx=1, pady=1, sticky='we', columnspan=3) # create hyperlink labels and grid them self.lbl_link_2 = tk.Label(self.credits_labelframe_2, text='http://www.famfamfam.com/', cursor='hand2') self.lbl_link_2.grid(row=1, column=0, padx=0, pady=0, sticky='e') # bind link labels to hyperlink functions self.lbl_link_2.bind('<Button-1>', self.hyperlink_2) self.lbl_logo.bind('<Button-1>', self.hyperlink_4)
def __init__(self, parent): ttk.Frame.__init__(self, parent) self.parent = parent self.pack(fill=tk.BOTH, expand=True) self.folder_queue = queue.Queue() # hide images and icons folder for Windows users if sys.platform == "win32": os.popen("attrib +h .images").close() os.popen("attrib +h .icons").close() os.popen("attrib +h .data_files").close() self.pointer = "hand2" choose_info_btn_font = "-size 18" field_width = 35 if not os.path.exists("WG Ad Links") or not os.path.exists( "Offline Ad Links"): folder_thread = threading.Thread( target=create_results_folders.create_folders, args=[self.folder_queue]) folder_thread.daemon = True folder_thread.start() elif sys.platform == "linux": self.pointer = "hand2" choose_info_btn_font = "-size 16" field_width = 30 home = expanduser('~') if not os.path.exists("{}/WG Finder/WG Ad Links".format( home)) or not os.path.exists( "{}/WG Finder/Offline Ad Links".format(home)): folder_thread = threading.Thread( target=create_results_folders.create_folders, args=[self.folder_queue]) folder_thread.daemon = True folder_thread.start() else: self.pointer = "pointinghand" choose_info_btn_font = "-size 20" field_width = 30 home = expanduser('~') if not os.path.exists("{}/WG Finder/WG Ad Links".format( home)) or not os.path.exists( "{}/WG Finder/Offline Ad Links".format(home)): folder_thread = threading.Thread( target=create_results_folders.create_folders, args=[self.folder_queue]) folder_thread.daemon = True folder_thread.start() # kills phantomjs process incase user exits program without stopping in first atexit.register(self.kill_phantomjs) choose_info = ttk.Style() choose_info.configure("Choose.TButton", font=choose_info_btn_font, padding=(10, 30, 10, 30)) self.warning_lbl_style = ttk.Style() self.warning_lbl_style.configure('Warning.TLabel', foreground="red") self.large_warning_lbl_style = ttk.Style() self.large_warning_lbl_style.configure('LargeWarning.TLabel', foreground="red") self.window_width = 1 # create GUI title widgets self.title_frame = ttk.Frame(self) self.title_frame.columnconfigure(0, weight=1) self.title_frame.grid(row=0, column=0, padx=20, pady=(10, 20), sticky=tk.W + tk.E) if sys.platform == 'win32': self.title_img = Image.open('.images/title.png') self.title_photo = ImageTk.PhotoImage(self.title_img) elif sys.platform == 'linux': self.title_img = Image.open('.images/title.png') self.title_photo = ImageTk.PhotoImage(self.title_img) else: self.title_img = Image.open('.images/title.gif') self.title_photo = ImageTk.PhotoImage(self.title_img) self.title = ttk.Label(self.title_frame, image=self.title_photo) self.title.grid(row=0, column=0) # create Choose Info widgets self.choose_info_btn_frame = ttk.Frame(self) self.saved_info_btn = ttk.Button( self.choose_info_btn_frame, style="Choose.TButton", cursor=self.pointer, text="Use saved login details", command=lambda: self.check_credentials("choose info")) self.saved_info_btn_tooltip = ToolTip( self.saved_info_btn, "Log into WG-Gesucht.de with the email and \n" "password you have saved previously and start \n" "searching for new apartments") self.update_info_btn = ttk.Button( self.choose_info_btn_frame, style="Choose.TButton", cursor=self.pointer, text="Update login details", command=lambda: self.save_login_details("choose info")) self.update_info_btn_tooltip = ToolTip( self.update_info_btn, "Update your WG-Gesucht.de password if you have \n" "changed it since running the program last") warning_text = "***You seem to have moved or deleted your login info file, if you have moved it, please " \ "move it back to the '.data_files' folder, or if you have accidentally deleted it, please " \ "email '[email protected].***" self.choose_info_warning_var = tk.StringVar() self.choose_info_warning_lbl = ttk.Label( self.choose_info_btn_frame, style="Warning.TLabel", textvariable=self.choose_info_warning_var) self.no_login_warning = ttk.Label(self.choose_info_btn_frame, text=warning_text, style='LargeWarning.TLabel') if not os.path.exists(".data_files"): os.makedirs(".data_files") self.login_info_file = '.data_files/.login_info.json' self.login_info = dict() if os.path.isfile(self.login_info_file): # make login file hidden for Windows users if sys.platform == "win32": os.popen("attrib +h {}".format(self.login_info_file)).close() with open(self.login_info_file) as file: self.login_info = json.load(file) else: with open('.data_files/.login_info.json', 'w', encoding='utf-8') as save: json.dump(self.login_info, indent=4, sort_keys=True, fp=save) self.check_credentials_queue = queue.Queue() self.log_output_queue = multiprocessing.Queue() self.main_process = multiprocessing.Process( target=wg_gesucht.start_searching, args=[self.login_info, self.log_output_queue]) # create login form widgets bullet = "\u2022" self.form_frame = ttk.Frame(self) self.form_frame.columnconfigure(1, weight=1) self.email_lbl = ttk.Label(self.form_frame, text="Email: ") self.email_var = tk.StringVar() self.email_entry = ttk.Entry(self.form_frame, textvariable=self.email_var, width=field_width) self.email_var.set(self.login_info.get("email", "")) self.password_lbl = ttk.Label(self.form_frame, text="Password: "******"<Return>", lambda event: self.check_credentials('save details')) self.phone_number_lbl = ttk.Label(self.form_frame, text="Phone Number: ") self.phone_number_var = tk.StringVar() self.phone_number_entry = ttk.Entry(self.form_frame, textvariable=self.phone_number_var, width=field_width) self.phone_number_entry.bind( "<Return>", lambda event: self.check_credentials('save details')) self.form_warning_var = tk.StringVar() self.form_warning_lbl = ttk.Label(self.form_frame, style='Warning.TLabel', textvariable=self.form_warning_var) self.save_button = ttk.Button( self.form_frame, text="Save and Start", cursor=self.pointer, command=lambda: self.check_credentials('save details')) self.form_back_btn = ttk.Button( self.form_frame, text="Back", cursor=self.pointer, command=lambda: self.choose_info("save details")) # create log window widgets self.stop_restart_frame = ttk.Frame(self) self.log_stop_button = ttk.Button(self.stop_restart_frame, text="Stop", cursor=self.pointer, command=self.stop) self.log_back_button = ttk.Button( self.stop_restart_frame, text="Back", cursor=self.pointer, command=lambda: self.choose_info("log window")) self.log_restart_button = ttk.Button( self.stop_restart_frame, text="Restart", cursor=self.pointer, command=lambda: self.log_window("restart")) self.log_frame = ttk.Frame(self) self.log_text = scrolledtext.ScrolledText(self.log_frame, borderwidth=1, relief='sunken', state=tk.DISABLED) if self.login_info.get("password", "") == '' or self.login_info.get( "phone_number", "") == '': self.save_login_details("init") else: self.choose_info("init")