SetBackgroundColour in staticText doesn't work

Hi,
I’m starting an aplication (my 1st to deploy in python/wxPython) and
it needs a “inverse” or selected efect in a static text but I can’t do it.
I the statictext demo (2.8.9.2) changing the values also doesn’t work.

Any one notice the problem.

Thanks in advance

Ubuntu 8.10, python 2.5, wxPython 2.8.9.2

Jorge wrote:

Thank you Chrisitan,
unfortunately I can't use the TextCtrl because it can have a focus.

So? Call the text control's Disable() method and it no longer accepts focus. Of course, I don't see why you cannot use a Listbox. You can make programmatic calls on it to tell it which line to select too.

···

What I'm trying to do, is a column in StaticText that behave like a list box but controlled from a other controls,
these controls select and delesect the "rows"

First Line ^ Second Line ^ ^ Third Line Forth Line v v Fifth Line v

imagine that when you press the ^ area the program set the colours black and white in the 3 column
and invert the co lours in the 2 column

First Line ^ Second Line ^ ^ Third Line Forth Line v v Fifth Line v

Regards.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

__________ Information from ESET NOD32 Antivirus, version of virus signature database 3988 (20090404) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Mike,

I don’t see why you cannot use a Listbox.
because I need a put a bitmap image in the foreground!

My I put screen shots in the mailing list? It will be easy to explain.

Thank you.

···

On Sun, Apr 5, 2009 at 4:07 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Jorge wrote:

Thank you Chrisitan,

unfortunately I can’t use the TextCtrl because it can have a focus.

So? Call the text control’s Disable() method and it no longer accepts focus. Of course, You can make programmatic calls on it to tell it which line to select too.

What I’m trying to do, is a column in StaticText that behave like a list box but controlled from a other controls,

these controls select and delesect the “rows”

First Line ^ Second Line ^ ^ Third Line Forth Line v v Fifth Line v

imagine that when you press the ^ area the program set the colours black and white in the 3 column

and invert the co lours in the 2 column

First Line ^ Second Line ^ ^ Third Line Forth Line v v Fifth Line v

Regards.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Python Extension Building Network: http://www.pythonlibrary.org

__________ Information from ESET NOD32 Antivirus, version of virus signature database 3988 (20090404) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Sorry for not mention a background bitimap.
here goes the screenshot of what I pretend to do.

Thank you.

···

On Sun, Apr 5, 2009 at 5:36 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Jorge wrote:

Mike,

I don't see why you cannot use a Listbox.

because I need a put a bitmap image in the foreground!

My I put screen shots in the mailing list? It will be easy to explain.

Thank you.

Well, what the heck!? You never said jack about a bitmap image. No wonder no one can answer your question. By all means, email some photos.

On Sun, Apr 5, 2009 at 4:07 PM, Mike Driscoll <mike@pythonlibrary.org mailto:mike@pythonlibrary.org> wrote:

Jorge wrote:



    Thank you Chrisitan,

    unfortunately I can't use the TextCtrl because it can have a

    focus.





So? Call the text control's Disable() method and it no longer

accepts focus. Of course, You can make programmatic calls on it to

tell it which line to select too.







    What I'm trying to do, is a column in StaticText that  behave

    like a list box but controlled from a other controls,

    these controls select and delesect the "rows"



    First Line         ^ Second Line      ^   ^        Third Line

                  Forth Line       v   v     Fifth Line         v

                  imagine that when you press the ^ area the program set the

    colours black and white in the 3 column

    and invert the co lours in the 2 column



    First Line         ^ Second Line      ^   ^        Third Line

                  Forth Line       v   v     Fifth Line         v

                  Regards.



-------------------

Mike Driscoll



Blog:   [http://blog.pythonlibrary.org](http://blog.pythonlibrary.org)

Python Extension Building Network:     [http://www.pythonlibrary.org](http://www.pythonlibrary.org)

__________ Information from ESET NOD32 Antivirus, version of virus signature database 3988 (20090404) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Jorge,

Sorry for not mention a background bitimap.
here goes the screenshot of what I pretend to do.

Thank you.

I'm not aware of any controls that have that functionality built into them. You'll probably want to roll your own widget or create a composite widget. As I recall, there are directions on the wiki. You can probably also do it using DCs, but I don't know how to do that sort of thing. Check the demo.

- Mike

···

On Sun, Apr 5, 2009 at 5:36 PM, Mike Driscoll <mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>> wrote:

    Jorge wrote:

        Mike,

           I don't see why you cannot use a Listbox.

        because I need a put a bitmap image in the foreground!
        My I put screen shots in the mailing list? It will be easy to
        explain.

        Thank you.

    Well, what the heck!? You never said jack about a bitmap image. No
    wonder no one can answer your question. By all means, email some
    photos.

        On Sun, Apr 5, 2009 at 4:07 PM, Mike Driscoll > <mike@pythonlibrary.org <mailto:mike@pythonlibrary.org> > <mailto:mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>>> wrote:

           Jorge wrote:

               Thank you Chrisitan,
               unfortunately I can't use the TextCtrl because it can
        have a
               focus.

           So? Call the text control's Disable() method and it no longer
           accepts focus. Of course, You can make programmatic calls
        on it to
           tell it which line to select too.

               What I'm trying to do, is a column in StaticText that
         behave
               like a list box but controlled from a other controls,
               these controls select and delesect the "rows"

               First Line ^ Second Line ^ ^ Third Line
                             Forth Line v v Fifth Line v
                             imagine that when you press the ^ area
        the program set the
               colours black and white in the 3 column
               and invert the co lours in the 2 column

               First Line ^ Second Line ^ ^ Third Line
                             Forth Line v v Fifth Line v
                             Regards.

           -------------------
           Mike Driscoll

           Blog: http://blog.pythonlibrary.org
           Python Extension Building Network: http://www.pythonlibrary.org

Hi Mike,
what annoy me is that SetBackgroundColour doesn’t work in normal use or in the demo.
Is it a bug?

Thank you.

···

On Mon, Apr 6, 2009 at 3:19 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Hi Jorge,

Sorry for not mention a background bitimap.

here goes the screenshot of what I pretend to do.

Thank you.

I’m not aware of any controls that have that functionality built into them. You’ll probably want to roll your own widget or create a composite widget. As I recall, there are directions on the wiki. You can probably also do it using DCs, but I don’t know how to do that sort of thing. Check the demo.

  • Mike

On Sun, Apr 5, 2009 at 5:36 PM, Mike Driscoll <mike@pythonlibrary.org mailto:mike@pythonlibrary.org> wrote:

Jorge wrote:



    Mike,



       I don't see why you cannot use a Listbox.



    because I need a put a bitmap image in the foreground!

    My I put screen shots in the mailing list? It will be easy to

    explain.



    Thank you.





Well, what the heck!? You never said jack about a bitmap image. No

wonder no one can answer your question. By all means, email some

photos.









    On Sun, Apr 5, 2009 at 4:07 PM, Mike Driscoll

    <mike@pythonlibrary.org <mailto:mike@pythonlibrary.org>

<mailto:mike@pythonlibrary.org

    <mailto:mike@pythonlibrary.org>>> wrote:



       Jorge wrote:



           Thank you Chrisitan,

           unfortunately I can't use the TextCtrl because it can

    have a

           focus.





       So? Call the text control's Disable() method and it no longer

       accepts focus. Of course, You can make programmatic calls

    on it to

       tell it which line to select too.







           What I'm trying to do, is a column in StaticText that

     behave

           like a list box but controlled from a other controls,

           these controls select and delesect the "rows"



           First Line         ^ Second Line      ^   ^               Third Line

                         Forth Line       v   v     Fifth Line                v

                         imagine that when you press the ^ area

    the program set the

           colours black and white in the 3 column

           and invert the co lours in the 2 column



           First Line         ^ Second Line      ^   ^               Third Line

                         Forth Line       v   v     Fifth Line                v

                         Regards.



       -------------------

       Mike Driscoll



       Blog:   [http://blog.pythonlibrary.org](http://blog.pythonlibrary.org)

       Python Extension Building Network:            [http://www.pythonlibrary.org](http://www.pythonlibrary.org)

wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Jorge a écrit :

Hi Mike,
what annoy me is that SetBackgroundColour doesn't work in normal use or in the demo.
Is it a bug?

It's platform dependent. It works on Windows. It does not on GTK. If you want your app to run on both, use TextCtrl.

···

--
jmp

Thanks, Rene, for that investigation. I get the impression, though, from
questions about "background handling" on this list in the past (I've asked
some about how to let gradients shine through on all platforms), that for
native controls there is nothing one can do. Workarounds seem to be to
either draw something directly on oneself, or use or create a generic
control, or use a similar control creatively (such as the suggestion in this
thread to use a wx.TextCtrl).

Che

···

On Mon, Apr 6, 2009 at 3:41 PM, Rene Heymans <rene.heymans@gmail.com> wrote:

Dear Jorge, Mike,

I can confirm this problem. Indeed I am just working on Chapter 7 of
Robin's "wxPython In Action" and I did test listing 7.1 on my WinXP laptop
and my Linux box. Both run Python 2.5. and wxPython 2.8.

The code is:

    rev = wx\.StaticText\(panel, \-1, &quot;Static Text With Reversed

Colors", (100, 30))
rev.SetForegroundColour('white')
rev.SetBackgroundColour('black')

When the program is run, it displays exactly as Figure 7.1 in the book (p.
186) on my WinXP laptop but the same text doesn't show up on my Linux box.
Nothing to see (maybe it is still white on white ?).

I'm just looking at the documentation (
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.StaticText.html )
to realize that both methods (SetForegroundColour() and
SetBackgroundColour()) are not wx.StaticText methods but methods from the
wx.Window parent class. So, looking there I see a few notes that intrigue me
further:

Note: The interpretation of foreground colour is open to interpretation
according to the window class; it may be the text colour or other colour, or
it may not be used at all.
Note: The background colour is usually painted by the default wx.EraseEvent
event handler function under Windows and automatically under GTK.
Note: Note that setting the background colour does not cause an immediate
refresh, so you may wish to call ClearBackground or Refresh after calling
this function. Using this function will disable attempts to use themes for
this window, if the system supports them. Use with care since usually the
themes represent the appearance chosen by the user to be used for all
applications on the system.

Unfortunately I don't have time anymore this evening to investigate further
on this matter.

Maybe the above can hint to a solution.
Regards, Rene

Rene,
I did the same test with the same result!
works in Windows but not in Linux.
My code work bad in Linux(only changing the text color) and do nothing in Windows.

Jean-Marie,
I try but it doesn’t have transparency.

Attached my code press the arrow down and then the arrow up, because it only affect 2 lines.

touchlist.zip (19.2 KB)

···

On Mon, Apr 6, 2009 at 10:15 PM, C M cmpython@gmail.com wrote:

On Mon, Apr 6, 2009 at 3:41 PM, Rene Heymans rene.heymans@gmail.com wrote:

Dear Jorge, Mike,

I can confirm this problem. Indeed I am just working on Chapter 7 of

Robin’s “wxPython In Action” and I did test listing 7.1 on my WinXP laptop

and my Linux box. Both run Python 2.5. and wxPython 2.8.

The code is:

    rev = wx.StaticText(panel, -1, "Static Text With Reversed

Colors", (100, 30))

    rev.SetForegroundColour('white')
    rev.SetBackgroundColour('black')

When the program is run, it displays exactly as Figure 7.1 in the book (p.

  1. on my WinXP laptop but the same text doesn’t show up on my Linux box.

Nothing to see (maybe it is still white on white ?).

I’m just looking at the documentation (

http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.StaticText.html )

to realize that both methods (SetForegroundColour() and

SetBackgroundColour()) are not wx.StaticText methods but methods from the

wx.Window parent class. So, looking there I see a few notes that intrigue me

further:

Note: The interpretation of foreground colour is open to interpretation

according to the window class; it may be the text colour or other colour, or

it may not be used at all.

Note: The background colour is usually painted by the default wx.EraseEvent

event handler function under Windows and automatically under GTK.

Note: Note that setting the background colour does not cause an immediate

refresh, so you may wish to call ClearBackground or Refresh after calling

this function. Using this function will disable attempts to use themes for

this window, if the system supports them. Use with care since usually the

themes represent the appearance chosen by the user to be used for all

applications on the system.

Unfortunately I don’t have time anymore this evening to investigate further

on this matter.

Maybe the above can hint to a solution.

Regards, Rene

Thanks, Rene, for that investigation. I get the impression, though, from

questions about “background handling” on this list in the past (I’ve asked

some about how to let gradients shine through on all platforms), that for

native controls there is nothing one can do. Workarounds seem to be to

either draw something directly on oneself, or use or create a generic

control, or use a similar control creatively (such as the suggestion in this

thread to use a wx.TextCtrl).

Che


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

C M wrote:

···

On Mon, Apr 6, 2009 at 3:41 PM, Rene Heymans <rene.heymans@gmail.com> wrote:
  

Dear Jorge, Mike,

I can confirm this problem. Indeed I am just working on Chapter 7 of
Robin's "wxPython In Action" and I did test listing 7.1 on my WinXP laptop
and my Linux box. Both run Python 2.5. and wxPython 2.8.

The code is:

        rev = wx.StaticText(panel, -1, "Static Text With Reversed
Colors", (100, 30))
        rev.SetForegroundColour('white')
        rev.SetBackgroundColour('black')

When the program is run, it displays exactly as Figure 7.1 in the book (p.
186) on my WinXP laptop but the same text doesn't show up on my Linux box.
Nothing to see (maybe it is still white on white ?).

I'm just looking at the documentation (
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.StaticText.html )
to realize that both methods (SetForegroundColour() and
SetBackgroundColour()) are not wx.StaticText methods but methods from the
wx.Window parent class. So, looking there I see a few notes that intrigue me
further:

Note: The interpretation of foreground colour is open to interpretation
according to the window class; it may be the text colour or other colour, or
it may not be used at all.
Note: The background colour is usually painted by the default wx.EraseEvent
event handler function under Windows and automatically under GTK.
Note: Note that setting the background colour does not cause an immediate
refresh, so you may wish to call ClearBackground or Refresh after calling
this function. Using this function will disable attempts to use themes for
this window, if the system supports them. Use with care since usually the
themes represent the appearance chosen by the user to be used for all
applications on the system.

Unfortunately I don't have time anymore this evening to investigate further
on this matter.

Maybe the above can hint to a solution.
Regards, Rene
    
Thanks, Rene, for that investigation. I get the impression, though, from
questions about "background handling" on this list in the past (I've asked
some about how to let gradients shine through on all platforms), that for
native controls there is nothing one can do. Workarounds seem to be to
either draw something directly on oneself, or use or create a generic
control, or use a similar control creatively (such as the suggestion in this
thread to use a wx.TextCtrl).

Che

You are correct. If the native control doesn't have that feature, then you cannot use it in that way. Create your own control, use a generic one or use the DC stuff.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

__________ Information from ESET NOD32 Antivirus, version of virus signature database 3990 (20090406) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Thank you to all.
so I have to :

  • Quit
  • Use DC.
    Where can I get a good tutorial of DC?

Regards.

···

On Tue, Apr 7, 2009 at 3:16 AM, Robin Dunn robin@alldunn.com wrote:

Mike Driscoll wrote:

Jorge wrote:

Hi Mike,

what annoy me is that SetBackgroundColour doesn’t work in normal use or in the demo.

Is it a bug?

Thank you.

It’s probably a platform implementation thing. Some platforms support it and some do not. With native widgets comes native customs. That’s why we have generic controls and such. Robin can comment on this better than I can. Hopefully he will.

Static texts and some other widgets are not true widgets in the wxGTK port, they are just drawn directly on the parent. So that means that they do not automatically inherit all of the features of the base widget class, and background colors is one of those.

There is a generic implementation in wx.lib.stattext that you can use instead, although from your screenshot I expect that it wont be much help either. You’ll want to make a custom widget that draws all the text and the image in a single widget.

Robin Dunn

Software Craftsman

http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi,
I think I solve the problem using DC.

Thanks a lot to all of you.

···

On Wed, Apr 8, 2009 at 1:06 AM, Robin Dunn robin@alldunn.com wrote:

Jorge wrote:

Thank you to all.

so I have to :

* Quit

* Use DC.

Where can I get a good tutorial of DC?

Several samples in the demo and the wiki show it in action, as well as the generic widgets in the wx.lib package.

Robin Dunn

Software Craftsman

http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users