Nov-22-2019, 10:37 PM
Well that's kind of what I had in mind...
So I changed my code and now it works but it's awful :(
Then I create my 6 buttons.
Finaly I overwrite the buttons where '-' is set
If you have any better suggestions...?
So I changed my code and now it works but it's awful :(
keys = [] names = [] for key, name in self.__model.get_6_users().items(): keys.append(key) names.append(name) for i in range(len(keys), 6): keys.append('-') names.append('-') Button(acceuil, text=names[0], command=lambda: self.click_user(keys[0])). \ grid(column=0, row=2, sticky=N + S + W + E) Button(acceuil, text=names[1], command=lambda: self.click_user(keys[1])). \ grid(column=1, row=2, sticky=N + S + W + E) Button(acceuil, text=names[2], command=lambda: self.click_user(keys[2])). \ grid(column=2, row=2, sticky=N + S + W + E) Button(acceuil, text=names[3], command=lambda: self.click_user(keys[3])). \ grid(column=3, row=2, sticky=N + S + W + E) Button(acceuil, text=names[4], command=lambda: self.click_user(keys[4])). \ grid(column=4, row=2, sticky=N + S + W + E) Button(acceuil, text=names[5], command=lambda: self.click_user(keys[5])). \ grid(column=5, row=2, sticky=N + S + W + E) for i in range(0,len(keys)): if keys[i] == '-': Button(acceuil, text=names[i], state=DISABLED).grid(column=i, row=2, sticky=N + S + W + E)So I get my keys and names that I put in two != lists and I and values '-' if I don't have enough user to fill the 6 fields.
Then I create my 6 buttons.
Finaly I overwrite the buttons where '-' is set
If you have any better suggestions...?