我正在一个具有内置文件管理器的项目中,并且我希望每个文件(一个{}
)都有自己的行,但是我无法创建Button
填满整行。
我尝试使Button
粘在W + E上,但是没有用
Button
实际结果如下:
但是,我希望def reloadWindow(self):
for x in self.widgets:
x.grid_forget()
self.widgets = []
for path, subdirs, files in os.walk(dir):
for name in files:
if not name == "":
replacer = self.proDir + "\\assets"
self.helloBTN = Button(self, text=path.replace(str(replacer), "") + "\\" + name)
self.helloBTN.grid(row=len(self.widgets), sticky=W+E)
self.widgets.append(self.helloBTN)
充满整个窗口(代码是从顶级类执行的。)
编辑: 这是指向完整窗口剪辑LINK
的链接EDIT2: LINK到精简版本的代码。在第41行,将[DIR]替换为真实目录(最多36个文件)。