Python GUI questions

maiden129 sengokubasarafever at gmail.com
Wed Mar 20 03:36:28 CET 2013


On Tuesday, March 19, 2013 10:16:25 PM UTC-4, Rick Johnson wrote:
> On Mar 19, 8:25 pm, maiden129 <sengokubasarafe... at gmail.com> wrote:



So should I redo my other code that I created with the radioButtons to change the colors of a text?

from tkinter import *

class buttons:
    def __init__(self):
        window = Tk()
        window.title("Radio buttons and buttons")
        
        self.var = IntVar()
        

        w1 =  Radiobutton(window, text="Red", variable=self.var, value=1,command=changeColor).pack()
        w2 =  Radiobutton(window, text="Yellow", variable=self.var, value=2,command=changeColor).pack()
        w3 =  Radiobutton(window, text="White", variable=self.var, value=3,command=changeColor).pack()
        w4 =  Radiobutton(window, text="Grey", variable=self.var, value=4,command=changeColor).pack()
        w5 =  Radiobutton(window, text="Green", variable=self.var, value=5,command=changeColor).pack()
        B1 = Button ( window, text="<=", command=LEFT).pack()
        B2 = Button ( window, text="=>", command=RIGHT).pack()

    def changeColor(self):
        self.var.get()
        

        
        window.mainloop()


buttons()






More information about the Python-list mailing list