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 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 _set_config(self): """Method sets configuration gui Args: none Returns: void """ row = 0 font = ('Arial', 10, 'bold') tk.Label(self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_title'), font=font).grid(row=row, column=0, sticky='w') tk.Label( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_url')).grid( row=row + 1, column=0, sticky='e') self._url = tk.Entry(self._frame_right, width=70) self._url.grid(row=row + 1, column=1, padx=3, pady=3, sticky='w') tk.Label( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_user')).grid( row=row + 2, column=0, sticky='e') self._user = tk.Entry(self._frame_right, width=20) self._user.grid(row=row + 2, column=1, padx=3, pady=3, sticky='w') tk.Label(self._frame_right, text=self.trn.msg( 'htk_gitclient_repomanager_config_password')).grid( row=row + 3, column=0, sticky='e') self._passw = tk.Entry(self._frame_right, width=20) self._passw.grid(row=row + 3, column=1, padx=3, pady=3, sticky='w') tk.Label( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_name')).grid( row=row + 4, column=0, sticky='e') self._name = tk.Entry(self._frame_right, width=40) self._name.grid(row=row + 4, column=1, padx=3, pady=3, sticky='w') tk.Label( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_email')).grid( row=row + 5, column=0, sticky='e') self._email = tk.Entry(self._frame_right, width=40) self._email.grid(row=row + 5, column=1, padx=3, pady=3, sticky='w') error = tk.Label(self._frame_right, text='', foreground='#FF0000') error.grid(row=row + 6, column=1, sticky='w') btn = tk.Button( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_config_save'), command=lambda: self._save_config(self._url.get(), self._user.get( ), self._passw.get(), self._name.get(), self._email.get(), error)) btn.grid(row=row + 6, column=2, padx=3, pady=3, sticky='e')
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 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 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())
def set_tool(self, key, image, tooltip, command, enable=True): """Method sets tool button Args: key (str): tool key image (str): image file tooltip (str): langtext command (callback): command enable (bool): enable tool Returns: void """ if (key not in self._images): self._images[key] = tk.PhotoImage(file=path.join(self._imgdir, image)) state = tk.NORMAL if (enable) else tk.DISABLED btn = tk.Button(self._tool_bar, command=command, image=self._images[key], relief=tk.FLAT, state=state) btn.image = self._images[key] btn.pack(side=tk.LEFT) self._tools[key] = btn self._tooltips[key] = ToolTip(btn, self.trn.msg(tooltip))
def _set_commit(self): """Method sets commit gui Args: none Returns: void """ row = 7 font = ('Arial', 10, 'bold') tk.Label(self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_title'), font=font).grid(row=row, column=0, sticky='w') tk.Label(self._frame_right, text=self.trn.msg( 'htk_gitclient_repomanager_commit_message')).grid( row=row + 1, column=0, sticky='e') self._msg = tk.Text(self._frame_right, background='#FFFFFF', height=7, width=50) self._msg.grid(row=row + 1, column=1, rowspan=2, sticky='w') row += 1 tk.Label( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_author')).grid( row=row + 3, column=0, sticky='e') self._author = tk.Entry(self._frame_right, width=40) self._author.grid(row=row + 3, column=1, padx=3, pady=3, sticky='w') push = tk.BooleanVar(value=True) tk.Checkbutton( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_push'), variable=push).grid(row=row + 3, column=2, sticky='e') error = tk.Label(self._frame_right, text='', foreground='#FF0000') error.grid(row=row + 4, column=1, sticky='w') btn = tk.Button( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_commit'), command=lambda: self._commit(self._msg.get( '1.0', 'end-1c'), self._author.get(), [], push.get(), error)) btn.grid(row=row + 4, column=2, padx=3, pady=3, sticky='e') tk.Label(self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_files'), font=font).grid(row=row + 5, column=0, sticky='w') select_all = tk.BooleanVar(value=False) tk.Checkbutton( self._frame_right, text=self.trn.msg('htk_gitclient_repomanager_commit_select_all'), variable=select_all, command=lambda: self._select_all_files(select_all.get())).grid( row=row + 6, column=1, sticky='w') self._files_bar = ttk.Scrollbar(self._frame_right, orient=tk.VERTICAL) self._files = ttk.Treeview(self._frame_right, columns=('operation', 'file'), show='tree', displaycolumns=('operation', 'file'), height=10, selectmode='browse', yscrollcommand=self._files_bar.set) self._files_bar.configure(command=self._files.yview) self._files.grid(row=row + 7, column=1, sticky=tk.NSEW) self._files_bar.grid(row=row + 7, column=2, sticky='nsw') self._files.column('#0', stretch=False, width=40) self._files.column('operation', stretch=False, width=50) self._files.column('file', stretch=True, width=200) self._files.bind('<ButtonRelease-1>', self._select_file) self._files.bind('<Any-KeyRelease>', self._select_file)