def _display(self, event=None): """Method displays tooltip Args: event (obj): event Returns: void """ x, y, cx, cy = self._parent.bbox('insert') x += self._parent.winfo_rootx() + 25 y += self._parent.winfo_rooty() + 20 self._win = tk.Toplevel(self._parent) self._win.wm_overrideredirect(True) self._win.wm_geometry("+%d+%d" % (x, y)) label = tk.Label(self._win, text=self._text, justify='left', background='#FFFF00', relief='solid', borderwidth=1) label.pack(ipadx=1)
def win_goto(self, event=None): """Method displays Goto window Args: event (obj): event Returns: void """ tab = self.nb.get_current_tab() if (tab is not None): win = tk.Toplevel(self.root) win.title(self.trn.msg('htk_gui_editor_goto_title')) win.transient(self.root) win.resizable(False, False) win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 2, self.root.winfo_screenheight() / 2)) win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo']) tk.Label(win, text=self.trn.msg('htk_gui_editor_goto_text')).pack( side=tk.LEFT, padx=3) entry = tk.Entry(win, width=15) entry.pack(side=tk.LEFT, padx=3) entry.focus_set() btn = tk.Button(win, text='OK', command=lambda: self._goto(entry.get(), win)) btn.pack(side=tk.LEFT, padx=3) win.bind('<Escape>', lambda f: win.destroy())
def _win_repomanager(self): """Method displays repository manager window Args: none Returns: void """ self._win = tk.Toplevel(self.root) self._win.title(self.trn.msg('htk_gitclient_repomanager_title')) self._win.transient(self.root) self._win.resizable(False, False) self._win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 5, self.root.winfo_screenheight() / 10)) self._win.tk.call('wm', 'iconphoto', self._win._w, self.root.images['logo']) self._pane = tk.PanedWindow(self._win, orient=tk.HORIZONTAL) self._pane.pack(expand=True, fill=tk.BOTH) # left frame self._frame_left = tk.Frame(self._pane) self._set_tree() self._pane.add(self._frame_left) # right frame self._frame_right = tk.Frame(self._pane) self._set_config() self._set_commit() self._pane.add(self._frame_right) self._win.bind('<Escape>', lambda f: self._win.destroy())
def win_replace(self, event=None): """Method displays Replace window Args: event (obj): event Returns: void """ tab = self.nb.get_current_tab() if (tab is not None): win = tk.Toplevel(self.root) win.title(self.trn.msg('htk_gui_editor_replace_title')) win.transient(self.root) win.resizable(False, False) win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 2, self.root.winfo_screenheight() / 2)) win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo']) tk.Label(win, text=self.trn.msg('htk_gui_editor_replace_find')).grid( row=0, column=0, sticky='e') find_entry = tk.Entry(win, width=50) find_entry.grid(row=0, column=1, padx=3, sticky='e') find_entry.focus_set() tk.Label(win, text=self.trn.msg('htk_gui_editor_replace_replace')).grid( row=1, column=0, pady=3, sticky='e') replace_entry = tk.Entry(win, width=50) replace_entry.grid(row=1, column=1, padx=3, sticky='e') replace_all = tk.BooleanVar(value=True) tk.Checkbutton( win, text=self.trn.msg('htk_gui_editor_replace_replace_all'), variable=replace_all).grid(row=2, column=1, pady=3, sticky='w') ignore_case = tk.BooleanVar(value=True) tk.Checkbutton( win, text=self.trn.msg('htk_gui_editor_replace_ignore_case'), variable=ignore_case).grid(row=3, column=1, sticky='w') regexp = tk.BooleanVar() tk.Checkbutton(win, text=self.trn.msg('htk_gui_editor_replace_regexp'), variable=regexp).grid(row=4, column=1, sticky='w') btn = tk.Button( win, text='OK', command=lambda: self._replace(find_entry.get( ), replace_entry.get(), replace_all.get(), ignore_case.get(), regexp.get(), win)) btn.grid(row=0, column=2, padx=3, sticky='e') win.bind('<Escape>', lambda f: win.destroy())
def _win_clone(self): """Method displays clone window Args: none Returns: void """ win = tk.Toplevel(self.root) win.title(self.trn.msg('htk_gitclient_clone_title')) win.transient(self.root) win.resizable(False, False) win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3, self.root.winfo_screenheight() / 3)) win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo']) tk.Label(win, text=self.trn.msg('htk_gitclient_clone_url')).grid(row=0, column=0, sticky='e') url = tk.Entry(win, width=70) url.grid(row=0, column=1, padx=3, pady=10, sticky='e') url.focus_set() tk.Label(win, text=self.trn.msg('htk_gitclient_clone_user')).grid( row=1, column=0, sticky='e') user = tk.Entry(win, width=20) user.grid(row=1, column=1, padx=3, pady=3, sticky='w') tk.Label(win, text=self.trn.msg('htk_gitclient_clone_password')).grid( row=2, column=0, sticky='e') passw = tk.Entry(win, width=20) passw.grid(row=2, column=1, padx=3, pady=3, sticky='w') tk.Label(win, text=self.trn.msg('htk_gitclient_clone_dirpath')).grid( row=3, column=0, sticky='e') dirpath = tk.Entry(win, width=70) dirpath.grid(row=3, column=1, padx=3, pady=3, sticky='w') tk.Button(win, text='...', command=lambda: self._set_dirpath(dirpath)).grid(row=3, column=2, sticky='w') error = tk.Label(win, text='', foreground='#FF0000') error.grid(row=4, column=1, sticky='w') btn = tk.Button( win, text=self.trn.msg('htk_gitclient_clone_button'), command=lambda: self._clone_repo(url.get(), dirpath.get( ), user.get(), passw.get(), error, win)) btn.grid(row=4, column=2, padx=3, pady=3, sticky='e') win.bind('<Escape>', lambda f: win.destroy())
def show_manager(self): """Method shows manager window Args: none Returns: void """ win = tk.Toplevel(self.root) win.title(self.trn.msg('htk_gui_plugin_manager_title')) win.transient(self.root) win.resizable(False, False) win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3, self.root.winfo_screenheight() / 3)) win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo']) win.focus_set() font = ('Arial', 10, 'bold') tk.Label(win, text=self.trn.msg('htk_gui_plugin_manager_name'), font=font, width=25, anchor='w', padx=3, pady=3).grid(row=0, column=0) tk.Label(win, text=self.trn.msg('htk_gui_plugin_manager_enabled'), font=font, anchor='w', padx=3, pady=3).grid(row=0, column=1) i = 1 states = {} for name, cfg in self.config.data['Plugins'].items(): tk.Label(win, text=name, width=25, anchor='w', padx=3).grid(row=i, column=0) state = True if ('enabled' in cfg and cfg['enabled'] == 1) else False var = tk.IntVar(value=state) tk.Checkbutton(win, variable=var).grid(row=i, column=1, padx=3, sticky='w') states[name] = var i += 1 btn = tk.Button(win, text=self.trn.msg('htk_gui_plugin_manager_save'), command=lambda: self._update_state(states, win)) btn.grid(row=i, column=2, padx=3, pady=3, sticky='e') win.bind('<Escape>', lambda f: win.destroy())
def _set_gui(self, completions): """Method sets graphical interface Args: completions (list): code completions Returns: void """ self._win = tk.Toplevel(self.root) self._win.title('') self._win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3, self.root.winfo_screenheight() / 3)) self._win.tk.call('wm', 'iconphoto', self._win._w, self.root.images['logo']) self._vbar = ttk.Scrollbar(self._win, orient=tk.VERTICAL) self._tree = ttk.Treeview(self._win, columns=('complete', 'type', 'params'), show='tree', displaycolumns=(), height=10, selectmode='browse', yscrollcommand=self._vbar.set) self._vbar.config(command=self._tree.yview) self._vbar.pack(side=tk.RIGHT, fill=tk.Y) self._tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) self._win.bind('<Escape>', lambda f: self._win.destroy()) self._tree.bind('<Double-1>', self._complete) self._tree.bind('<Return>', self._complete) for c in completions: try: params = [] for p in c.params: params.append(p.name) params = ','.join(params) self._tree.insert('', 'end', text=c.name, values=(c.complete, c.type, params)) except (AttributeError, NotImplementedError): self._tree.insert('', 'end', text=c.name, values=(c.complete, c.type, '')) self._tree.focus(self._tree.get_children()[0]) self._tree.focus_set()
def win_about(self): """Method displays About window Args: none Returns: void """ win = tk.Toplevel(self.root) win.title(self.trn.msg('htk_gui_help_about_title')) win.transient(self.root) win.resizable(False, False) win.geometry('+%d+%d' % (self.root.winfo_screenwidth() / 3, self.root.winfo_screenheight() / 3)) win.tk.call('wm', 'iconphoto', win._w, self.root.images['logo']) text = tk.Text(win, background='#FFFFFF') text.pack(expand=True, fill=tk.BOTH) text.focus_set() content = """Client for HydraTK Version: 0.1.0 Web: http://hydratk.org Copyright (c) 2017-2018 Petr Rašek ([email protected]) HydraTK team ([email protected]) All rights reserved.""" text.insert(tk.END, content) text.configure(state=tk.DISABLED) tk.Button(win, text='Web', command=lambda: open('http://hydratk.org')).pack(side=tk.LEFT, pady=3) tk.Button(win, text='E-mail', command=lambda: open('mailto:[email protected]')).pack(side=tk.LEFT, padx=3, pady=3) tk.Button(win, text='OK', command=lambda: win.destroy()).pack(side=tk.RIGHT, pady=3) win.bind('<Escape>', lambda f: win.destroy())