我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用ttk.Notebook()。
def __init__(self): tk.Tk.__init__(self) tk.Tk.wm_title(self, "Smart Trader System") if os.name == "nt": tk.Tk.iconbitmap(self, default="app_icon.ico") self.configure(background = StColors.dark_grey) set_app_style() # Top section (header) title = ttk.Label(self, text="Smart Trader Portal", font=("Tahoma", 25, 'bold')) title.pack() # Lower section (tabs area) notebook = ttk.Notebook(self) notebook.pack() # Create Controllers and add their views explore = ExploreController(self) train = TrainingController(self) backtest= BacktestController(self) forecast= ForecastController(self) for view_frame in (explore.view, train.view, backtest.view, forecast.view): view_frame.grid(row=0, column=0, sticky="nsew") notebook.add(view_frame, text = view_frame.title)
def __init__(self, parent, controller): ttk.Notebook.__init__(self, parent) self.controller = controller datalist = list(range(1,7)) datalist.insert(0,'-') #Create the pages serialcfgframe = SerialTab(self, self.controller) datacfgframe = DataTab(self, self.controller) graph1frame = GraphTab(self, self.controller, 1) graph2frame = GraphTab(self, self.controller, 2) graph3frame = GraphTab(self, self.controller, 3) #Add them to the notebook self.add(datacfgframe, text='Data') self.add(serialcfgframe, text='Serial') self.add(graph1frame, text='Graph 1') self.add(graph2frame, text='Graph 2') self.add(graph3frame, text='Graph 3')
def _layout_basic(self): """ Defines the basic layout of the application. """ main = ttk.Notebook(self.gui) main.pack(fill='both', expand='yes') # create a child frame for each application pane frames = (Frame(), Frame(), Frame(), Frame()) # add the pages to the handler main.add(frames[0], text='Experimental Design') main.add(frames[1], text='Simulate Datasets') main.add(frames[2], text='Run Pipelines') main.add(frames[3], text='Result Summary') # Add the log handler. log = ttk.Notebook(self.gui) log.pack(fill='both', expand='yes') log_frame = Frame() log.add(log_frame, text='Log') # ... and the logging console self.console = Text(log_frame, name="console", height=10) self.console.pack(side='bottom', anchor='sw', expand='yes', fill=BOTH) return frames
def create(self, **kwargs): return ttk.Notebook(self.root, **kwargs)
def setUp(self): support.root_deiconify() self.nb = ttk.Notebook(padding=0) self.child1 = ttk.Label() self.child2 = ttk.Label() self.nb.add(self.child1, text='a') self.nb.add(self.child2, text='b')
def __init__(self, parent): """ Initialise main window. """ self.parent = parent self.parent.title("PIEFACE Input GUI") # Make all errors propagated to MainWindow.parent call custom exception routine parent.report_callback_exception = self.report_callback_exception self.filenames = [] self.nbookmain = ttk.Notebook(self.parent) self.intab = ttk.Frame(self.nbookmain) self.logtab = ttk.Frame(self.nbookmain) self.nbookmain.add(self.intab, text='Input', sticky='nesw') self.nbookmain.add(self.logtab, text='Output log', sticky='nesw', state=tk.NORMAL) self.log = LogDisplay(self.logtab) #self.log.__init__(self.logtab) self.log.pack(expand=1, fill=tk.BOTH) self.init_menu() self.init_gui(self.intab) self.nbookmain.pack(expand=1, fill=tk.BOTH) self.intab.columnconfigure(0, weight=1) self.intab.rowconfigure(0, weight=1) self.nbookmain.select(self.logtab) self.nbookmain.select(self.intab) self.find_updates(verbose=False) self.phases = {}
def make_plot_win(self, selected): """ Create Toplevel window with selected data plotted """ if len(selected) == 0: tkMessageBox.showerror('Error','Please select files to plot results.') return for selection in selected: if self.filenames[selection] not in self.phases: tkMessageBox.showerror('Error','No results exist for {0}'.format(self.filebox.get(selection))) continue if len( self.phases[self.filenames[selection]].polyhedra ) == 0: tkMessageBox.showerror('Error','No valid polyhedra exist for {0}'.format(self.filebox.get(selection))) crystob = self.phases[self.filenames[selection]] self.plotwin = tk.Toplevel() self.plotwin.iconbitmap(iconloc) self.plotwin.title("PIEFACE Ellipsoid Plots") self.plotnb = ttk.Notebook(self.plotwin) tabs = {} figs = {} for poly in sorted(crystob.polyhedra): #Iterate through all polyhedra in Crystal object tabs[poly] = ttk.Frame(self.plotnb) self.plotnb.add(tabs[poly], text=poly, sticky='nesw') figs[poly] = PlotWindow(tabs[poly]) figs[poly].updateplot(getattr(crystob, poly+'_poly').ellipsoid, title=self.filebox.get(selection), pointcolor = getattr(crystob, poly+"_poly").pointcolours()) figs[poly].pack(expand=1, fill=tk.BOTH) self.plotnb.pack(expand=1, fill=tk.BOTH)
def __init__(self, name, local_server_ip=None, local_server_port=None, launch_tor=True, tor_socks_port=None, tor_control_port=None, local_mode=False): super(Gui, self).__init__() self.calls_queue = Queue.Queue() self.title(APP_NAME) self.peer = None frame_notebook = Tk.Frame(self) frame_notebook.pack() self.notebook = ttk.Notebook(frame_notebook) self.notebook.pack() self.notebook.pack(fill=Tk.BOTH, expand=True) # hidden tab used only to set the size of the window hidden_tab = ChatTab(parent=self.notebook, gui=self, peer=self.peer, conversation=None) self.notebook.add(hidden_tab, text='Hidden') self.notebook.hide(hidden_tab) self.bootstrap_tab = BootstrapTab(parent=self.notebook, gui=self) self.menu_bar = Tk.Menu(self) self.menu_bar.add_command(label='New Chat', state=Tk.DISABLED, command=self.create_request) self.menu_bar.add_command(label='Copy Identity', state=Tk.DISABLED, command=self.copy_identity) self.menu_bar.add_command(label='Copy Key', state=Tk.DISABLED, command=self.copy_key) self.menu_bar.add_command(label='Copy Peer', state=Tk.DISABLED, command=self.copy_peer) self.menu_bar.add_command(label='Copy Onion', state=Tk.DISABLED, command=self.copy_onion) self.menu_bar.add_command(label='Quit', command=self.quit) self.config(menu=self.menu_bar) if name: self.init_peer(name, local_server_ip, local_server_port, launch_tor, tor_socks_port, tor_control_port, local_mode) else: self.tab_new = PeerCreationTab(parent=self.notebook, gui=self) self.notebook.add(self.tab_new, text='Start Peer', sticky=Tk.NS) self.check_calls()