Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- root["bg"] = "red"
- root.geometry("+1+6")
- buts = {}
- fras = {}
- chngs = {}
- sizes = ("XS", "S", "M", "L", "XL", "XXL")
- def chng1(event):
- for f in fras:
- fras[f].configure(width=30, height=30)
- for b in buts:
- buts[b].configure(font=("Impact", 10))
- buts[b].place(width=20, height=20)
- def chng2(event):
- for f in fras:
- fras[f].configure(width=60, height=60)
- for b in buts:
- buts[b].configure(font=("Impact", 11))
- buts[b].place(width=40, height=40)
- def chng3(event):
- for f in fras:
- fras[f].configure(width=90, height=90)
- for b in buts:
- buts[b].configure(font=("Impact", 14))
- buts[b].place(width=60, height=60)
- def chng4(event):
- for f in fras:
- fras[f].configure(width=120, height=120)
- for b in buts:
- buts[b].configure(font=("Impact", 19))
- buts[b].place(width=80, height=80)
- def chng5(event):
- for f in fras:
- fras[f].configure(width=150, height=150)
- for b in buts:
- buts[b].configure(font=("Impact", 26))
- buts[b].place(width=100, height=100)
- def chng6(event):
- for f in fras:
- fras[f].configure(width=180, height=180)
- for b in buts:
- buts[b].configure(font=("Impact", 35))
- buts[b].place(width=120, height=120)
- def back(event):
- for k in range(6):
- b = "but_{}".format(sizes[k])
- f = "fra_{}".format(k + 1)
- fras[f].configure(width=30*(k+1),
- height=30*(k+1))
- buts[b].configure(font=("Impact", 10+int(k**2)))
- buts[b].place(width=20*(k+1),
- height=20*(k+1))
- fra_main = Frame(root,
- bg="blue")
- fra_main.grid(row=0,
- column=0,
- columnspan=3)
- for i in range(6):
- but = "but_{}".format(sizes[i])
- fra = "fra_{}".format(i + 1)
- fras[fra] = Frame(fra_main,
- bg="yellow",
- borderwidth=3,
- width=30 * (i + 1),
- height=30 * (i + 1))
- buts[but] = Button(fras[fra],
- text="{}".format(sizes[i]),
- font=("Impact", (10 + int(i ** 2))),
- bg="bisque",
- padx=10,
- pady=10)
- fras[fra].pack(side=LEFT,
- padx=10,
- pady=10)
- buts[but].place(width=20 * (i + 1),
- height=20 * (i + 1),
- anchor=CENTER,
- relx=0.5,
- rely=0.5)
- buts["but_XS"].bind("<Button-1>", chng1)
- buts["but_S"].bind("<Button-1>", chng2)
- buts["but_M"].bind("<Button-1>", chng3)
- buts["but_L"].bind("<Button-1>", chng4)
- buts["but_XL"].bind("<Button-1>", chng5)
- buts["but_XXL"].bind("<Button-1>", chng6)
- back_but = Button(root,
- text="Back to demo",
- padx=20,
- pady=20)
- back_but.bind("<Button-1>", back)
- back_but.grid(row=1,
- column=1,
- padx=10,
- pady=20)
- root.mainloop()
Add Comment
Please, Sign In to add comment