python / cpython

The Python programming language
https://www.python.org
Other
63.17k stars 30.25k forks source link

Tix: Subwidget names #43249

Closed bb8559d8-7a7e-44b1-ad79-8ac984ba1db9 closed 17 years ago

bb8559d8-7a7e-44b1-ad79-8ac984ba1db9 commented 18 years ago
BPO 1472877
Nosy @loewis, @mkiever

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = 'https://github.com/loewis' closed_at = created_at = labels = ['expert-tkinter'] title = 'Tix: Subwidget names' updated_at = user = 'https://github.com/mkiever' ``` bugs.python.org fields: ```python activity = actor = 'loewis' assignee = 'loewis' closed = True closed_date = None closer = None components = ['Tkinter'] creation = creator = 'mkiever' dependencies = [] files = [] hgrepos = [] issue_num = 1472877 keywords = [] message_count = 3.0 messages = ['28305', '28306', '28307'] nosy_count = 2.0 nosy_names = ['loewis', 'mkiever'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1472877' versions = [] ```

bb8559d8-7a7e-44b1-ad79-8ac984ba1db9 commented 18 years ago

My system information: ------------------------------------------ uname -a: Linux linux 2.6.4-52-default #1 Wed Apr 7 02:08:30 UTC 2004 i686 athlon i386 GNU/Linux Python: Python 2.4.1 (#4, Jan 10 2006, 10:53:14) [GCC 3.3.3 (SuSE Linux)] on linux2 and Python 2.3.5 (#1, Sep 12 2005, 14:56:24) [GCC 3.3.3 (SuSE Linux)] on linux2 ------------------------------------------

Using Tix you can produce the following exception:

---------------------------------------------------

>>> from Tix import *
>>> tk = Tk ()
>>> b = Balloon ()
>>> b.subwidget ( 'label' )
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/mkiever/pro/Python-2.4.1/Lib/lib-tk/Tix.
py", line 340, in subwidget
    return self._nametowidget(n)
  File "/home/mkiever/pro/Python-2.4.1/Lib/lib-tk/
Tkinter.py", line 1015, in nametowidget
    w = w.children[name]
KeyError: 'lab'
>>> 

I found a commentary in Tix.py:TixWidget:init stating that 'subwidget_list' should contain Tix names. But in Tix.py:TixSubWidget:init the python names are used, not the names returned by Tix.

I was successful with the following two small additions (+++) near lines 400-450: ---------------------------------------------

class TixSubWidget(TixWidget):
 ...
 def __init__(self, master, name,
              destroy_physically=1,
              check_intermediate=1):
  ...
  if (not check_intermediate) or len(plist) < 2:
   # immediate descendant
   if check_intermediate:                        +++
    name = plist [0]                             +++
   TixWidget.__init__(self, master, None, None, 
                      {'name' : name})
  else:
   ...
   name = plist [-1]                             +++
   TixWidget.__init__(self, parent, None, None,
                      {'name' : name})
  self.destroy_physically = destroy_physically
...

This replaces the python name by the name returned from Tix. I have not extensively tested this (sorry). Hope this helps.

Matthias Kievernagel (mkiever@web.de)

bb8559d8-7a7e-44b1-ad79-8ac984ba1db9 commented 18 years ago

Logged In: YES user_id=1477880

Solution was not complete. Submitted a complete patch bpo-1472877 for this which is tested against the tix demo code in Demo/tix/tixwidgets.py

Matthias Kievernagel mkiever at web dot de

61337411-43fc-4a9c-b8d5-4060aede66d0 commented 17 years ago

Fixed with said patch.