Python tkinter.ttk.Notebook() Examples
The following are 30
code examples of tkinter.ttk.Notebook().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter.ttk
, or try the search function
.
Example #1
Source File: GUI_DesignPattern.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 14 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Monty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) self.createButtons()
Example #2
Source File: program12.py From python-gui-demos with MIT License | 10 votes |
def __init__(self, master): self.master = master self.notebk = ttk.Notebook(self.master) self.notebk.pack() self.frame1 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN) self.frame2 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN) self.notebk.add(self.frame1, text = 'One') self.notebk.add(self.frame2, text = 'Two') self.btn = ttk.Button(self.frame1, text='Add/Insert Tab at Position 1', command = self.AddTab) self.btn.pack() self.btn2 = ttk.Button(self.frame1, text='Disable Tab at Position 1', command = self.disableTab) self.btn2.pack() strdisplay = r'Tab ID:{}'.format(self.notebk.select()) ttk.Label(self.frame1, text = strdisplay).pack() strdisplay2 = 'Tab index:{}'.format(self.notebk.index(self.notebk.select())) ttk.Label(self.frame1, text = strdisplay2).pack()
Example #3
Source File: annotation_gui.py From SEM with MIT License | 9 votes |
def preferences(self, event=None): preferenceTop = tkinter.Toplevel() preferenceTop.focus_set() notebook = ttk.Notebook(preferenceTop) frame1 = ttk.Frame(notebook) notebook.add(frame1, text='general') frame2 = ttk.Frame(notebook) notebook.add(frame2, text='shortcuts') c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word) c.pack() shortcuts_vars = [] shortcuts_gui = [] cur_row = 0 j = -1 frame_list = [] frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts")) frame_list[-1].pack(fill="both", expand="yes") for i, shortcut in enumerate(self.shortcuts): j += 1 key, cmd, bindings = shortcut name, command = cmd shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key)) tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W) entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j]) entry.grid(row=cur_row, column=1) cur_row += 1 notebook.pack() # # ? menu methods #
Example #4
Source File: main_gui.py From JAVER_Assist with MIT License | 7 votes |
def __tabs_creator(self): style = ttk.Style() style.theme_create('st', settings={ ".": { "configure": { "background": self.__BG_GREY, "font": self.__FONT } }, "TNotebook": { "configure": { "tabmargins": [2, 5, 0, 0], } }, "TNotebook.Tab": { "configure": { "padding": [10, 2] }, "map": { "background": [("selected", self.__FG_GREY)], "expand": [("selected", [1, 1, 1, 0])] } } }) style.theme_use('st') tab_control = ttk.Notebook(self.root) tab1 = ttk.Frame(tab_control) tab_control.add(tab1, text='主页') self.__tab1_content(tab1) tab2 = ttk.Frame(tab_control) tab_control.add(tab2, text='设置') self.__tab2_content(tab2) tab3 = ttk.Frame(tab_control) tab_control.add(tab3, text='关于') tab_control.place(x=0, y=0, width=900, height=550)
Example #5
Source File: chapter8_05.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 6 votes |
def __init__(self): super().__init__() self.title("Ttk Notebook") todos = { "Home": ["Do the laundry", "Go grocery shopping"], "Work": ["Install Python", "Learn Tkinter", "Reply emails"], "Vacations": ["Relax!"] } self.notebook = ttk.Notebook(self, width=250, height=100, padding=10) for key, value in todos.items(): frame = ttk.Frame(self.notebook) self.notebook.add(frame, text=key, underline=0, sticky=tk.NE + tk.SW) for text in value: ttk.Label(frame, text=text).pack(anchor=tk.W) self.label = ttk.Label(self) self.notebook.pack() self.label.pack(anchor=tk.W) self.notebook.enable_traversal() self.notebook.bind("<<NotebookTabChanged>>", self.select_tab)
Example #6
Source File: workflowcreator.py From CEASIOMpy with Apache License 2.0 | 6 votes |
def __init__(self, master=None, **kwargs): tk.Frame.__init__(self, master, **kwargs) self.pack(fill=tk.BOTH) self.Options = WorkflowOptions() space_label = tk.Label(self, text=' ') space_label.grid(column=0, row=0) # Input CPACS file self.label = tk.Label(self, text=' Input CPACS file') self.label.grid(column=0, row=1) self.path_var = tk.StringVar() self.path_var.set(self.Options.cpacs_path) value_entry = tk.Entry(self, textvariable=self.path_var, width= 45) value_entry.grid(column=1, row=1) self.browse_button = tk.Button(self, text="Browse", command=self._browse_file) self.browse_button.grid(column=2, row=1, pady=5) # Notebook for tabs self.tabs = ttk.Notebook(self) self.tabs.grid(column=0, row=2, columnspan=3,padx=10,pady=10) self.TabPre = Tab(self, 'Pre') self.TabOptim = Tab(self, 'Optim') self.TabPost = Tab(self, 'Post') self.tabs.add(self.TabPre, text=self.TabPre.name) self.tabs.add(self.TabOptim, text=self.TabOptim.name) self.tabs.add(self.TabPost, text=self.TabPost.name) # General buttons self.close_button = tk.Button(self, text='Save & Quit', command=self._save_quit) self.close_button.grid(column=2, row=3)
Example #7
Source File: py_gui.py From pylinac with MIT License | 6 votes |
def __init__(self, master=None): super().__init__(master) self.pack() self.notebook = Notebook(self) self.init_pf() self.init_vmat() self.init_catphan() self.init_logs() # self.init_tg51() self.init_star() self.init_planar_imaging() self.init_winstonlutz() self.init_watcher() self.init_help() for child in self.winfo_children(): child.grid_configure(padx=10, pady=10)
Example #8
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 6 votes |
def notebook_callback(event): clear_display_area() current_notebook = str(event.widget) tab_no = str(event.widget.index("current") + 1) if current_notebook.endswith('notebook'): active_notebook = 'Notebook 1' elif current_notebook.endswith('notebook2'): active_notebook = 'Notebook 2' else: active_notebook = '' if active_notebook is 'Notebook 1': if tab_no == '1': display_tab1() elif tab_no == '2': display_tab2() elif tab_no == '3': display_tab3() else: display_button(active_notebook, tab_no) else: display_button(active_notebook, tab_no) #----------------------------------------------------------- # Create GUI #-----------------------------------------------------------
Example #9
Source File: tkwidgets.py From hwk-mirror with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, *tabs, **kwargs): super().__init__(parent, **kwargs) assert all(isinstance(t, str) for t in tabs) self.style = ttk.Style(self) self.style.configure("TNotebook.Tab") self._notebook = ttk.Notebook(self, style="TNotebook") self.data = { name: tk.Frame(self._notebook) for name in tabs} self._tab_ids = {} for name in self.data: self._notebook.add(self.data[name], text=name) self._tab_ids[name] = self._notebook.tabs()[-1] self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) self._notebook.grid(row=0, column=0, sticky="nswe")
Example #10
Source File: SocialAmnesia.py From Social-Amnesia with GNU General Public License v3.0 | 5 votes |
def __init__(self, master: tk.Tk, **kw): self.master = master super().__init__(self.master, **kw) self.configure_gui() self.tabs = ttk.Notebook(self.master) self.login_frame = self.build_login_tab() self.reddit_frame = self.build_reddit_tab() self.twitter_frame = self.build_twitter_tab() self.create_tabs()
Example #11
Source File: plot.py From evo_slam with GNU General Public License v3.0 | 5 votes |
def tabbed_tk_window(self): from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk import sys if sys.version_info[0] < 3: import Tkinter as tkinter import ttk else: import tkinter from tkinter import ttk self.root_window = tkinter.Tk() self.root_window.title(self.title) # quit if the window is deleted self.root_window.protocol("WM_DELETE_WINDOW", self.root_window.quit) nb = ttk.Notebook(self.root_window) nb.grid(row=1, column=0, sticky='NESW') for name, fig in self.figures.items(): fig.tight_layout() tab = ttk.Frame(nb) canvas = FigureCanvasTkAgg(self.figures[name], master=tab) canvas.draw() canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) toolbar = NavigationToolbar2Tk(canvas, tab) toolbar.update() canvas._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) for axes in fig.get_axes(): if isinstance(axes, Axes3D): # must explicitly allow mouse dragging for 3D plots axes.mouse_init() nb.add(tab, text=name) nb.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) self.root_window.mainloop() self.root_window.destroy()
Example #12
Source File: popup_configure.py From faceswap with GNU General Public License v3.0 | 5 votes |
def build_page(self, container, category): """ Build a plugin config page """ logger.debug("Building plugin config page: '%s'", category) plugins = sorted(list(key for key in self.config_cpanel_dict[category].keys())) panel_kwargs = dict(columns=2, max_columns=2, option_columns=2, blank_nones=False) if any(plugin != category for plugin in plugins): page = ttk.Notebook(container) page.pack(side=tk.TOP, fill=tk.BOTH, expand=True) for plugin in plugins: cp_options = list(self.config_cpanel_dict[category][plugin].values()) frame = ControlPanel(page, cp_options, header_text=self.plugin_info[plugin], **panel_kwargs) title = plugin[plugin.rfind(".") + 1:] title = title.replace("_", " ").title() page.add(frame, text=title) else: cp_options = list(self.config_cpanel_dict[category][plugins[0]].values()) page = ControlPanel(container, cp_options, header_text=self.plugin_info[plugins[0]], **panel_kwargs) logger.debug("Built plugin config page: '%s'", category) return page
Example #13
Source File: display_page.py From faceswap with GNU General Public License v3.0 | 5 votes |
def add_subnotebook(self): """ Add the main frame notebook """ logger.debug("Adding subnotebook") notebook = ttk.Notebook(self) notebook.pack(side=tk.TOP, anchor=tk.NW, fill=tk.BOTH, expand=True) return notebook
Example #14
Source File: preview.py From faceswap with GNU General Public License v3.0 | 5 votes |
def _build_tabs(self): """ Build the notebook tabs for the each configuration section. """ logger.debug("Build Tabs") for section in self.config_tools.sections: tab = ttk.Notebook(self) self._tabs[section] = {"tab": tab} self.add(tab, text=section.replace("_", " ").title())
Example #15
Source File: plot.py From evo with GNU General Public License v3.0 | 5 votes |
def tabbed_tk_window(self): from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk import sys if sys.version_info[0] < 3: import Tkinter as tkinter import ttk else: import tkinter from tkinter import ttk self.root_window = tkinter.Tk() self.root_window.title(self.title) # quit if the window is deleted self.root_window.protocol("WM_DELETE_WINDOW", self.root_window.quit) nb = ttk.Notebook(self.root_window) nb.grid(row=1, column=0, sticky='NESW') for name, fig in self.figures.items(): fig.tight_layout() tab = ttk.Frame(nb) canvas = FigureCanvasTkAgg(self.figures[name], master=tab) canvas.draw() canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) toolbar = NavigationToolbar2Tk(canvas, tab) toolbar.update() canvas._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) for axes in fig.get_axes(): if isinstance(axes, Axes3D): # must explicitly allow mouse dragging for 3D plots axes.mouse_init() nb.add(tab, text=name) nb.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True) self.root_window.mainloop() self.root_window.destroy()
Example #16
Source File: test_widgets.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create(self, **kwargs): return ttk.Notebook(self.root, **kwargs)
Example #17
Source File: tkui.py From onmyoji_bot with GNU General Public License v3.0 | 5 votes |
def create_section(self): ''' 创建主选项卡 ''' self.section = ttk.Notebook(self.main_frame1) # 创建选项卡1---御魂 self.frame0 = tk.Frame(self.section) self.section.add(self.frame0, text='御魂') # 创建选项卡2---御灵 self.frame1 = tk.Frame(self.section) self.section.add(self.frame1, text='御灵') # 创建选项卡3---探索 self.frame2 = tk.Frame(self.section, padx=5, pady=5) self.section.add(self.frame2, text='探索') # 创建选项卡4---关于 self.frame3 = tk.Frame(self.section) self.section.add(self.frame3, text='关于') self.section.pack(fill=tk.BOTH, expand=True)
Example #18
Source File: __main__.py From PickTrue with MIT License | 5 votes |
def __init__(self, *args, **kwargs): super(App, self).__init__(*args, **kwargs) self.tabs = ttk.Notebook(self) self.title("PickTrue - 相册下载器 v%s" % version.__version__) self.build_menu() for downloader in downloaders: self.tabs.add(downloader(self), text=downloader.title) self.tabs.pack( side=tk.LEFT, )
Example #19
Source File: export.py From thonny with MIT License | 5 votes |
def __init__(self, master): super().__init__(master=master) self.title("Export file") self.protocol("WM_DELETE_WINDOW", self.on_cancel) mainframe = ttk.Frame(self) mainframe.grid(row=0, column=0, sticky="nsew") self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.notebook = ttk.Notebook(mainframe) self.notebook.grid(row=3, column=0, columnspan=3, padx=20, pady=(20, 0), sticky="nsew") self.ok_button = ttk.Button(mainframe, text="OK", command=self.on_ok) self.ok_button.grid(row=4, column=1, sticky="e", padx=(20, 10), pady=(10, 20)) self.cancel_button = ttk.Button(mainframe, text="Cancel", command=self.on_cancel) self.cancel_button.grid(row=4, column=2, sticky="e", padx=(0, 20), pady=(10, 20)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(3, weight=1) for title, page_class in page_specs: page = page_class(self.notebook) self.notebook.add(page, text=title)
Example #20
Source File: config_ui.py From thonny with MIT License | 5 votes |
def __init__(self, master, page_records): super().__init__(master) width = ems_to_pixels(53) height = ems_to_pixels(43) self.geometry("%dx%d" % (width, height)) self.title(_("Thonny options")) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) main_frame = ttk.Frame(self) # otherwise there is wrong color background with clam main_frame.grid(row=0, column=0, sticky=tk.NSEW) main_frame.columnconfigure(0, weight=1) main_frame.rowconfigure(0, weight=1) self._notebook = ttk.Notebook(main_frame) self._notebook.grid(row=0, column=0, columnspan=3, sticky=tk.NSEW, padx=10, pady=10) self._ok_button = ttk.Button(main_frame, text=_("OK"), command=self._ok, default="active") self._cancel_button = ttk.Button(main_frame, text=_("Cancel"), command=self._cancel) self._ok_button.grid(row=1, column=1, padx=(0, 11), pady=(0, 10)) self._cancel_button.grid(row=1, column=2, padx=(0, 11), pady=(0, 10)) self._page_records = [] for key, title, page_class, order in sorted(page_records, key=lambda r: (r[3], r[0])): try: spacer = ttk.Frame(self) spacer.rowconfigure(0, weight=1) spacer.columnconfigure(0, weight=1) page = page_class(spacer) page.key = key self._page_records.append((key, title, page)) page.grid(sticky=tk.NSEW, pady=(15, 10), padx=15) self._notebook.add(spacer, text=title) except Exception: traceback.print_exc() self.bind("<Return>", self._ok, True) self.bind("<Escape>", self._cancel, True) self._notebook.select(self._notebook.tabs()[ConfigurationDialog.last_shown_tab_index])
Example #21
Source File: replayer.py From thonny with MIT License | 5 votes |
def __init__(self): super().__init__(get_workbench(), background=lookup_style_option("TFrame", "background")) ui_utils.set_zoomed(self, True) self.main_pw = ReplayerPanedWindow(self, orient=tk.HORIZONTAL, sashwidth=10) self.center_pw = ReplayerPanedWindow(self.main_pw, orient=tk.VERTICAL, sashwidth=10) self.right_frame = ttk.Frame(self.main_pw) self.right_pw = ReplayerPanedWindow(self.right_frame, orient=tk.VERTICAL, sashwidth=10) self.editor_notebook = ReplayerEditorNotebook(self.center_pw) shell_book = ttk.Notebook(self.main_pw) self.shell = ShellFrame(shell_book) self.details_frame = EventDetailsFrame(self.right_pw) self.log_frame = LogFrame( self.right_pw, self.editor_notebook, self.shell, self.details_frame ) self.browser = ReplayerFileBrowser(self.main_pw, self.log_frame) self.control_frame = ControlFrame(self.right_frame) self.main_pw.grid(padx=10, pady=10, sticky=tk.NSEW) self.main_pw.add(self.browser, width=200) self.main_pw.add(self.center_pw, width=1000) self.main_pw.add(self.right_frame, width=200) self.center_pw.add(self.editor_notebook, height=700) self.center_pw.add(shell_book, height=300) shell_book.add(self.shell, text="Shell") self.right_pw.grid(sticky=tk.NSEW) self.control_frame.grid(sticky=tk.NSEW) self.right_pw.add(self.log_frame, height=600) self.right_pw.add(self.details_frame, height=200) self.right_frame.columnconfigure(0, weight=1) self.right_frame.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1)
Example #22
Source File: replayer.py From thonny with MIT License | 5 votes |
def __init__(self, master): ttk.Notebook.__init__(self, master, padding=0) self._editors_by_text_widget_id = {}
Example #23
Source File: debugger.py From thonny with MIT License | 5 votes |
def _init_layout_widgets(self, master, frame_info): self.main_frame = ttk.Frame( self ) # just a backgroud behind padding of main_pw, without this OS X leaves white border self.main_frame.grid(sticky=tk.NSEW) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.main_pw = ui_utils.AutomaticPanedWindow(self.main_frame, orient=tk.VERTICAL) self.main_pw.grid(sticky=tk.NSEW, padx=10, pady=10) self.main_frame.rowconfigure(0, weight=1) self.main_frame.columnconfigure(0, weight=1) self._code_book = ttk.Notebook(self.main_pw) self._text_frame = CodeView( self._code_book, first_line_number=frame_info.firstlineno, font="EditorFont" ) self._code_book.add(self._text_frame, text="Source") self.main_pw.add(self._code_book, minsize=200) self._code_book.preferred_size_in_pw = 400
Example #24
Source File: popup_configure.py From faceswap with GNU General Public License v3.0 | 5 votes |
def build(self): """ Build the config popup """ logger.debug("Building plugin config popup") container = ttk.Notebook(self.page_frame) container.pack(fill=tk.BOTH, expand=True) categories = sorted(list(self.config_cpanel_dict.keys())) if "global" in categories: # Move global to first item categories.insert(0, categories.pop(categories.index("global"))) for category in categories: page = self.build_page(container, category) container.add(page, text=category.title()) self.add_frame_separator() self.add_actions() logger.debug("Built plugin config popup")
Example #25
Source File: tkui.py From monitor_ctrl with MIT License | 5 votes |
def __init__(self, *args, **kwargs): super(TkApp, self).__init__(*args, **kwargs) self.status_text_var = tk.StringVar() self.status_text_bar = ttk.Label(self, textvariable=self.status_text_var) self.notebook = ttk.Notebook(self) self.__init_ui()
Example #26
Source File: test_widgets.py From ironpython3 with Apache License 2.0 | 5 votes |
def create(self, **kwargs): return ttk.Notebook(self.root, **kwargs)
Example #27
Source File: run_gui.py From margipose with Apache License 2.0 | 5 votes |
def __init__(self, dataset, device, model): super().__init__() self.dataset = dataset self.device = device self.model = model self.wm_title('3D pose estimation') self.geometry('1280x800') matplotlib.rcParams['savefig.format'] = 'svg' matplotlib.rcParams['savefig.directory'] = os.curdir # Variables self.var_cur_example = tk.StringVar() self.var_pred_visible = tk.IntVar(value=0) self.var_gt_visible = tk.IntVar(value=1) self.var_mpjpe = tk.StringVar(value='??') self.var_pck = tk.StringVar(value='??') self.var_aligned = tk.IntVar(value=0) self.var_joint = tk.StringVar(value='pelvis') if self.model is not None: self.var_pred_visible.set(1) global_toolbar = self._make_global_toolbar(self) global_toolbar.pack(side=tk.TOP, fill=tk.X) self.notebook = ttk.Notebook(self) self.notebook.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True, padx=4, pady=4) def on_change_tab(event): self.update_current_tab() self.notebook.bind('<<NotebookTabChanged>>', on_change_tab) self.tab_update_funcs = [ self._make_overview_tab(self.notebook), self._make_heatmap_tab(self.notebook), ] self.current_example_index = 0
Example #28
Source File: GUI_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') self.action = ttk.Button(self.monty, text="Click Me!") self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #==========================
Example #29
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def notebook_callback(event): clear_display_area() current_notebook = str(event.widget) tab_no = str(event.widget.index("current") + 1) if current_notebook.endswith('notebook'): active_notebook = 'Notebook 1' elif current_notebook.endswith('notebook2'): active_notebook = 'Notebook 2' else: active_notebook = '' if active_notebook is 'Notebook 1': if tab_no == '1': display_tab1() elif tab_no == '2': display_tab2() elif tab_no == '3': display_tab3() else: display_button(active_notebook, tab_no) else: display_button(active_notebook, tab_no) #----------------------------------------------------------- # Create GUI #-----------------------------------------------------------
Example #30
Source File: GUI_Not_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(): tabControl = ttk.Notebook(win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") monty = ttk.LabelFrame(tab1, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') action = ttk.Button(monty, text="Click Me!") action.grid(column=2, row=1) ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #======================