def _set_menu(self, title, label, parent=''): """Method sets menu Args: title (str): menu title, used to register in root.menus label (str): langtext parent (str): parent menu (must be registered, otherwise will be added to menubar) Returns: void """ if (parent in self.root.menus): menu = tk.Menu(self.root.menus[parent], tearoff=False) self.root.menus[title] = menu self.root.menus[parent].add_cascade(label=self.trn.msg(label), menu=menu) else: menu = tk.Menu(self.root.menu_bar, tearoff=False) self.root.menus[title] = menu idx = self.root.menu_bar.index(tk.END) self.root.menu_bar.insert_cascade(idx, label=self.trn.msg(label), menu=menu)
def _set_menu_edit(self): """Method sets edit menu Args: none Returns: void """ menu_edit = tk.Menu(self._menu_bar, tearoff=False) self._menus['edit'] = menu_edit self._menu_bar.add_cascade(label=self.trn.msg('htk_gui_menu_edit'), menu=menu_edit) # menu items menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_undo'), accelerator='Ctrl+Z', command=self.editor.undo, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_redo'), accelerator='Ctrl+Y', command=self.editor.redo, state=tk.DISABLED) menu_edit.add_separator() menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_cut'), accelerator='Ctrl+X', command=self.editor.cut, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_copy'), accelerator='Ctrl+C', command=self.editor.copy, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_paste'), accelerator='Ctrl+V', command=self.editor.paste, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_delete'), accelerator='Delete', command=self.editor.delete, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_select_all'), accelerator='Ctrl+A', command=self.editor.select_all, state=tk.DISABLED) menu_edit.add_separator() menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_goto'), accelerator='Ctrl+G', command=self.editor.win_goto, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_find'), accelerator='Ctrl+F', command=self.editor.win_find, state=tk.DISABLED) menu_edit.add_command(label=self.trn.msg('htk_gui_menu_edit_replace'), accelerator='Ctrl+R', command=self.editor.win_replace, state=tk.DISABLED) # shorcuts self.bind('<Control-a>', self.editor.select_all) self.bind('<Control-g>', self.editor.win_goto) self.bind('<Control-f>', self.editor.win_find) self.bind('<Control-r>', self.editor.win_replace)
def _set_window(self): """Method sets window Args: none Returns: void """ self.title('HydraTK') self._imgdir = path.join(path.dirname(path.dirname(__file__)), 'img') self._images['logo'] = tk.PhotoImage(file=path.join(self._imgdir, 'logo.gif')) self.tk.call('wm', 'iconphoto', self._w, self._images['logo']) if (c_os == 'Windows'): self.wm_state('zoomed') else: self.wm_attributes('-zoomed', True) self.protocol('WM_DELETE_WINDOW', self._exit) self._menu_bar = tk.Menu(self) self.config(menu=self._menu_bar) self._tool_bar = tk.Frame(self) self._tool_bar.pack(expand=False, fill=tk.X) self._frame_main = tk.Frame(self) self._frame_main.pack(expand=True, fill=tk.BOTH) self._pane_main = tk.PanedWindow(self._frame_main, orient=tk.HORIZONTAL, sashwidth=10) self._pane_main.pack(expand=True, fill=tk.BOTH, padx=10, pady=(6, 10))
def _set_menu_file(self): """Method sets file menu Args: none Returns: void """ menu_file = tk.Menu(self._menu_bar, tearoff=False) self._menus['file'] = menu_file self._menu_bar.add_cascade(label=self.trn.msg('htk_gui_menu_file'), menu=menu_file) # submenu new menu_file_new = tk.Menu(menu_file, tearoff=False) self._menus['file_new'] = menu_file_new menu_file.add_cascade(label=self.trn.msg('htk_gui_menu_file_new'), menu=menu_file_new) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_file'), accelerator='Ctrl+N', command=self.editor.new_file) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_directory'), command=self.explorer.new_directory) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_project'), command=self.explorer.new_project) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_helper'), command=self.explorer.new_helper) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_library'), command=self.explorer.new_library) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_test'), command=self.explorer.new_test) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_archive'), command=self.explorer.new_archive) menu_file_new.add_command(label=self.trn.msg('htk_gui_menu_file_new_draft'), command=self.explorer.new_draft) # menu items menu_file.add_command(label=self.trn.msg('htk_gui_menu_file_open'), accelerator='Ctrl+O', command=self.editor.open_file) menu_file.add_command(label=self.trn.msg('htk_gui_menu_file_save_as'), command=self.editor.save_as_file, state=tk.DISABLED) menu_file.add_command(label=self.trn.msg('htk_gui_menu_file_save'), accelerator='Ctrl+S', command=self.editor.save_file, state=tk.DISABLED) menu_file.add_separator() menu_file.add_command(label=self.trn.msg('htk_gui_menu_file_exit'), accelerator='Ctrl+Q', command=self._exit) # shortcuts self.bind('<Control-n>', self.editor.new_file) self.bind('<Control-o>', self.editor.open_file) self.bind('<Control-s>', self.editor.save_file) self.bind('<Control-q>', self._exit)
def _set_menu(self): """Method sets menu Args: none Returns: void """ self._menu = tk.Menu(self._log, tearoff=False) self._menu.add_command(label=self.trn.msg('htk_gui_log_menu_clear'), command=self._clear) self._log.bind('<Button-3>', self._context_menu)
def _set_menu_help(self): """Method sets help menu Args: none Returns: void """ self._help = Help.get_instance() menu_help = tk.Menu(self._menu_bar, tearoff=False) self._menus['help'] = menu_help self._menu_bar.add_cascade(label=self.trn.msg('htk_gui_menu_help'), menu=menu_help) menu_help.add_command(label=self.trn.msg('htk_gui_menu_help_web_tutor'), command=self.help.web_tutor) menu_help.add_command(label=self.trn.msg('htk_gui_menu_help_web_doc'), command=self.help.web_doc) menu_help.add_separator() menu_help.add_command(label=self.trn.msg('htk_gui_menu_help_about'), command=self.help.win_about)
def _set_menu_plugin(self): """Method sets plugin menu Args: none Returns: void """ self._pluginmanager = PluginManager.get_instance() menu_plugin = tk.Menu(self._menu_bar, tearoff=False) self._menus['plugin'] = menu_plugin self._menu_bar.add_cascade(label=self.trn.msg('htk_gui_menu_plugin'), menu=menu_plugin) # menu items menu_plugin.add_command(label=self.trn.msg('htk_gui_menu_plugin_manager'), command=self.pluginmanager.show_manager) menu_plugin.add_separator()
def _set_menu_view(self): """Method sets view menu Args: none Returns: void """ menu_view = tk.Menu(self._menu_bar, tearoff=False) self._menus['view'] = menu_view self._menu_bar.add_cascade(label=self.trn.msg('htk_gui_menu_view'), menu=menu_view) # menu items menu_view.add_checkbutton(label=self.trn.msg('htk_gui_menu_view_show_line_number'), variable=self.editor.var_show_line_number, command=self.editor.show_line_number) menu_view.add_checkbutton(label=self.trn.msg('htk_gui_menu_view_show_info_bar'), variable=self.editor.var_show_info_bar, command=self.editor.show_info_bar) menu_view.add_separator() menu_view.add_command(label=self.trn.msg('htk_gui_menu_view_increase_font'), accelerator='Ctrl+MouseUp', command=self.editor.increase_font, state=tk.DISABLED) menu_view.add_command(label=self.trn.msg('htk_gui_menu_view_decrease_font'), accelerator='Ctrl+MouseDown', command=self.editor.decrease_font, state=tk.DISABLED)
def _set_tree(self): """Method sets tree gui Args: none Returns: void """ self._vbar = ttk.Scrollbar(self._frame_left, orient=tk.VERTICAL) self._tree = ttk.Treeview(self._frame_left, columns=(), 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) for name, cfg in self.explorer._projects.items(): if ('git' in cfg): self._tree.insert('', 'end', text=name) # context menu self._menu = tk.Menu(self._tree, tearoff=False) self._menu.add_command( label=self.trn.msg('htk_gitclient_repomanager_push'), command=self._push) self._menu.add_command( label=self.trn.msg('htk_gitclient_repomanager_pull'), command=self._pull) # events self._tree.bind('<ButtonRelease-1>', self._fill_repo_detail) self._tree.bind('<Any-KeyRelease>', self._fill_repo_detail) self._tree.bind('<Button-3>', self._context_menu)
def _set_menu(self): """Method sets menu Args: none Returns: void """ self._menu = tk.Menu(self._text, tearoff=False) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_undo'), accelerator='Ctrl+Z', command=self.editor.undo) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_redo'), accelerator='Ctrl+Y', command=self.editor.redo) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_cut'), accelerator='Ctrl+X', command=self.editor.cut) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_copy'), accelerator='Ctrl+C', command=self.editor.copy) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_paste'), accelerator='Ctrl+V', command=self.editor.paste) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_delete'), accelerator='Delete', command=self.editor.delete) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_select_all'), accelerator='Ctrl+A', command=self.editor.select_all) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_goto'), accelerator='Ctrl+G', command=self.editor.win_goto) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_find'), accelerator='Ctrl+F', command=self.editor.win_find) self._menu.add_command(label=self.editor.trn.msg('htk_gui_editor_menu_replace'), accelerator='Ctrl+R', command=self.editor.win_replace) self._text.bind('<Button-3>', self._context_menu)
def _set_menu(self, item): """Method sets context menu according to item Args: item (obj): selected tree item Returns: void """ key = self._tree.item(item)['text'] self._menu = tk.Menu(self._tree, tearoff=False) self._tree.bind('<Button-3>', self._context_menu) if ('TEST-SCENARIO' in key.upper()): tree_path = [key] self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_scenario'), command=lambda: self._add_item('scenario', tree_path)) self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_case'), command=lambda: self._add_item('case', tree_path)) keys = [] for k in self._tests[self._current_test]['content'][key].keys(): keys.append(k.upper()) if ('PRE-REQ' not in keys): self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_prereq'), command=lambda: self._add_item('prereq', tree_path)) if ('POST-REQ' not in keys): self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_postreq'), command=lambda: self._add_item('postreq', tree_path)) if ('EVENTS' not in keys): self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_events'), command=lambda: self._add_item('events', tree_path)) elif ('TEST-CASE' in key.upper()): parent = self._tree.parent(item) tsc = self._tree.item(parent)['text'] tree_path = [tsc, key] self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_condition'), command=lambda: self._add_item('condition', tree_path)) keys = [] for k in self._tests[ self._current_test]['content'][tsc][key].keys(): keys.append(k.upper()) if ('EVENTS' not in keys): self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_events'), command=lambda: self._add_item('events', tree_path)) elif ('TEST-CONDITION' in key.upper()): parent = self._tree.parent(item) tca = self._tree.item(parent)['text'] tsc = self._tree.item(self._tree.parent(parent))['text'] tree_path = [tsc, tca, key] keys = [] for k in self._tests[ self._current_test]['content'][tsc][tca][key].keys(): keys.append(k.upper()) if ('EVENTS' not in keys): self._menu.add_command( label=self.trn.msg('htk_gui_yoda_tree_menu_add_events'), command=lambda: self._add_item('events', tree_path))
def _set_menu(self): """Method sets menu Args: none Returns: void """ self._menu = tk.Menu(self._tree, tearoff=False) self._menu_new = tk.Menu(self._menu, tearoff=False) self._menu.add_cascade(label=self.trn.msg('htk_gui_explorer_menu_new'), menu=self._menu_new) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_file'), accelerator='Ctrl+N', command=self.new_file) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_directory'), command=self.new_directory) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_project'), command=self.new_project) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_helper'), command=self.new_helper) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_library'), command=self.new_library) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_test'), command=self.new_test) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_archive'), command=self.new_archive) self._menu_new.add_command( label=self.trn.msg('htk_gui_explorer_menu_new_draft'), command=self.new_draft) self._menu.add_command( label=self.trn.msg('htk_gui_explorer_menu_open'), accelerator='Ctrl+O', command=self._open) self._menu.add_command( label=self.trn.msg('htk_gui_explorer_menu_copy'), accelerator='Ctrl+C', command=self._copy) self._menu.add_command( label=self.trn.msg('htk_gui_explorer_menu_paste'), accelerator='Ctrl+V', command=self._paste) self._menu.add_command( label=self.trn.msg('htk_gui_explorer_menu_delete'), accelerato='Delete', command=self._delete) self._menu.add_command( label=self.trn.msg('htk_gui_explorer_menu_refresh'), accelerator='F5', command=self.refresh) self._tree.bind('<Button-3>', self._context_menu)