-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI_OOP.py
55 lines (45 loc) · 1.85 KB
/
GUI_OOP.py
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
50
51
52
53
54
'''
May 2017
@author: Burkhard
'''
import tkinter as tk
from tkinter import ttk
from tkinter import scrolledtext
from tkinter import Menu
class OOP():
def __init__(self):
self.win = tk.Tk()
self.win.title("Python GUI")
self.createWidgets()
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()
#==========================
oop = OOP()
oop.win.mainloop()