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

CustomTreeCtrl edit label remains stuck forever sometimes #1235

Nyral opened this issue May 27, 2019 · 3 comments

CustomTreeCtrl edit label remains stuck forever sometimes #1235

Nyral opened this issue May 27, 2019 · 3 comments


Copy link

@Nyral Nyral commented May 27, 2019

Windows 10 (or Windows 7)
wxPython 4.0.6 (pip)
Python 3.7.3 [32bit]

From what I can tell, it seems that I'm able to somehow select the label from behind the TextCtrl and trigger a second edit label instance that can't be closed.
Or maybe KillFocus doesn't trigger correctly? I dunno.

Here's me reproducing it with the example from wxDemo:

Another example (from another GUI):

Copy link

@cbeytas cbeytas commented May 29, 2019

When you left-click on a label, a TreeEditTimer is started. After _DELAY (500ms) the tree will edit the label.

If you are already editing the label this shouldn't happen, but the TreeTextCtrl doesn't fully cover the label area. So if you click just outside the TreeTextCtrl, the TREE_HITTEST_ONITEMLABEL test will pass and the timer will be started. After 500ms a second TreeTextCtrl is spawned on top of the old one.

When you change the selection, only the most recent TreeTextCtrl is Destroyed and the old one is left orphaned in the tree.

Could be fixed in at the end of the Edit() method:

        if self._editCtrl != None and item != self._editCtrl.item():

        self._editCtrl = TreeTextCtrl(self, item=item)

if self._editCtrl is not None, an edit control already exists in the tree.
I believe it should not assign self._editCtrl to a new TreeTextCtrl without guaranteeing the previous one is destroyed.

Copy link
Contributor Author

@Nyral Nyral commented May 30, 2019

@cbeytas Thank you for looking into this! It means a lot to me.

Based on your explanation, I added a condition for checking self._editCtrl is None.

if self._editCtrl == None:
        self._editCtrl = TreeTextCtrl(self, item=item)

That seems to have been enough to fix the issue.


In wxDemo you can see that the edit event is triggered multiple times, but a new TreeTextCtrl is not created.

Nyral added a commit to Nyral/Phoenix that referenced this issue May 30, 2019
Nyral added a commit to Nyral/Phoenix that referenced this issue Jun 1, 2019
RobinD42 added a commit that referenced this issue Sep 14, 2019
Fixes #1235: CustomTreeCtrl edit label remains stuck forever

(cherry picked from commit 4d336e1)
Copy link

@RobinD42 RobinD42 commented Apr 24, 2020

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants