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

[DEMO] HyperTreeList: right click -> select context menu item causes error #1032

Closed
blitzmann opened this Issue Oct 10, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@blitzmann
Copy link

blitzmann commented Oct 10, 2018

Operating system: Windows 10
wxPython version & source: 4.0.3
Python version & source: 3.6

Description of the problem:
You should be able to right click on the items and select one of the options. Some of them produce errors, such as (when changing text color):

Traceback (most recent call last):
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\wx\lib\agw\hypertreelist.py", line 3300, in OnPaint
    y, x_maincol = self.PaintLevel(self._anchor, dc, 0, 0, x_maincol)
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\wx\lib\agw\hypertreelist.py", line 3207, in PaintLevel
    y, x_maincol = self.PaintLevel(child, dc, level+1, y, x_maincol)
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\wx\lib\agw\hypertreelist.py", line 3118, in PaintLevel
    self.PaintItem(item, dc)
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\wx\lib\agw\hypertreelist.py", line 2779, in PaintItem
    if attr and attr.HasTextColour():
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\wx\lib\agw\customtreectrl.py", line 903, in HasTextColour
    return self._colText != wx.NullColour and self._colText.IsOk()
AttributeError: 'tuple' object has no attribute 'IsOk'

After this happens, it seems like a lot of the other options that start having issues.

Unsure if this is strictly due to the demo code, or if they are issues with the HyperTreeList itself

@infinity77

This comment has been minimized.

Copy link
Contributor

infinity77 commented Oct 10, 2018

This is probably due to the fact that we are passing a color as a tuple instead of a wx.Colour object when setting the item text colour/background. Maybe the underlying CustomTreeCtrl should be patched to detect whether the colour passed is a tuple (or a string) and convert it to wx.Colour on the fly.

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Oct 16, 2018

Maybe the underlying CustomTreeCtrl should be patched to detect whether the colour passed is a tuple (or a string) and convert it to wx.Colour on the fly.

Agreed. I seem to recall doing that somewhere else too, although I don't remember where. It's very easy to do, just one line, that can replace the line already there for assigning the attribute. Something like this:

    # instead of this
    self.someColour = someParameter
    # do this
    self.someColour = wx.Colour(someParameter)

Then no matter what is passed in someParameter it will be converted to a wx.Colour if possible, even if it's already a wx.Colour. It will just make a copy of the wx.Colour in that case.

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Oct 27, 2018

Fixed by #1058

@RobinD42 RobinD42 closed this Oct 27, 2018

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