Capability needed: list-control functionality with the ability to ...

… use color within individual list entries. E.g., one entry might
be INCRED IBLE, and another in
the same list might be MONDEGREEN
.

Any ideas, any suggestions?

Hi Bob,

... use color within individual list entries.  E.g., one entry might

be INCRED IBLE, 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.

···

On Wed, 22 Mar 2017 at 02:52, Bob Klahn bobklahn@comcast.net wrote:

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.

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.

Bob

···

On 3/22/2017 1:01 AM, Andrea Gavana wrote:

Hi Bob,

On Wed, 22 Mar 2017 at 02:52, Bob Klahn <bobklahn@comcast.net > <mailto:bobklahn@comcast.net>> wrote:

    ... use color within individual list entries. E.g., one entry
    might be INC*RED*IBLE, and another in the same list might be
    MONDE*GREEN* .

    Any ideas, any suggestions?

UltimateListCtrl with a custom renderer should probably do the trick. I believe the demo has something similar.

Andrea.

Hi,

···

On 22 March 2017 at 15:14, Bob Klahn bobklahn@comcast.net wrote:

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.

There is, in the demo. If you look at the UltimateReportDemo.py, there are a few lines of code like:

            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 <bobklahn@comcast.net            >
> > wrote:

> > >               ...
> > > use color within individual list entries.  E.g., one entry
> > > might be INC**RED**              IBLE, and another in the
> > > same list might be MONDE**GREEN** .
> > > 
> > > 
> > > 
> > >               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.
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

</details>

Awesome use of the time machine, Andrea!

-CHB

···

On 22 March 2017 at 15:14, Bob Klahn bobklahn@comcast.net wrote:

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.

There is, in the demo. If you look at the UltimateReportDemo.py, there are a few lines of code like:

            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 <bobklahn@comcast.net            >
> > wrote:

> > >               ...
> > > use color within individual list entries.  E.g., one entry
> > > might be INC**RED**              IBLE, and another in the
> > > same list might be MONDE**GREEN** .
> > > 
> > > 
> > > 
> > >               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.
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

</details>

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 Redirecting... . Is my "fear" unfounded?

Bob

···

On 3/22/2017 10:43 AM, Andrea Gavana wrote:

Hi,

On 22 March 2017 at 15:14, Bob Klahn <bobklahn@comcast.net > <mailto:bobklahn@comcast.net>> wrote:

    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.

There is, in the demo. If you look at the UltimateReportDemo.py, there are a few lines of code like:
             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.

    On 3/22/2017 1:01 AM, Andrea Gavana wrote:

    Hi Bob,

    On Wed, 22 Mar 2017 at 02:52, Bob Klahn <bobklahn@comcast.net >> <mailto:bobklahn@comcast.net>> wrote:

        ... use color within individual list entries. E.g., one
        entry might be INC*RED*IBLE, and another in the same list
        might be MONDE*GREEN* .

        Any ideas, any suggestions?

    UltimateListCtrl with a custom renderer should probably do the
    trick. I believe the demo has something similar.

    Andrea.

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 Redirecting... . Is my
"fear" unfounded?

It is. The 32-bit installer for the demo works without issues on any
Windows architecture. As Mike (and quite a few others) said, the installer
simply creates a few folders in the path you choose and copies there the
demo files (which are Python files). No risk whatsoever.

Andrea.

···

On 22 March 2017 at 16:17, Bob Klahn <bobklahn@comcast.net> wrote:

Bob

On 3/22/2017 10:43 AM, Andrea Gavana wrote:

Hi,

On 22 March 2017 at 15:14, Bob Klahn <bobklahn@comcast.net> wrote:

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.

There is, in the demo. If you look at the UltimateReportDemo.py, there are
a few lines of code like:

            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.

On 3/22/2017 1:01 AM, Andrea Gavana wrote:

Hi Bob,

On Wed, 22 Mar 2017 at 02:52, Bob Klahn <bobklahn@comcast.net> wrote:

... use color within individual list entries. E.g., one entry might be
INC*RED*IBLE, and another in the same list might be MONDE*GREEN* .

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.
For more options, visit https://groups.google.com/d/optout.