-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy path36. tkinter basics 1 - Intro.py
59 lines (35 loc) · 1.58 KB
/
36. tkinter basics 1 - Intro.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
55
56
57
58
'''
Hello and welcome to a basic intro to TKinter, which is the Python
binding to TK, which is a toolkit that works around the Tcl language.
The tkinter module purpose to to generate GUIs, like windows. Python is not very
popularly used for this purpose, but it is more than capable of being used
'''
# Simple enough, just import everything from tkinter.
from tkinter import *
# Here, we are creating our class, Window, and inheriting from the Frame
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
class Window(Frame):
# Define settings upon initialization. Here you can specify
def __init__(self, master=None):
# parameters that you want to send through the Frame class.
# self, and this is the parent widget
# if you are wondering what self is... it is the object
# created from the class. You can actually call it anything
# you want... people just use "self"
Frame.__init__(self, master)
#reference to the master widget, which is the tk window
self.master = master
#with that, we want to then run init_window, which doesn't yet exist
#self.init_window()
#Creation of init_window
#def init_window(self):
# changing the title of our master widget
# self.master.title("GUI")
# root window created. Here, that would be the only window, but
# you can later have windows within windows.
root = Tk()
#///root.geometry("250x150+300+300")
#creation of an instance
app = Window(root)
#mainloop
root.mainloop()