je nach gewählter Steurung sollen die Buttons der MVG den text ändern.
Code: Alles auswählen
# -*- coding: cp1252 -*-
from Tkinter import *
root = Tk()
v = IntVar()
v.set(1) # initializing the choice, i.e. Python
x =IntVar()
x.set(11)
#Textblock für Antriebe
MVG1 = [
("32FB422",1),
("32FB423",2),
("32FB424",3),
("32FB425",4),
("32FB426",6),
("32FB427",7),
("32FB428",8)
]
MVG2 = [
("32FB322",1),
("32FB323",2),
("32FB324",3),
("32FB325",4),
("32FB326",6),
("32FB327",7),
("32FB328",8)
]
#Textblock für Steuerung
Steuerung = [
("Block 1",11),
("Block 2",12),
("Block 3",13),
("Block 4",14),
("SPG",16)
]
def ShowChoice():
print v.get()
def ShowChoiceSPS():
print x.get()
def changeTXT():#Texte der MVG an Steuerung anpassene
nr=x.get()
if nr==11:
MVG=MVG1
elif nr==12:
MVG=MVG2
else:
MVG=[
("none",1),
("none",2),
("none",3),
("none",4),
("none",6),
("none",7),
("none",8)
]
return MVG
Label(root,
text="""Bitte Steuerung auswählen:""",
justify = LEFT,
padx = 20).pack()
for txt, val in Steuerung:
Radiobutton(root,
text=txt,
indicatoron=0,
width =20,
padx = 20,
variable=x,
command=changeTXT,
value=val).pack(anchor=W)
Label(root,
text="""Bitte Aktuellen MVG auswählen:""",
justify = LEFT,
padx = 20).pack()
MVG = changeTXT() #Textändern
for txt, val in MVG:
Radiobutton(root,
text=txt,
indicatoron=0,
width =20,
padx = 20,
variable=v,
command=ShowChoice,
value=val).pack(anchor=W)
mainloop()