Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.messagebox
- def isSet():
- radioValue = radioBoxValue.get()
- tkinter.messagebox.showinfo("You clicked ", radioValue)
- def changeLabel():
- tst = "Thanks for the click " + inputBoxValue.get()
- textOfLabel.set(tst)
- inputBox.delete(0, END)
- inputBox.insert(0, "My name is Matthias")
- app = Tk()
- app.title("This is the title")
- app.geometry("640x480+100+100")
- textOfLabel = StringVar()
- textOfLabel.set("This is a label")
- firstLabel = Label(app, textvariable = textOfLabel)
- firstLabel.grid(row=0, column=0, sticky=W)
- checkBoxValue = IntVar()
- checkBox1 = Checkbutton(app, variable = checkBoxValue, text = "Happy?")
- checkBox1.grid(row=1, column=0, sticky=W)
- inputBoxValue = StringVar()
- inputBox = Entry(app, textvariable=inputBoxValue)
- inputBox.grid(row=2, column=0, sticky=W)
- radioBoxValue = StringVar()
- radioBoxValue.set(None)
- #For some reason you can only use ONE name for ALL your radioboxes. In other words. Every radiobox is named
- #radioBox = Radiobutton(app, ...........blabla)
- #each radioBox has its own position on the grid though which has to be set immediately after spawning
- #the radiobutton.
- #spawning
- radioBox = Radiobutton(app, text="Single", value = "Single!", variable = radioBoxValue, command=isSet)
- #setting location
- radioBox.grid(row=4, column=0, sticky=W)
- #spawning
- radioBox = Radiobutton(app, text="Married", value = "Married!", variable = radioBoxValue, command=isSet)
- #setting location
- radioBox.grid(row=4, column=1, sticky=W)
- button1 = Button(app, text='Click me!', width = 20, command = changeLabel)
- button1.grid(row=5, column=2, sticky=W)
- app.mainloop()
Add Comment
Please, Sign In to add comment