. Sorry.
Also die Sache ist so, ich habe 4Checkbuttons, und je nach reihenfolge der "On/Off" Werte, also 0/1, wird ein Wert ausgegeben. Bis jetzt muss ich nach jeder Änderung der Checkbuttons wieder auf einen normalen Button klicken der dann einen CMD ausführt welcher dann die 4Checkbutton Werte aus gibt. Also 4 mal 0 oder 1.
Ach herrje ist das kompliziert. Ich hoffe du hast das ganze verstanden... Ich poste im Anhang mal den Code damit du mich dann hoffentlich verstehst...
Code: Alles auswählen
from random import randint
from Tkinter import *
from thread import start_new_thread
from time import sleep
dict={
'[0, 0, 0, 0]':'0',
'[1, 0, 0, 0]':'1',
'[0, 1, 0, 0]':'2',
'[0, 0, 1, 0]':'3',
'[0, 0, 0, 1]':'4',
'[1, 1, 0, 0]':'5',
'[1, 0, 1, 0]':'6',
'[1, 0, 0, 1]':'7',
'[1, 1, 1, 0]':'8',
'[1, 1, 0, 1]':'9',
'[1, 1, 1, 1]':':',
'[0, 1, 0, 1]':'=',
'[1, 0, 1, 1]':' ',
'[0, 1, 1, 0]':'.',
'[0, 1, 1, 1]':',',
'[0, 0, 1, 1]':'E'
}
redict={
'0':'[0, 0, 0, 0]',
'1':'[1, 0, 0, 0]',
'2':'[0, 1, 0, 0]',
'3':'[0, 0, 1, 0]',
'4':'[0, 0, 0, 1]',
'5':'[1, 1, 0, 0]',
'6':'[1, 0, 1, 0]',
'7':'[1, 0, 0, 1]',
'8':'[1, 1, 1, 0]',
'9':'[1, 1, 0, 1]',
':':'[1, 1, 1, 1]',
'=':'[0, 1, 0, 1]',
' ':'[1, 0, 1, 1]',
'.':'[0, 1, 1, 0]',
',':'[0, 1, 1, 1]',
'E':'[0, 0, 1, 1]'
}
def update(A, B, C, D, resulta):
while 1:
go(A, B, C, D, resulta)
sleep(0.1)
def go(A, B, C, D, resulta, *key):
if A=='':
A=0
if B=='':
B=0
if C=='':
C=0
if D=='':
D=0
A, B, C, D=str(A), str(B), str(C), str(D)
a=dict['['+A+', '+B+', '+C+', '+D+']']
try: resulta.destroy()
except: pass
result=Label(root, text=' ', font="TimesNewRoman -50")
result.place(x=30, y=100)
result=Label(root, text=a, font="TimesNewRoman -50")
result.place(x=30, y=100)
def set_it(A, B, C, D, Ac, Bc, Cc, Dc, resulta):
if (A==1):
Ac.select()
if (B==1):
Bc.select()
if (C==1):
Cc.select()
if (D==1):
Dc.select()
if (A==0):
Ac.deselect()
if (B==0):
Bc.deselect()
if (C==0):
Cc.deselect()
if (D==0):
Dc.deselect()
go(A, B, C, D, resulta)
def convert(result, Ac, Bc, Cc, Dc, resulta):
if result==():
result=('0')
list=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '=', ' ', '.', ',', 'E']
A=int(redict[list[int(result[0])]][1])
B=int(redict[list[int(result[0])]][4])
C=int(redict[list[int(result[0])]][7])
D=int(redict[list[int(result[0])]][10])
set_it(A, B, C, D, Ac, Bc, Cc, Dc, resulta)
root=Tk()
root.minsize(170, 240)
root.maxsize(170, 240)
result=Label(root)
Label(root, text='A').place(x=5, y=0)
A, B, C, D=StringVar(), StringVar(), StringVar(), StringVar()
Ac=Checkbutton(root, variable=A)
Ac.place(x=0, y=15)
Label(root, text='B').place(x=25, y=0)
Bc=Checkbutton(root, variable=B)
Bc.place(x=20, y=15)
Label(root, text='C').place(x=45, y=0)
Cc=Checkbutton(root, variable=C)
Cc.place(x=40, y=15)
Label(root, text='D').place(x=65, y=0)
Dc=Checkbutton(root, variable=D)
Dc.place(x=60, y=15)
Button(root, text="Update!", command=lambda:go(A.get(), B.get(), C.get(), D.get(), result)).place(x=40, y=70)
root.bind('<Return>', lambda x:go(A.get(), B.get(), C.get(), D.get(), result))
box=Listbox(root, width=4, height=16)
box.place(x=100, y=0)
for i in range(0, 10):
box.insert(END, str(i))
box.insert(END, ':')
box.insert(END, '=')
box.insert(END, ' ')
box.insert(END, '.')
box.insert(END, ',')
box.insert(END, 'E')
box.bind('<Button-1>', lambda x:convert(box.curselection(), Ac, Bc, Cc, Dc, result))
#start_new_thread(update, (A.get(), B.get(), C.get(), D.get(), result))
root.mainloop()