-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateTitleRootWindow.py
More file actions
50 lines (35 loc) · 1.22 KB
/
CreateTitleRootWindow.py
File metadata and controls
50 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
from tkinter import Menu
from tkinter import Spinbox
# Create instance
win = tk.Tk()
# Add a title
win.title('Python GUI')
# tab control ---------------------
tabControl = ttk.Notebook(win) # create tab control
tab1 = ttk.Frame(tabControl) # create a tab
tabControl.add(tab1, text='Tab 1') # add the tab
tab2 = ttk.Frame(tabControl) # add a second tab
tabControl.add(tab2, text='Tab 2') # Make second tab visible
tabControl.pack(expand=1, fill='both') # Pack to make visible
containerFrame = ttk.LabelFrame(tab1, text='Container Frame to Hold Widgets')
spin = Spinbox(tab1, from_=0,to=10)
spin.grid(column=0, row=2)
#create menu bar
menuBar = Menu(tab1)
win.config(menu=menuBar)
# Add menu items
fileMenu = Menu(menuBar, tearoff=0)
fileMenu.add_command(label='New')
fileMenu.add_separator()
fileMenu.add_command(label='Exit')
menuBar.add_cascade(label='File', menu=fileMenu)
# Add another menu to the menu bar and an item
helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label='About')
menuBar.add_cascade(label='Help', menu=helpMenu)
# change the main windows icon
win.iconbitmap(r'c:\Python34\DLLs\pyc.ico')
win.mainloop()