Am liebsten hätte ich die Buttons Rund
und ja es sind eigentlich Checkboxen die müssten dann aber auch nicht wie Checkboxen aussehen weil das ist - bäh.
Deswegen habe ich die Buttons genommen um sie eventuell später durch Bilder auszutauschen.
Im Moment habe ich die Frames als Klassen und die Buttons quasi nur als Eigenschaften dieser.
[codebox=python file=Unbenannt.txt]
class FrameDefinition:
def __init__(self, master, dictionary):
self.row = dictionary[ "row" ]
self.col = dictionary[ "col" ]
self.sticky = dictionary[ "sticky" ]
self.text = dictionary[ "text" ]
self.frame = LabelFrame(master, text=self.text)
self.frame.grid(row=self.row, column=self.col, sticky=self.sticky)
self.widgets = {}
def return_frame(self):
#no one cares
def registerentry(self, text, row, col, sticky, number):
# no one cares
def register_skillbutton(self, text="", row=0, col=0, sticky="w", skill="", favorite=False, value=0):
if favorite:
color = "black"
else:
color = "grey"
widgetsign = str(skill)
widgetsign = widgetsign + "F"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.change_favoriteskill(skill))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
col += 1
widgetsign = str(skill) + "L"
self.widgets[ widgetsign ] = Label(self.frame, text=skill).grid(row=row, column=col, sticky=sticky)
col += 1
widgetsign = str(skill) + "B"
if value >= 1:
color = "black"
else:
color = "grey"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.set_skill(skill, 1))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
col += 1
if value >= 2:
color = "black"
else:
color = "grey"
widgetsign = widgetsign + "B"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.set_skill(skill, 2))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
col += 1
if value >= 3:
color = "black"
else:
color = "grey"
widgetsign = widgetsign + "B"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.set_skill(skill, 3))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
col += 1
if value >= 4:
color = "black"
else:
color = "grey"
widgetsign = widgetsign + "B"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.set_skill(skill, 4))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
col += 1
if value >= 5:
color = "black"
else:
color = "grey"
widgetsign = widgetsign + "B"
self.widgets[ widgetsign ] = Button(self.frame, text=text, height=1, width=2, bg=color,
command=lambda: chardata.set_skill(skill, 5))
self.widgets[ widgetsign ].grid(row=row, column=col, sticky=sticky)
def register_attributebutton(self, text="", row=0, col=0, sticky="w", attribute="", value=1):
# sieht ähnlich dem Skill Button aus nur ohne den Favored Teil
[/code]
Im Prinzip fehlt mir genau diese Rückruf Funktion.
Hm die Buttons mit einer Vorschleife zu erzeugen wäre wohl schöner.