Advertisement
Guest User

Untitled

a guest
May 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. # Import the Tkinter functions
  2. from Tkinter import *
  3.  
  4. # Create a window
  5. the_window = Tk()
  6. the_window.geometry('460x200')
  7.  
  8. # Give the window a title
  9. the_window.title('Show Columns')
  10.  
  11. #Declare Radio Variable
  12. radio_var = IntVar(value=0)
  13.  
  14. #Change first set colour
  15. def change_first_set_colour():
  16.  
  17. #Determine colour to display
  18. if radio_var == 1:
  19. label1.configure(bg="blue")
  20. label2.configure(bg="blue")
  21. label3.configure(bg="blue")
  22. label4.configure(bg="blue")
  23. else:
  24. label1.configure(bg="grey")
  25. label2.configure(bg="grey")
  26. label3.configure(bg="grey")
  27. label4.configure(bg="grey")
  28.  
  29. #Change first set colour
  30. def change_second_set_colour():
  31.  
  32. #Determine colour to display
  33. if radio_var == 2:
  34. label1.configure(bg="blue")
  35. label2.configure(bg="blue")
  36. label3.configure(bg="blue")
  37. label4.configure(bg="blue")
  38. else:
  39. label1.configure(bg="grey")
  40. label2.configure(bg="grey")
  41. label3.configure(bg="grey")
  42. label4.configure(bg="grey")
  43.  
  44. #Change first set colour
  45. def change_third_set_colour():
  46.  
  47. #Determine colour to display
  48. if radio_var == 3:
  49. label1.configure(bg="blue")
  50. label2.configure(bg="blue")
  51. label3.configure(bg="blue")
  52. label4.configure(bg="blue")
  53. else:
  54. label1.configure(bg="grey")
  55. label2.configure(bg="grey")
  56. label3.configure(bg="grey")
  57. label4.configure(bg="grey")
  58.  
  59. #Create label1
  60. label1 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  61. label1.place(x=5, y=5)
  62.  
  63. #Create label2
  64. label2 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  65. label2.place(x=5, y=45)
  66.  
  67. #Create label3
  68. label3 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  69. label3.place(x=5, y=85)
  70.  
  71. #Create label4
  72. label4 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  73. label4.place(x=5, y=125)
  74.  
  75. #Create Radio Button 1
  76. Radio_1 = Radiobutton(the_window,
  77. text="First",
  78. variable=radio_var,
  79. command=change_first_set_colour,
  80. value=1)
  81. Radio_1.place(x=50, y=165)
  82.  
  83. #Create label5
  84. label5 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  85. label5.place(x=155, y=5)
  86.  
  87. #Create label6
  88. label6 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  89. label6.place(x=155, y=45)
  90.  
  91. #Create label7
  92. label7 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  93. label7.place(x=155, y=85)
  94.  
  95. #Create label8
  96. label8 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  97. label8.place(x=155, y=125)
  98.  
  99. #Create Radio Button 2
  100. Radio_2 = Radiobutton(the_window,
  101. text="Second",
  102. variable=radio_var,
  103. command=change_second_set_colour,
  104. value=2)
  105. Radio_2.place(x=180, y=165)
  106.  
  107. #Create label9
  108. label9 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  109. label9.place(x=305, y=5)
  110.  
  111. #Create label10
  112. label10 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  113. label10.place(x=305, y=45)
  114.  
  115. #Create label11
  116. label11 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  117. label11.place(x=305, y=85)
  118.  
  119. #Create label12
  120. label12 = Label(the_window, bg="grey", fg="black", width=20, height=2)
  121. label12.place(x=305, y=125)
  122.  
  123. Radio_3 = Radiobutton(the_window,
  124. text="Third",
  125. variable=radio_var,
  126. command=change_third_set_colour,
  127. value=3)
  128. Radio_3.place(x=345, y=165)
  129.  
  130. #----------------------------------------------------------------
  131.  
  132. # Start the event loop to react to user inputs
  133. the_window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement