... use color within individual list entries. E.g., one entry might be INCREDIBLE, and another in the same list might be MONDEGREEN .
Any ideas, any suggestions?
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Andrea,
I've looked at the UltimateListCtrl demo, and have Googled it a bit, but I see no examples in which a =single= item can have multiple colors, as in my black-and-red and black-and-green examples below.
I need to be able to present, in a list control, vocabulary items which contain specific character strings, with those character strings highlighted.
You've created a lot of very useful controls. If what I need does not yet exist, might you be able to create what's needed? Presumably as a mod to UltimateListControl, or a mix-in, rather than a new control.
randomRenderer = random.randint(0, 2) if randomRenderer == 2: # set some custom renderers... klass = UltimateRenderer_1(self) renderers[index] = klass self.list.SetItemCustomRenderer(index, 3, klass) elif randomRenderer == 1: klass = UltimateRenderer_2(self) self.list.SetItemCustomRenderer(index, 3, klass) else: klass = UltimateRenderer_3() self.list.SetItemCustomRenderer(index, 3, klass)
UltimateRenderer_2 is the class you want. Looking at how that class implements its DrawSubItem method:
def DrawSubItem(self, dc, rect, line, highlighted, enabled): dc.SetBackgroundMode(wx.SOLID) dc.SetBrush(wx.Brush(wx.BLACK, wx.SOLID)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(rect) dc.SetBackgroundMode(wx.TRANSPARENT) dc.SetFont(self.randomFont) colours = [wx.RED, wx.WHITE, wx.GREEN, wx.NamedColour("SKY BLUE")] w, h = dc.GetTextExtent("Hg") x = rect.x + 1 y = rect.y + rect.height/2 - h/2 for ch in self.text: dc.SetTextForeground(random.choice(colours)) dc.DrawText(ch, x, y) w, h = dc.GetTextExtent(ch) x = x + w if x > rect.right - 5: break
You can easily see that, for each character in the string "self.text" it chooses a random color and draws that letter. I believe it would be quite easy to modify that class to do what you want.
Andrea.
Bob
On 3/22/2017 1:01 AM, Andrea Gavana wrote:
Hi Bob,
On Wed, 22 Mar 2017 at 02:52, Bob Klahn <bobk...@comcast.net> wrote:
... use color within individual list entries. E.g., one entry might be INCREDIBLE, and another in the same list might be MONDEGREEN .
Any ideas, any suggestions?
UltimateListCtrl with a custom renderer should probably do the trick. I believe the demo has something similar.
Andrea.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
Hi,
On 3/22/2017 1:01 AM, Andrea Gavana wrote:
Thank you very much, Andrea! The copy of the UltimateListCtrl demo I have is quite old, and the super-helpful code you've just cited is not part of it. I'd like to install the current demo package on my new 64-bit machine, but I haven't yet figure out how to do so. Rightly or wrongly, I'm afraid to try running the 32-bit installer, wxPython3.0-win32-docs-demos.exe, the only installer listed at https://wxpython.org/download.php . Is my "fear" unfounded?