Hatte mir eingebildet das die zip-Funktion keine dictionarys zusammenfassen kann. Funktioniert allerdings einfandfrei
, danke.
Jetzt ist allerdings ein neues Problem aufgetaucht:
Ich erstelle, mit einer Klasse, ein Fenster und mainloope es. Normalerweise konnte ich, nachdem ich diesen mainloop ausgefuehrt hatte, weiterhin die Oberflaeche, ich diesem Fall eine canvas Oberflaeche veraendern und um es erscheinen zu lassen, updaten:
Code: Alles auswählen
class Root(object):
def __init__(self):
self.fieldlist = {'bottom': ((206, 81, 223, 98), (226, 81, 243, 98), (246, 81, 263, 98),
(206, 101, 223, 118), (226, 101, 243, 118), (246, 101, 263, 118),
(206, 121, 223, 138), (226, 121, 243, 138), (246, 121, 263, 138)),
'front': ((326, 141, 343, 158), (346, 141, 363, 158), (366, 141, 383, 158),
(326, 161, 343, 178), (346, 161, 363, 178), (366, 161, 383, 178),
(326, 181, 343, 198), (346, 181, 363, 198), (366, 181, 383, 198))}
self.root = Tk()
self.root.title("Ein Rubik Cube Programm")
self.bgcanvas = Canvas(self.root, width=710, height=400, bg='#2ff2ff2ff').pack()
self.canvas = Canvas(self.root, width=650, height=220, bg='grey')
self.canvas.place(x=30,y=30)
self.root.mainloop()
def placing_fields(self,colorlist=Cube().main()):
for seite in self.fieldlist:
for position in zip(self.fieldlist[seite],colorlist[seite]):
self.canvas.create_rectangle(position[0][0],position[0][1],position[0][2],position[0][3],fill=position[1])
self.root.update()
Root().placing_fields()
Jetzt kommt allerdings folgende Fahlermeldung:
Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\workspace\Training - Python\src\uebung.py", line 157, in <module>
Root().placing_fields()
File "C:\Dokumente und Einstellungen\workspace\Training - Python\src\uebung.py", line 154, in placing_fields
self.canvas.create_rectangle(position[0][0],position[0][1],position[0][2],position[0][3],fill=position[1])
File "C:\Python25\lib\lib-tk\Tkinter.py", line 2166, in create_rectangle
return self._create('rectangle', args, kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 2145, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: invalid command name ".12420240"
Das Fenster oeffnet sich wie gewohnt, wenn ich den mainloop aus Zeile 22 loesche und ihn statt dem update in Zeile 28 aufrufe. Doch dann ist das Programm logischerweise unbrauchbar.