tkinter.tix "Control" widget don't work with StringVar?
jfong at ms4.hinet.net
jfong at ms4.hinet.net
Sat Jun 1 21:28:33 EDT 2019
Below is a simplified version of the sample script downloaded from its package.
When run it, the entry field display '0' instead of 'P&W'.
PS. I am using Python 3.4.4, Windows 32bit
----test0.py----
1 from tkinter import tix as Tix
2
3 root = Tix.Tk()
4
5 demo_maker = Tix.StringVar()
6 demo_maker.set('P&W')
7
8 c = Tix.Control(root, label='Engine Maker: ',
9 variable=demo_maker,
10 options='entry.width 10 label.width 20 label.anchor e')
11 c.pack(side=Tix.TOP, anchor=Tix.W)
12
13 root.mainloop()
--------
I run it under pdb, try to figure out where the problem is:
D:\Works\Python>py -m pdb test0.py
> d:\works\python\test0.py(1)<module>()
-> from tkinter import tix as Tix
(Pdb) tbreak 13
Breakpoint 1 at d:\works\python\test0.py:13
(Pdb) cont
Deleted breakpoint 1 at d:\works\python\test0.py:13
> d:\works\python\test0.py(13)<module>()
-> root.mainloop()
(Pdb) !c['value']
'0'
(Pdb) !demo_maker.get()
'P&W'
(Pdb) quit
If I change line 8 to "c = Tix.Control(root, label='Engine Maker: ', value='P&W',", the result is very interest:
D:\Works\Python>py -m pdb test0.py
> d:\works\python\test0.py(1)<module>()
-> from tkinter import tix as Tix
(Pdb) tbreak 13
Breakpoint 1 at d:\works\python\test0.py:13
(Pdb) cont
Deleted breakpoint 1 at d:\works\python\test0.py:13
> d:\works\python\test0.py(13)<module>()
-> root.mainloop()
(Pdb) !c['value']
'0'
(Pdb) !demo_maker.get()
'0'
(Pdb) quit
Anyone can help?
--Jach
More information about the Python-list
mailing list