Hello, does any of you have an idea how you can program a GUI with Tkinter, using different interfaces (for example, different arrangement of buttons)? Or has someone already programmed something like that?
Thanks, Woody
Code: Select all
from tkinter import *
import threading
import time
master = Tk()
page = 0
timer = 0
canvas = Canvas(width=1280, height=720, bg='black')
canvas.grid(rowspan=5, columnspan=8, sticky='W,E,N,S')
def background_math():
global timer
start = time.time()
while 1:
now = time.time()
timer = now - start
time.sleep(1)
def main_page():
global page
page = 0
block.config(bg='red', text=page)
block.grid(padx=5, pady=10, row=0, column=0, sticky='W,E,N,S')
next_page.config(command=page_1)
time_label.config(text="script run for " + ("%02d" % timer) + " seconds")
master.update_idletasks()
def page_1():
global page
page = 1
block.config(bg='green', text=page)
block.grid(padx=5, pady=10, row=1, column=1, sticky='W,E,N,S')
next_page.config(command=page_2)
time_label.config(text="script run for " + ("%02d" % timer) + " seconds")
master.update_idletasks()
def page_2():
global page
page = 2
block.config(bg='pink', text=page)
block.grid(padx=5, pady=10, row=2, column=2, sticky='W,E,N,S')
next_page.config(command=page_3)
time_label.config(text="script run for " + ("%02d" % timer) + " seconds")
master.update_idletasks()
def page_3():
global page
page = 3
block.config(bg='blue', text=page)
block.grid(padx=5, pady=10, row=3, column=3, sticky='W,E,N,S')
next_page.config(command=main_page)
time_label.config(text="script run for " + ("%02d" % timer) + " seconds")
master.update_idletasks()
block = Label(master, text=page, width=20, font=('aharoni', 18, 'bold'), bg='red', fg='white')
block.grid(padx=5, pady=10, row=0, column=0, sticky='W,E,N,S')
next_page = Button(master, text="+", width=5, font=('aharoni', 18, 'bold'), bg='orange', fg='white')
next_page.grid(padx=10, pady=10, row=4, column=7, sticky='W,E,N,S')
time_label = Label(master, width=10, font=('aharoni', 18, 'bold'), bg='black', fg='white')
time_label.grid(padx=5, pady=10, row=4, column=0, columnspan=4, sticky='W,E,N,S')
main_page()
t = threading.Thread(target=background_math)
t.daemon = True
t.start()
master.mainloop()