I try to put a treeview into a subframe but it doesn't fit into 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 is supposed to fit into the PipeLineFrame (white area) but currently, it goes out of the frame like this. current result
CodePudding user response:
When you layout a widget you can do it in 1 line like this:
Widget(root).pack()
or you can give it a name and use 2 lines like this:
name = Widget(root)
name.pack()
You cannot combine those 2 methods and give it name using one line. This is the error you get if you try that.