For example, you can create a Treeview widget using a class as follows:
class FiltersTree: def __init__(self, master, filters): self.master = master self.filters = filters self.treeFrame = Frame(self.master) self.treeFrame.pack() self._create_treeview() self._populate_root() def _create_treeview(self): self.dataCols = ['filter', 'attribute'] self.tree = ttk.Treeview(self.master, columns = self.dataCols, displaycolumns = '#all')
Fill in the root, insert the children as usual. At the end of the block, you can see where I want to put the Combobox in the tree using the Combo object:
def _populate_root(self):
The following is a definition of the Combo class. As I understand it, the combobox widget is inherited and should be placed inside the Labelframe widget from ttk:
class Combo(ttk.Frame): def __init__(self, master): self.opts = ('opt1', 'opt2', 'etc') self.comboFrame = ttk.Labelframe(master, text = 'Choose option') self.comboFrame.pack() self.combo = ttk.Combobox(comboFrame, values=self.opts, state='readonly') self.combo.current(1) self.combo.pack()
So is this completely wrong? I want to be able to switch between units (e.g. m / s, ft / s, etc.) from the Treeview widget.
Any suggestions, plz?

source share