-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtkinter_example.py
More file actions
36 lines (26 loc) · 875 Bytes
/
tkinter_example.py
File metadata and controls
36 lines (26 loc) · 875 Bytes
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
from tkinter import *
main = Tk()
# main.geometry('1200x800')
# Example of calculation the center of the coordinate based on the screen and window width and height
main.title("TKinter Panel")
main.configure(bg = 'lightgreen')
w = 800
h = 600
# Get the screen dimensions
sw = main.winfo_screenwidth()
sh = main.winfo_screenheight()
# Find the center of the point
cx = int(sw/2 - h/2)
cy = int(sh/2 - w/2)
main.geometry(f'{w}x{h}+{cx}+{cy}')
main.resizable(False, False)
main.protocol("WM_DELETE_WINDOW",main)
# main.attributes("-fullscreen",1)
# Creating a Button widget
cmd_btn = Button(main, text="Click", fg='red', bg='white')
# Set position of Button within win-form
cmd_btn.place(x=130,y=130)
# Creating a Button widget
lbl_widget = Label(main, text="This is a Label widget using tkinter Library",fg="black",bg="white")
lbl_widget.place(x=230,y=240)
mainloop()