here2share

# Tk_custom_toggle_widget.py

Dec 30th, 2021
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 10.89 KB | None | 0 0
  1. # Tk_custom_toggle_widget.py
  2.  
  3. from tkinter import *
  4. from PIL import ImageTk, Image
  5. import base64
  6.  
  7. root = Tk()
  8. root.title('Tk Toggle Switch')
  9. root.geometry("400x150")
  10.  
  11. # Define Our Images
  12. b64_on = '''
  13. iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
  14. YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAA4sSURBVGhDzVlrjFXVGV3nnHvnzsDMAAPyEBxmhIziswTS
  15. olatRUxBq6JobY1RY1uaVovVCFi1xWdNCgmxaRSjVNtaH01rU6mIWo3BHypKqdCqEUtQFGWYGeZ9X+ec
  16. rvXtc+7cAUTb9Ee/fff59t5nv9ba336d6+FzShzHU6gW0B9Nfzl9E/3/gzxA30vfQf+wEii7Pc8Lk/Ah
  17. 5TMJIPATqa6nv8wSKF3RXnxY3mHhWI61eMOqsgSnDyrDc0viqmdFLDqUpraSQKW8x8YV1rM5Ox31/igl
  18. r6O/nSS8psih5NN6KOCjqdbQn0M/YntpG/5eeAUbBp9AR9yOD8IdiDz1xCMBPpXzgDSrVVxhOcUtLNE7
  19. S7VYKgYuFkCjVO27MHUcR+YtHrk4HwRPH3kISEImCtCaacNxNbMwZ8RcnDby7DLbeIaFVrL9l6gPKsN7
  20. kQgblamvpZ+g+F1d1+D5/JPoo6WxPcS+AwdpAx5YPA37BpZpBlRhpaegna5uWFANnGmBVYxazsAr5kiI
  21. EjLiSCS4d9J8DZ9hnx3M0M8bsRCXj/4RWmraCqx0MdtPp8cwOYAAVnge1Z/KcQnbSq9jaeel6OT0in1m
  22. TcFWNMGazxBiEjbgoiAhwsIiIYVNOswihosDLQpSsAbfxQx4jGwcoC6uwzHRDDR7rcxD60OIiGRsCV/D
  23. jng7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d7WJkObcdNQH/6M/R/cXEvH/+ve4RN/p7qXXLraD/nP+PQ78Gwt1MXvM
  75. sd4ZAAAAAElFTkSuQmCC'''.strip()
  76.  
  77. b64_off = '''
  78. iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
  79. YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAAzzSURBVGhD1ZhpjFzFEcfrzbVre72sCeC1sQjiEuZwMI4A
  80. kQRboIjTBgTYkTAGPgBKEAaE4AsQgYSElASRcItDBhOCuYISkgjF2AhBDAmOIBBOm0uADzD2rvec2Zl5
  81. +f2r+83MDos/5BP8d2v6rq6qrq7ufom1IU3TXJIkddIjSF+P1aof4GeKURmrvrVAxIn06iHZKd1CTUAu
  82. po5M+VhcQvkNaDuUUu76LigvSN4Iyf6G6hC9T7pRHqfzhArR6Xck50AzvCJidMUKqzz9tI9Kv/jC6ps2
  83. i3Owi1J1wlYqK5/Ibll9BpmygVjQ+FZk5YnSjHLoQZrGNHfIIZafP99yvb1WPPPM0L8JBLUnoMeQbZ3X
  84. RDhnWUXWifnbSBZD01UWBi+5xMZWr7Z0eNiSOKHlMmGCQd0ISqWzpxhCCkaDeOo9doHIw5HlfY6WfDZ/
  85. zKetdVk6hZ06bZoVL7zQimefHcaabYUeR5bloRhA7ybalR+95x4bueUWS/v6GpOKsXV2mBUKVjptkbeN
  86. /eNFw7nMhobMZCTySVpvGkKeEPMTQrzbkdVpzjj316hFcTdEPh88wimPjHnLHXusTbpNajnGGQF9C8iU
  87. 9lDRRyq3XwK58kPXXGOj994Lf5jDMDdrb8svOt2ShYus1rtnmECrTXuSxwXTmiUbN1j9iaestmatWX+/
  88. 5eoYITNATBFzPCR4O1rrlBfJdqRujIbiMd8oIytG8HJMVU4OPNAmr1oV+EUjQKvgtY5RARhgE4nv+aHl
  89. y9nvD8IAxWbOtNySc6yy8BSr7tlLnRjDVIpHgQoFDJTPGS1WYCPlN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qilKuc6R2cpwkvSkH4uDH0p3hRt/yMmVY47DD40S6X7ZlmnTfe
  103. 6MOwrA1fc7UNzDncBg4/3IZavKHjyivNtLpT2CJAsUToWzDf+ubNtf45c6wfvk0EmbTirTQOlbGYaTFA
  104. kB3NTjzJ46AawkqSjwqnMeBJb9/f9K/hnorsUlUG0kEnb8Hvw1g3WtgaHSediEcFAyT77WeFo492fkPn
  105. nWe1P/LG+JwYQZyor/67DR5/vLepT/7HP7JU+1kQUxCCXgx83EOaCO3tSN74T8yB6gQGEDRUAirVdVZ/
  106. YeV9Hd191SblO3DJAkLIAGNjMPRgJXbqKcX5cQ4YREFUEbxEIKKxTkAqLdaNO6C+fr0fUYm2gYLZMIHq
  107. 449jK9vh9NMJcAQz4FdeMO25NTbtX69az2uvWc/r/uBzhI1rHgtaSZARkhH46ziNGOcBPhQL11lB7xIn
  108. UyhTLpghVCsACoqh7gW06c+5yGBS2odrjP40PnLAGEm2oiAdq3ig0xnuwikVRSRSPsrSvuvaodizS2j1
  109. a8SBiK/1lkKuiFqYM0k5ftAkiB5UrOMd5XLFXT+PC5aI5joehSBmwDhZ2VdJTTUQHlPfrJt3QNLLDVxH
  110. nAiv8lRHWUR1HS/YGCQzgfuOOcb62Pt9s2dbP0/hJsKs/UuX2QBvl8GfnmiDCxZ4nZDIABN5QAAO+9FH
  111. LFDBFZHCDrxCOW2BDHJ7rby2gcg7fOPyUM//8N/+Gt4GjC0/ugojbPEVmfrSS5b2TverqhP39u633w6G
  112. 2rKF29tTlgwONnmBZMcOS3hweb1eoRGKS0Ju2xfc+OG/fRt92F7Tp1syA0NXq34tz9AwgCsM72Tdy1Y0
  113. GSC4sI42bYqAaIA2RcNVoq2u8ct42utjZatu3RweRYoZGLry8ENIwDy4ZPd/37Luzz6z7s8/t+733vPR
  114. uuBUeJekigdRybCZSOHhjywRSqddU72+xqtUkGEUUxIUlpETLkEut2hCD+C+LqQvr7MuhFbgc2AA5fJ1
  115. TNIcNw6Z1cdBE1GtlhyeUl33itXW/9u4esKHE4JgV/nNLTay/HJLN24Me16COREPtm61Ye4kFd7yyeCA
  116. JUPDgW/cv5nifhqpHOsLUe5E3yWkPPzU14+2CHlZBt0E1ZIMXnKxjf7+EV+z4m9vsx0/Oc7KmCfH8eW3
  117. vmwyVkVXYK+jHG6BkNfRpgCnk4O6vFLES0bLNnj9L230gft5LhM3EEhtibaOboNcVwsnn8yhzyJIfgSv
  118. rX3e0u3bfRu4MdX3qHBsOhTRVc88HiBpTw+eHRup/uQjP8kcyOztSkHujDNs0nXXKTvm5sII3vMr3v51
  119. rp7J/vtb/c67bSf7so5SGljgXCswkc5zv+KS1zPYjeJG0JVZxoER8+iqy4WY1R+zEZ6gQz+/1PLwLkh5
  120. SK7nniOhooBBGRokuNbFUyj2cwUgHxeVb30O+ykivvokFlRqjEsIrKm+ZoHStddakXsGfGLoTlP3n9Ki
  121. Rfxy3n/4oRUfXmlT8Yc8+z+cAGH3icJvyIVEk7HXtV2gnCbXcSSurOLIr37tAUuTOUkBkfIIndP3gpER
  122. CLdla/j3gxispGymsJd9TwfXdpLSkeR9/sZgfGNLkWpcqjEEztxRR7nyGbQFfsEEdzW84IADrcYRpULp
  123. /POtyp18oIPXFFbmmU9CgHQXJ0+Fuzl2dC9AgKJWHbMphiRffmn9F11oNS4sBVbUXR++werN1BENEmxL
  124. C2VfcU2kVO3kXUgZo9FfXilhKEc5Gn3jWN0afQvsvrt1rV0bxnFGwKOXHvaqF9MUs5l9b+MGy+m4gEmZ
  125. CJxcfoV1f/KJdeocVzcPiojhpwN5Karrrt8X8BcoKev194ztOHcJgW99MBxjPU5I4EguaDtpFqVReH3Y
  126. 9O2hu4FWV6Ry7K8Rvh3YLiHYuYka7Q0j7rabdd58c2jDF6A/KyMP2ANhtpE+yuDFDJKsto0LRu3TT92K
  127. OkOLCxda+rPFVuudySjpyg/MFQhZb/cCd/0337LKgw9aZc1q01Gk56+vPORG0KSaoB0S2FMRqyfB9XTV
  128. MzhTwvtISRK5Nzx9Mfh1g6oP5CuvFdc4jd99mnXceqsVeH1GvEn/OcqMkwUjPA6dRaPktG2HHooRPvPv
  129. An4H363HcgfsbyVeYvViyfKnnmH1nTssffEFy/PMHHnqSQZx8dC9XgpLcQQVM+WVqn7cpK2Q8JkiEl5K
  130. yAOkhOozgkfr8YYzRuU1FpfPDIDL5w46yErLl1vhyCPDHGab0W8meh5M+i4jmqDyVJJlZM5iImY2G7zh
  131. BhtesQJFd7pwmkv3fAniticNTIJimeKZwhMpPm7SVtDgvIklUiRz+4ZBVC/ES40+tAQgicZlBqCvIn7n
  132. TTdZ8YQTYh9HpvzRpP9UxddkofEUkqXRCBzSASOP/MGG7rnHxt552xX3gOMrwr+virJNZaW4mGcGEHzF
  133. WqFxrXB+cIkrGLwA4hWpT1qhnX999NCHjbgNGmN7eqzASZabO9dKbNkW6AvIJuR0t29FmwRNYIgHSE6D
  134. 9vKK7yYU7PTqeg7lr1AFeukaOEgZ6+3CAO1gYNvyfatRRsFwt98lzP4H0inYpEVSpZAAAAAASUVORK5C
  135. YII='''.strip()
  136.  
  137. b64data = [base64.b64decode(b64) for b64 in (b64_on,b64_off)]
  138. on, off = [PhotoImage(data=img) for img in b64data]
  139.  
  140. '''
  141.  
  142. # ... Or...
  143.  
  144. # Define Our Images
  145. on = PhotoImage(file="images/on.png")
  146. off = PhotoImage(file="images/off.png")
  147. '''
  148.  
  149. # Keep track of the button state on/off
  150. global is_on
  151. is_on = True
  152.  
  153. # Create Label
  154. my_label = Label(root,
  155.     text="The Switch Is On!",
  156.     fg="green",
  157.     font=("Helvetica", 32))
  158.  
  159. my_label.pack(pady=5)
  160.  
  161.  
  162. # Define our switch function
  163. def switch():
  164.     global is_on
  165.     # Determin is on or off
  166.     if is_on:
  167.         on_button.config(image=off)
  168.         my_label.config(text="The Switch Is Off", fg="white", bg="grey20")
  169.         on_button.config(bg="grey20", activebackground="grey20")
  170.         root.config(bg="grey20")
  171.         is_on = False
  172.     else:
  173.         on_button.config(image=on)
  174.         my_label.config(text="The Switch Is On", fg="green", bg="lightgrey")
  175.         on_button.config(bg="lightgrey", activebackground="lightgrey")
  176.         root.config(bg="lightgrey")
  177.         is_on = True
  178.  
  179. # Create A Button
  180. on_button = Button(root, image=on, bd=0, command=switch)
  181. on_button.pack(pady=10)
  182.  
  183. root.mainloop()
  184.  
Add Comment
Please, Sign In to add comment