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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Bob Klahn
... 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andrea Gavana
Hi Bob,

On Wed, 22 Mar 2017 at 02:52, Bob Klahn <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Bob Klahn
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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andrea Gavana
Hi,

On 22 March 2017 at 15:14, Bob Klahn <[hidden email]> 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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Chris Barker - NOAA Federal
Awesome use of the time machine, Andrea!

-CHB

On Mar 22, 2017, at 7:43 AM, Andrea Gavana <[hidden email]> wrote:

Hi,

On 22 March 2017 at 15:14, Bob Klahn <[hidden email]> 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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

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

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Bob Klahn
In reply to this post by Andrea Gavana
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? 

Bob

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

On 22 March 2017 at 15:14, Bob Klahn <[hidden email]> 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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Andrea Gavana


On 22 March 2017 at 16:17, Bob Klahn <[hidden email]> 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? 

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.

 

Bob


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

On 22 March 2017 at 15:14, Bob Klahn <[hidden email]> 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 <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

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