树视图不适合框架
treeview doesn't fit the frame
我尝试将树视图放入子框架,但它不适合框架。
class Application(Frame):
def __init__(self,master=None):
self.pipeLine =[]
super().__init__(master)
self.master = master
self.PipeFrame = Frame(self.master,width=200,height=200).place(x=30,y=30)
self.PipeLineFrame = Frame(self.PipeFrame,width=200,height=220,bg='white',).place(x=10,y=100)
self.createPipeTree()
self.createWidget()
self.pack()
def createPipeTree(self):
self.PipeTree = ttk.Treeview(self.PipeLineFrame,column=("input","output"))
self.PipeTree.column("#0",minwidth=25,width= 60)
self.PipeTree.column("input",anchor=W,width=60)
self.PipeTree.column("output",anchor=W,width=60)
self.PipeTree.heading("#0",text="PipeLine")
self.PipeTree.heading("input",text="input")
self.PipeTree.heading("output",text="output")
self.PipeTree.pack(side=LEFT,expand=True)
def createWidget(self):
self.addNode = Button(self.PipeFrame,text="click to add procedure into pipeline",command=self.addNode).place(x=10,y=20)
self.inputBtn1 = Button(self.PipeFrame, text="F0").place(x=10,y=350)
self.inputBtn2 = Button(self.PipeFrame, text="Mel" ).place(x=50, y=350)
self.inputBtn3 = Button(self.PipeFrame, text="audio" ).place(x=100, y=350)
self.inputBtn4 = Button(self.PipeFrame, text="text").place(x=150,y=350)
self.inputBtn5 = Button(self.PipeFrame, text="f0").place(x=200, y=350)
if __name__ == '__main__':
root = Tk()
root.geometry("800x400+200+300")
root.title("HDI is the best")
Application(master=root)
root.mainloop()
PipeTree 应该适合 PipeLineFrame(白色区域),但目前,它会像这样超出框架。
current result
当你布局一个小部件时,你可以像这样在 1 行中完成:
Widget(root).pack()
或者你可以给它起个名字,然后像这样使用 2 行:
name = Widget(root)
name.pack()
您不能将这 2 种方法组合在一起并使用一行为其命名。如果您尝试这样做,就会出现此错误。
我尝试将树视图放入子框架,但它不适合框架。
class Application(Frame):
def __init__(self,master=None):
self.pipeLine =[]
super().__init__(master)
self.master = master
self.PipeFrame = Frame(self.master,width=200,height=200).place(x=30,y=30)
self.PipeLineFrame = Frame(self.PipeFrame,width=200,height=220,bg='white',).place(x=10,y=100)
self.createPipeTree()
self.createWidget()
self.pack()
def createPipeTree(self):
self.PipeTree = ttk.Treeview(self.PipeLineFrame,column=("input","output"))
self.PipeTree.column("#0",minwidth=25,width= 60)
self.PipeTree.column("input",anchor=W,width=60)
self.PipeTree.column("output",anchor=W,width=60)
self.PipeTree.heading("#0",text="PipeLine")
self.PipeTree.heading("input",text="input")
self.PipeTree.heading("output",text="output")
self.PipeTree.pack(side=LEFT,expand=True)
def createWidget(self):
self.addNode = Button(self.PipeFrame,text="click to add procedure into pipeline",command=self.addNode).place(x=10,y=20)
self.inputBtn1 = Button(self.PipeFrame, text="F0").place(x=10,y=350)
self.inputBtn2 = Button(self.PipeFrame, text="Mel" ).place(x=50, y=350)
self.inputBtn3 = Button(self.PipeFrame, text="audio" ).place(x=100, y=350)
self.inputBtn4 = Button(self.PipeFrame, text="text").place(x=150,y=350)
self.inputBtn5 = Button(self.PipeFrame, text="f0").place(x=200, y=350)
if __name__ == '__main__':
root = Tk()
root.geometry("800x400+200+300")
root.title("HDI is the best")
Application(master=root)
root.mainloop()
PipeTree 应该适合 PipeLineFrame(白色区域),但目前,它会像这样超出框架。 current result
当你布局一个小部件时,你可以像这样在 1 行中完成:
Widget(root).pack()
或者你可以给它起个名字,然后像这样使用 2 行:
name = Widget(root)
name.pack()
您不能将这 2 种方法组合在一起并使用一行为其命名。如果您尝试这样做,就会出现此错误。