I want to limit the height of a tkinter widget based on a length of a list. For this, i want to set 5 as a lower and 10 as an upper limit. The height should be 10 if my list exceeds 10 elements, 5 when there are equal or less than 5 elements, and the exact amount of elements if the list is in that range. I am wondering if there is a more pythonic way than this:
if 5 <= len(self.content) <= 10:
lb_height = len(self.content)
elif len(self.content) <= 5:
lb_height = 5
else:
lb_height = 10
Aucun commentaire:
Enregistrer un commentaire