开发者

tkinter in python. .pack works, but .grid produces nothing

This code works fine and produces check开发者_如何学JAVAbuttons in a long long list.

def createbutton(self,name):
    var = IntVar()
    account = name[0]
    chk = Checkbutton(self.root, text=account, variable=var)
    chk.pack(side = BOTTOM)
    self.states.append((name,var))

The problem is that the list of buttons is so long, that it stretches farther then the length of my screen so i want to put them into a grid, so that i can have maybe 10 checkbuttons in a column. Just to test the capability, i did this:

def createbutton(self,name):
    var = IntVar()
    account = name[0]
    chk = Checkbutton(self.root, text=account, variable=var)
    chk.grid(column=0)
    self.states.append((name,var))

And nothing happens, no tk interface opens and the program just waits. Please help!


Is it possible that you have other widgets that are in the root window, and they are put there using pack? If you try to use pack and grid in the same container your app can go into an infinite loop as each manager struggles for control of the container.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜