python 2.7 - Horizontal scrolling won't activate for ttk Treeview widget -
i'm using ttk treeview widget implement folder/path selection dialog. it's working expected except horizontal scrollbar won't activate. no matter how wide folder path goes horizontally, , no matter how narrow window, horizontal slider never appears. vertical scrolling working though.
i'm figuring it's either kind of limitation when use 1 column in treeview, or newbie mistake configuring , connecting widgets. i'd bet on latter.
example dialog widened show full folder depth:
dialog narrowed point horizontal scrolling should activate (but doesn't):
here's gui layout code:
windirsel = tk.toplevel() windirsel.title('select test directory...') tvwdirsel = ttk.treeview(windirsel, height=10,padding=3, show='tree') lbltestdir = tk.label(windirsel, relief=tk.sunken, justify=tk.left, anchor=tk.w, textvariable=ctrltestdir,width=80) scbhdirsel = ttk.scrollbar(windirsel, orient=tk.horizontal, command=tvwdirsel.xview) scbvdirsel = ttk.scrollbar(windirsel, orient=tk.vertical, command=tvwdirsel.yview) tvwdirsel.configure(xscrollcommand=scbhdirsel.set, yscrollcommand=scbvdirsel.set) lbltestdir.grid(row=0,column=0,sticky=tk.ew) tvwdirsel.grid(row=1,column=0,sticky=tk.nsew) scbvdirsel.grid(row=1,column=1,sticky=tk.ns) scbhdirsel.grid(row=2,column=0,sticky=tk.ew) windirsel.rowconfigure(1,weight=1) windirsel.columnconfigure(0,weight=1)
ok, after playing minwidth
, stretch
, think have better handle on it. horizontal scrolling triggered column-edge going out of window's bounds, not content of column. can use these parameters force column wider , force scrolling.
the problem though lose automatic adjustment of column width suit width of tree itself. either have force wide accommodate (assumed) folder depth, or live folder names getting truncated @ right boundary of column.
so bottom line: it's limitation of widget itself. (at least respect behavior on platform, ms windows.)
Comments
Post a Comment