Guest User

Untitled

a guest
Mar 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. root = Tk()
  4. root["bg"] = "red"
  5. root.geometry("+1+6")
  6.  
  7. buts = {}
  8. fras = {}
  9. chngs = {}
  10. sizes = ("XS", "S", "M", "L", "XL", "XXL")
  11.  
  12.  
  13. def chng1(event):
  14. for f in fras:
  15. fras[f].configure(width=30, height=30)
  16. for b in buts:
  17. buts[b].configure(font=("Impact", 10))
  18. buts[b].place(width=20, height=20)
  19.  
  20.  
  21. def chng2(event):
  22. for f in fras:
  23. fras[f].configure(width=60, height=60)
  24. for b in buts:
  25. buts[b].configure(font=("Impact", 11))
  26. buts[b].place(width=40, height=40)
  27.  
  28.  
  29. def chng3(event):
  30. for f in fras:
  31. fras[f].configure(width=90, height=90)
  32. for b in buts:
  33. buts[b].configure(font=("Impact", 14))
  34. buts[b].place(width=60, height=60)
  35.  
  36.  
  37. def chng4(event):
  38. for f in fras:
  39. fras[f].configure(width=120, height=120)
  40. for b in buts:
  41. buts[b].configure(font=("Impact", 19))
  42. buts[b].place(width=80, height=80)
  43.  
  44.  
  45. def chng5(event):
  46. for f in fras:
  47. fras[f].configure(width=150, height=150)
  48. for b in buts:
  49. buts[b].configure(font=("Impact", 26))
  50. buts[b].place(width=100, height=100)
  51.  
  52.  
  53. def chng6(event):
  54. for f in fras:
  55. fras[f].configure(width=180, height=180)
  56. for b in buts:
  57. buts[b].configure(font=("Impact", 35))
  58. buts[b].place(width=120, height=120)
  59.  
  60.  
  61. def back(event):
  62. for k in range(6):
  63. b = "but_{}".format(sizes[k])
  64. f = "fra_{}".format(k + 1)
  65.  
  66. fras[f].configure(width=30*(k+1),
  67. height=30*(k+1))
  68. buts[b].configure(font=("Impact", 10+int(k**2)))
  69. buts[b].place(width=20*(k+1),
  70. height=20*(k+1))
  71.  
  72.  
  73. fra_main = Frame(root,
  74. bg="blue")
  75. fra_main.grid(row=0,
  76. column=0,
  77. columnspan=3)
  78.  
  79. for i in range(6):
  80. but = "but_{}".format(sizes[i])
  81. fra = "fra_{}".format(i + 1)
  82. fras[fra] = Frame(fra_main,
  83. bg="yellow",
  84. borderwidth=3,
  85. width=30 * (i + 1),
  86. height=30 * (i + 1))
  87. buts[but] = Button(fras[fra],
  88. text="{}".format(sizes[i]),
  89. font=("Impact", (10 + int(i ** 2))),
  90. bg="bisque",
  91. padx=10,
  92. pady=10)
  93. fras[fra].pack(side=LEFT,
  94. padx=10,
  95. pady=10)
  96. buts[but].place(width=20 * (i + 1),
  97. height=20 * (i + 1),
  98. anchor=CENTER,
  99. relx=0.5,
  100. rely=0.5)
  101.  
  102. buts["but_XS"].bind("<Button-1>", chng1)
  103. buts["but_S"].bind("<Button-1>", chng2)
  104. buts["but_M"].bind("<Button-1>", chng3)
  105. buts["but_L"].bind("<Button-1>", chng4)
  106. buts["but_XL"].bind("<Button-1>", chng5)
  107. buts["but_XXL"].bind("<Button-1>", chng6)
  108.  
  109. back_but = Button(root,
  110. text="Back to demo",
  111. padx=20,
  112. pady=20)
  113.  
  114. back_but.bind("<Button-1>", back)
  115. back_but.grid(row=1,
  116. column=1,
  117. padx=10,
  118. pady=20)
  119. root.mainloop()
Add Comment
Please, Sign In to add comment