Peter Otten於 2017年10月19日星期四 UTC+8下午6時04分39秒寫道: > jf...@ms4.hinet.net wrote: > > > Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: > >> It's not clear to me what you mean with this. Did you place the table > >> from the recipe elsewhere inside a window that you created or did you > >> make changes in the recipe's code? > > > > Thank you, Peter. I am using Python 3.4.4 under WinXP. > > > > When running the file directly from download, I get a table scrolling > > vertically only. If its Table class's __init__ parameter > > "scroll_horizontally" changed to True, it can be scrolled horizontally > > also. But there is a problem when scrolled horizontally, the header field > > will not align with data field anymore. I make some modifications to make > > it does. So far so good. > > > > Later, I want to make the table also has a vertical header. The first step > > I had taken was to move all 2nd top-level widgets(not much, just four) to > > right one column further to make room for this new widget. I though it's a > > simple work, just increase their grid column value by 1. But Murphy's Law > > comes, the xscrollbar even don't show up when the table was squeezed > > horizontally. > > Thank you for the clarification; I understand your problem much better now. > > > > >> > The canvas has a binding: > >> > self.canvas.bind('<Configure>', self._on_canvas_configure) > >> > > >> > After this movement, the callback was only triggered when dragging the > >> > root widget to resize canvas vertically, but not horizontally. > >> > > >> > Event seems has OS involved(it's MS Windows XP in my case). How to > >> > debug this kind of problem, under pdb? > >> > >> I don't know, but if you can post a small example script that > >> demonstrates the problem, and you are lucky, someone will see the > >> problem. > > > > This is a ~5xx lines file and I think it's not fare to ask forum members > > to look through it. So I decide to ask for help on how to debug it, > > instead of the solution. > > > > I try to change the binding to > > self.bind_all('<Configure>', self._on_canvas_configure) > > and add a line into the callback > > print(event.widget) > > > > I got some info below each time when I squeeze the table: > > . > > .50077776 > > .50077776.50712528 > > .50077776.50712496 > > .50077776.50712464 > > .50077776.50712144 > > .50077776.50712528.50712560.50782256 > > .50077776.50712528.50712560.50782256.50783024 > > .50077776.50712528.50712560.50782256 > > .50077776.50712528.50712560.50782256.50783024 > > > > How to change these number(is it a widget ID?) to a meaning name? > > That's the name of the widget in the underlying tcl/tk. You can specify it > in Python: > > >>> import tkinter as tk > >>> print(tk.Button()) > .139817813335904 > >>> print(tk.Button(name="mybutton")) > .mybutton > > You have to ensure that names are unique.
Thank you. It's very helpful information. By the way, I just found this problem can be easily seen by not modifing the original file too much with the following steps: 1. copy and get the file from the link. 2. change the "scroll_horizontally" parameter in the "Table" class's __init__ method to "True" Running it you will see it perform correctly. 3. Change the "column=x" at line 268, 282, 288, 292, 303 to "column=x+1" Now it has the problem. --Jach -- https://mail.python.org/mailman/listinfo/python-list