1from tkinter import * #import
2
3def main():
4 screen = Tk()#initialize
5 screen.geomerty("num1xnum2") #pixels
6 screen.title("Title")
7 screen.cofigure(bg = 'grey')#hex colors or normal colors
8
9 screen.mainloop()
10main()#call
1from tkinter import *
2from tkinter import ttk
3root=Tk()
4entry1=Entry(root,cursor="fleur",insertbackground="red")
5entry1.pack()
6Button(root,text="Get cursor type and colour", command=lambda: print(entry1['cursor'],entry1['insertbackground'])).pack()
7root.mainloop()
8
9
1from tkinter import *
2
3root = Tk()
4root.geometry("500x500")
5root.title("My App")
6root.config(bg="#ff0000")
7
8def printhi(*args):
9 print("Hi!")
10
11btn = Button(root, text="Click to print hi", command=printhi)
12btn.place(x=200, y=200)
13
14root.mainloop()
1Tkinter is the biuld-in GUI toolkit of python. You can
2easily make a graffical software using tkinter.
1from tkinter import * # import tkinter
2
3window = Tk() #create a window
4
5window.mainloop() #update window
6
1#The (!) is the not operator in Python, (!=) means not equal to.
2if 2!=10:
3 print("2 isn't equal to 10.")
4elif 2==10:
5 print("2 is equal to 10.")
6#Prints "2 isn't equal to 10." as 2 isn't equal to 10. Is it?
7
8#Note that "=" is used for declarations (assign a value to a variable or change the value of one) while "==" is usually used for checking.
9#Usually, "==" returns a boolean, but depends on the objects being checked if they're equal or not, that the result will be boolean.
10#For example, some NumPy objects when checked will return values other than boolean (other than True or False).
11
12#For example:
13
14a = 10
15print(a)
16
17#will return the int 10
18#Now,
19
20print(a==10)
21
22#will return a boolean, True as we have assigned the value of a as 10
23
24#Another example (to make it easier and to avoid confusion) would be where
25
26a = 10
27b = 10
28
29#and
30
31print(a==b)
32
33#will return a boolean, True as they're equal.
34
35