Profilo di Gianmaria Battistella

Nome Gianmaria Battistella
Indirizzo email [email protected]
AvatarAvatar utenti
Messaggi1
  • Tkinter.ttk Map for Theme
    Forum >> Programmazione Python >> GUI
    sto seguendo un esempio con un libro
    from tkinter import *
    from tkinter.ttk import *
    def Pressed():
    if myText.get()=='NO':
    myText.set('YES')
    else:
    myText.set('NO')

    def Pressed2():
    if myText2.get()=='NO':
    myText2.set('YES')
    else:
    myText2.set('NO')

    def button():
    BT=Style()
    BT.theme_use('classic')
    BT.configure('exit.TButton',
    background='blue',
    foreground='white',
    highlightthickness='5',
    font=('helvetica 34 bold italic'))

    BT.map('exit.Tbutton',
    foreground=[('disabled','yellow'),
    ('pressed','red'),
    ('active','blue')],
    background=[('disabled','black'),
    ('pressed','cyan'),
    ('active','green')],
    highlightcolor=[('focus','green'),
    ('!focus','red')],
    relief=[('pressed','groove'),
    ('!pressed','raised')])

    Button1=Button(root,
    textvariable=myText,command=Pressed,style='exit.TButton')
    Button1.grid(column=0,row=0)

    Button2=Button(root,
    textvariable=myText2,command=Pressed2,style='exit.TButton')
    Button2.grid(column=1,row=0)

    if __name__=="__main__":
    root=Tk()
    root.title("Finestra Giammi")
    root.geometry("500x100+200+10")
    myText=StringVar()
    myText.set('YES')

    myText2=StringVar()
    myText2.set('NO')

    button()
    root.mainloop()il programma gira ma mi pare che non esegua la parte relativa al mapovvero non cambiano i colori in base allo stato .. dove sbaglio ?

    grazieGian




    --- Ultima modifica di Giammi77 in data 2015-06-07 15:57:52 ---