当树失去焦点时,wxPython树列表Ctrl项难以识别

时间:2018-06-16 20:21:01

标签: python python-3.x wxpython wxpython-phoenix

在Ubuntu Bionic Beaver(4月2018年),至少**,当树控件失去焦点时,项目变得不可读。下面的代码(Python 3和wxPython 4)演示了它。双击任何项目以查看问题。

import wx
import wx.lib.agw.hypertreelist as HTL

class StartFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, title='Demo', size=(500, 300))
        self.panel = wx.Panel(self)
        self.panel.SetBackgroundColour(wx.RED)
        self.tree = HTL.HyperTreeList(self.panel, size=(400, 200),
            agwStyle=wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE)
        self.tree.AddColumn('Col 1')
        self.root = self.tree.AddRoot('My Root')
        self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED,
            self.on_row_item_activated)
        for n in range(1, 4):
            item = self.tree.AppendItem(self.root, 'item {}'.format(n))
            item.SetText(1, 'Col 1 item {}'.format(n))
            self.tree.SetItemTextColour(item, wx.BLUE)
            self.tree.SetItemBackgroundColour(item, wx.GREEN)

    def on_row_item_activated(self, _evt):
        wx.MessageBox("I've taken the focus - how are the items? Changed "
            "colours? Still legible? Did the custom colours help anything?")

class App(wx.App):

    def OnInit(self):
        frame = StartFrame()
        frame.Show()
        self.SetTopWindow(frame)
        return True

app = App()
app.MainLoop()

图片1:选择一个项目 - 未选择的项目和所选项目都清晰可见。

enter image description here

图片2:双击项目2,弹出消息框,窃取焦点。第1项现在不可读:

enter image description here

我希望解决方案不会涉及根据How to change Selection Colour for selected items in wxpython's CustomTreeCtrl破解OnPaintItem,但如果确实如此,我会尽我所能 - 我不得不在某些时候做得更糟;-)

**我还没有在任何其他平台上进行过测试,但我在使用wxPython 2.8和wx.gizmos.TreeListCtrl

时对Bionic没有任何麻烦

0 个答案:

没有答案
相关问题