MCPcopy Create free account
hub / github.com/ActiveState/code / demo

Function demo

recipes/Python/541092_tkNotebook/recipe-541092.py:132–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 self.iteratedTabs += 1 #Add one to the loop count
131
132def demo():
133 def adjustCanvas(someVariable = None):
134 fontLabel["font"] = ("arial", var.get())
135
136 root = Tk()
137 root.title("tkNotebook Example")
138 note = Notebook(root, width= 400, height =400, activefg = 'red', inactivefg = 'blue') #Create a Note book Instance
139 note.grid()
140 tab1 = note.add_tab(text = "Tab One") #Create a tab with the text "Tab One"
141 tab2 = note.add_tab(text = "Tab Two") #Create a tab with the text "Tab Two"
142 tab3 = note.add_tab(text = "Tab Three") #Create a tab with the text "Tab Three"
143 tab4 = note.add_tab(text = "Tab Four") #Create a tab with the text "Tab Four"
144 tab5 = note.add_tab(text = "Tab Five") #Create a tab with the text "Tab Five"
145 Label(tab1, text = 'Tab one').grid(row = 0, column = 0) #Use each created tab as a parent, etc etc...
146 Label(tab1, text = "When something is changed on a tab,\ngoing to a different tab and back\nwill not reset, or effect it in any way.", font = ("Comic Sans MS", 12, "italic")).grid()
147 var = IntVar()
148 var.set(10)
149 scale = Scale(tab1, font = ("arial", 10), orient = 'horizontal', command = adjustCanvas, variable =var).grid()
150 fontLabel = Label(tab1, text = "TEXT", font = ("Arial", 10))
151 fontLabel.grid()
152 Label(tab2, text = 'Tab Two\n\n(Has focus first by using the focus_on attribute)\n\nThe tabs are colored red and blue via\nthe Notebook options. The default\nvalues are black on black :P', font = ("Comic Sans MS", 12, "italic")).grid()
153 Button(tab3, text = 'Destroy Tab Four!', command = lambda:note.destroy_tab(tab4)).grid()
154 Label(tab3, text = "Destroying a tab will remove it,\nand competely destoy all child widgets.\nOnce you destroy a tab, you have to recreate it\ncompletely in order to get it back.", font = ("Comic Sans MS", 12, "italic")).grid()
155 Label(tab4, text = 'Tab 4').grid()
156 Button(tab5, text = 'Tab One', command = lambda:note.focus_on(tab1)).grid(pady = 3)
157 Button(tab5, text = 'EXIT', width = 23, command = root.destroy).grid()
158 note.focus_on(tab2)
159 root.mainloop()
160
161if __name__ == "__main__":
162 demo()

Callers 1

recipe-541092.pyFile · 0.70

Calls 12

add_tabMethod · 0.95
destroy_tabMethod · 0.95
focus_onMethod · 0.95
NotebookClass · 0.85
LabelClass · 0.85
ScaleClass · 0.85
mainloopMethod · 0.80
TkClass · 0.50
ButtonClass · 0.50
titleMethod · 0.45
gridMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected