Guest User

Untitled

a guest
Jul 17th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox
  3.  
  4. def isSet():
  5.     radioValue = radioBoxValue.get()
  6.     tkinter.messagebox.showinfo("You clicked ", radioValue)
  7.      
  8. def changeLabel():
  9.     tst = "Thanks for the click " + inputBoxValue.get()
  10.     textOfLabel.set(tst)
  11.     inputBox.delete(0, END)
  12.     inputBox.insert(0, "My name is Matthias")
  13.    
  14.  
  15. app = Tk()
  16. app.title("This is the title")
  17. app.geometry("640x480+100+100")
  18.  
  19. textOfLabel = StringVar()
  20. textOfLabel.set("This is a label")
  21.  
  22. firstLabel = Label(app, textvariable = textOfLabel)
  23. firstLabel.grid(row=0, column=0, sticky=W)
  24.  
  25. checkBoxValue = IntVar()
  26. checkBox1 = Checkbutton(app, variable = checkBoxValue, text = "Happy?")
  27. checkBox1.grid(row=1, column=0, sticky=W)
  28.  
  29. inputBoxValue = StringVar()
  30. inputBox = Entry(app, textvariable=inputBoxValue)
  31. inputBox.grid(row=2, column=0, sticky=W)
  32.  
  33. radioBoxValue = StringVar()
  34. radioBoxValue.set(None)
  35. #For some reason you can only use ONE name for ALL your radioboxes. In other words. Every radiobox is named
  36. #radioBox = Radiobutton(app, ...........blabla)
  37. #each radioBox has its own position on the grid though which has to be set immediately after spawning
  38. #the radiobutton.
  39.  
  40. #spawning
  41. radioBox = Radiobutton(app, text="Single", value = "Single!", variable = radioBoxValue, command=isSet)
  42. #setting location
  43. radioBox.grid(row=4, column=0, sticky=W)
  44. #spawning
  45. radioBox = Radiobutton(app, text="Married", value = "Married!", variable = radioBoxValue, command=isSet)
  46. #setting location
  47. radioBox.grid(row=4, column=1, sticky=W)
  48.  
  49. button1 = Button(app, text='Click me!', width = 20, command = changeLabel)
  50. button1.grid(row=5, column=2, sticky=W)
  51.  
  52. app.mainloop()
Add Comment
Please, Sign In to add comment