Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tix:NoteBook add/delete/add page problem #36091

Closed
chrismo mannequin opened this issue Feb 12, 2002 · 3 comments
Closed

Tix:NoteBook add/delete/add page problem #36091

chrismo mannequin opened this issue Feb 12, 2002 · 3 comments

Comments

@chrismo
Copy link
Mannequin

chrismo mannequin commented Feb 12, 2002

BPO 516703
Nosy @loewis
Files
  • patch.tix: Patch for Tix
  • 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:

    assignee = None
    closed_at = <Date 2002-03-27.18:05:20.000>
    created_at = <Date 2002-02-12.23:21:03.000>
    labels = ['expert-tkinter']
    title = 'Tix:NoteBook add/delete/add page problem'
    updated_at = <Date 2002-03-27.18:05:20.000>
    user = 'https://bugs.python.org/chrismo'

    bugs.python.org fields:

    activity = <Date 2002-03-27.18:05:20.000>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Tkinter']
    creation = <Date 2002-02-12.23:21:03.000>
    creator = 'chris_mo'
    dependencies = []
    files = ['331']
    hgrepos = []
    issue_num = 516703
    keywords = []
    message_count = 3.0
    messages = ['9258', '9259', '9260']
    nosy_count = 2.0
    nosy_names = ['loewis', 'chris_mo']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue516703'
    versions = ['Python 2.3']

    @chrismo
    Copy link
    Mannequin Author

    chrismo mannequin commented Feb 12, 2002

    Problem: NoteBook add/delete/add page with the same
    name does not work. python2.2/Tix

    Example Python Script for reproducing the Bug:

    import Tix
    import rlcompleter
    root=Tix.Tk()
    notebook=Tix.NoteBook(root, ipadx=3, ipady=3)
    notebook.add('general', label="General", underline=0)
    notebook.add('displaymode', label="Display mode", 
    underline=0)
    notebook.pack()
    notebook.delete('general')
    notebook.add('general', label="General", underline=0)
    la=Tix.Label(notebook.general,text="hallo")
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 
    2261, in __init__
        Widget.__init__(self, master, 'label', cnf, kw)
      File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 
    1756, in __init__
        self.tk.call(
    TclError: bad window path name 
    ".135915860.nbframe.general"   
    Tix seems nothing to know about the new page
    >>> notebook.tk.call(notebook._w,'pages')
    'displaymode'

    Analysis:
    in NoteBook.add() the new "same named" widget will
    succesfully created in tk. But it will be immediatly
    removed, if the TixSubWidget is constructed

    Solution:
    In the Notebook class:
    Do mark subwidget "destroy_physically=1". Also
    for clearness delete entry from subwidget_list dict.
    I dont't know if this is a fine or correct solution
    but it works (for me)

    Patch:
    derrick:chris$ diff -u 
    /usr/lib/python2.2/lib-tk/Tix.py Tix.py
    --- /usr/lib/python2.2/lib-tk/Tix.py    Sun Nov  4 
    01:45:36 2001
    +++ Tix.py      Tue Feb 12 23:41:50 2002
    @@ -828,12 +828,13 @@
         def add(self, name, cnf={}, **kw):
            apply(self.tk.call,
                  (self._w, 'add', name) + 
    self._options(cnf, kw))
    -       self.subwidget_list[name] = 
    TixSubWidget(self, name)
    +       self.subwidget_list[name] = 
    TixSubWidget(self, name, destroy_physically
            return self.subwidget_list[name]   
    
         def delete(self, name):
    +       del self.subwidget_list[name]
            self.tk.call(self._w, 'delete', name) 
    -
    +       
         def page(self, name):
            return self.subwidget(name)
     

    Tix.py Version
    # $Id: Tix.py,v 1.4 2001/10/09 11:50:55 loewis Exp $

    Tix Version
    tix-8.1.3

    Tcl/Tk-version
    tcl8.3-8.3.3
    tk8.3_8.3.3

    @chrismo chrismo mannequin closed this as completed Feb 12, 2002
    @chrismo chrismo mannequin added the topic-tkinter label Feb 12, 2002
    @chrismo chrismo mannequin closed this as completed Feb 12, 2002
    @chrismo
    Copy link
    Mannequin Author

    chrismo mannequin commented Feb 12, 2002

    Logged In: YES
    user_id=456854

    Okay, this is my first bug report, and seems not a good
    idea to paste patches into the text window :(

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 27, 2002

    Logged In: YES
    user_id=21627

    This is fixed in Tix.py 1.8. Notice that setting
    destroy_physically is not the right thing: that way, the Tcl
    widget won't be destroyed at all.

    Instead, the problem was that the line

    self.subwidget_list[name] = TixSubWidget(self, name)

    would first create the new subwidget, then remove the last
    reference to the old subwidget. The __del__ of the old
    subwidget would then destroy the Tcl widget. Since the old
    widget and the new widget have the same name, this would
    delete the new widget. The solution is to explicitly destroy
    the subwidget in delete.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants