i'm completely new to python and try to wrap my head about the following problem. I need to create buttons from an sql query. Right now one button looks like this (i skip style things)
def __init__ (self, screen):
self.frame = Frame(screen)
self.frame.grid()
self.button01Image = PhotoImage(file=row[2])
self.button01 = Button(
self.frame,
image = self.button01Image,
command = self.button01Activate,
)
self.button01.grid(row = 0, column = 0)
def button01Activate(self):
self.button01.configure(
state = DISABLED
)
dosomething(23)
dosomething(01)
result (row) from sql query looks like this
('01', '23', 'picturefilename.png' ,'0')
In the end i want something like this, yes i know that it doesn't work.
def __init__ (self, screen):
self.frame = Frame(screen)
self.frame.grid()
self.button + row[0] Image = PhotoImage(file=row[2])
self.button + row[0] = Button(
self.frame,
image = self.button01Image,
command = self.button01Activate,
)
if row[3] == 0
self.button + row[0] + .configure(
state = DISABLED
)
#counting up to a 3x5 grid)
self.button + row[0] + .grid(row = 0, column = 0)
def button + row[0] + Activate(self):
self.button + row[0] + .configure(
state = DISABLED
)
dosomething(row[1])
dosomethingelse(row[0])
So basically i need to assign functions and pictures to the button from the database.
I got no clue where to start change things here, i guess my approach is completely wrong. Can somebody point me into the right direction?