vendredi 7 décembre 2018

Tabulate labels in checkbar Tkinter

I am doing a GUI with Tkinter and I am trying to show the labels from two checkbars tabulated. I tried (as you can see in the code) to check if the problem was that the labels were not the same length, but after adding some blank spaces when needed; it seems this was not the problem. Any ideas why this could be happenning?

class Checkbar(Frame):
def __init__(self, parent=None, picks={}, side=LEFT, anchor=W, list_keys=[]):
    Frame.__init__(self, parent)
    self.vars = []

    for key, value in picks.items():
        var = IntVar()
        chk = Checkbutton(self, text=self.SameLength(list_keys, key), variable=var)
        button_ttp = ToolTip(chk, value)
        chk.pack(side=side, anchor=anchor, expand=YES, )

def SameLength(self, listStrings, word):
    return word.ljust(len(max(listStrings, key=len)), '0')

Image




Aucun commentaire:

Enregistrer un commentaire