How to override default system colors?

wx 2.6.0.1
python 2.3
wxGTK & wxMac

Is it even possible to override the colors from themed OSs?
I was always having problems on wxMac with wx.Dialog color and they
would just default to white. However, on Linux everything looked great
until I upgraded wx from 2.5.2.8 to 2.6.0.1 and then all of a sudden
all the manually set colors went to the system default (KDE 3.3.0).
Furthermore, the control fonts (like buttons) became huge and don't fit
inside anymore (everywhere else the fonts look just fine... ie, in
the rest of the OS).

So to summarize my question, how would one override default system
control colors and fonts?

Thanks,
Ratko

Ratko Jagodic wrote:

wx 2.6.0.1
python 2.3
wxGTK & wxMac

Is it even possible to override the colors from themed OSs?

Yes, but sometimes some things are a little more stubborn. It's possible that with some themes the attribute changes are just ignored.

I was always having problems on wxMac with wx.Dialog color and they
would just default to white. However, on Linux everything looked great
until I upgraded wx from 2.5.2.8 to 2.6.0.1 and then all of a sudden
all the manually set colors went to the system default (KDE 3.3.0).
Furthermore, the control fonts (like buttons) became huge and don't fit
inside anymore (everywhere else the fonts look just fine... ie, in the rest of the OS).

Did you also change from a gtk1 to a gtk2 build? Do any of these controls have a SetFont called on them? Have you tried with different gtk themes active? How about with no active theme?

So to summarize my question, how would one override default system control colors and fonts?

You can't do it for the whole app at once, but if the theme allows it then you can do it for each control with the Set*Colour and SetFont methods.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Did you also change from a gtk1 to a gtk2 build?

No. It was gtk2 before and it is now.

Do any of these controls have a SetFont called on them?

All of them do.

Have you tried with different gtk themes active? How about with no

active theme?
Well, I never even changed the theme from the default setup. Actually, no
themes are even installed on my system. The only thing I could change is
the style (appearance) of the windows and controls. I tried with different
styles and the same thing. I also can't pick no style... something must be
selected.

> So to summarize my question, how would one override default system
> control colors and fonts?

You can't do it for the whole app at once, but if the theme allows it
then you can do it for each control with the Set*Colour and SetFont methods.

For every control that I wanted to change the font and the color of, I
specified that explicitly using Set*Colour and SetFont methods. Everything
worked just fine before I upgraded to 2.6.0.1. The colors were showing up
exactly as I wanted them and the fonts were exactly as I specified them. I
fixed the fonts by letting the system pick them (commented out the SetFont
calls) so they look pretty good now. However, I really need to have the
panels be of my own color and not the system default. What exactly changed
between 2.5.2.8 and 2.6.0.1 with respect to that? I looked through "Recent
Changes" but I couldn't find anything specific to my problem.

Also, I don't believe that the theme doesn't allow the colors to be
changed since it worked fine before.

Thanks,
Ratko

Ratko Jagodic wrote:

So to summarize my question, how would one override default system control colors and fonts?

You can't do it for the whole app at once, but if the theme allows it then you can do it for each control with the Set*Colour and SetFont methods.

For every control that I wanted to change the font and the color of, I
specified that explicitly using Set*Colour and SetFont methods. Everything
worked just fine before I upgraded to 2.6.0.1. The colors were showing up
exactly as I wanted them and the fonts were exactly as I specified them. I
fixed the fonts by letting the system pick them (commented out the SetFont
calls) so they look pretty good now. However, I really need to have the
panels be of my own color and not the system default.

Changing the colour of panels works fine here.

What exactly changed
between 2.5.2.8 and 2.6.0.1 with respect to that? I looked through "Recent
Changes" but I couldn't find anything specific to my problem.

I don't remember the exact timing but there were some changes in how the various attributes for a particular widget are fetched and used from the theme, and how they are blended with custom settings, and also how they are or are not inherited from parent windows. It was done to make interacting with the theme settings "more correct" acocrding to gtk, and IIRC it corrected several problems.

Also, I don't believe that the theme doesn't allow the colors to be
changed since it worked fine before.

Just for kicks try running your app with no active theme and see how it behaves then. Just unset GTK2_RC_FILES in a shell window and run the app from there. (You may also have to comment out some include statements in ~/.gtkrc-2.0)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

> Also, I don't believe that the theme doesn't allow the colors to be
> changed since it worked fine before.

Just for kicks try running your app with no active theme and see how it
behaves then. Just unset GTK2_RC_FILES in a shell window and run the
app from there. (You may also have to comment out some include
statements in ~/.gtkrc-2.0)

It works beautifully! All the SetFont and SetColour methods take effect
the way you would expect them to. Well, now I am really confused.

> > Also, I don't believe that the theme doesn't allow the colors to be
> > changed since it worked fine before.
>
> Just for kicks try running your app with no active theme and see how it
> behaves then. Just unset GTK2_RC_FILES in a shell window and run the
> app from there. (You may also have to comment out some include
> statements in ~/.gtkrc-2.0)

It works beautifully! All the SetFont and SetColour methods take effect
the way you would expect them to. Well, now I am really confused.

OK, I've attached a simple test app that I ran under SUSE Linux 9.1 gtk2
(this is actually a small chunk of my app that I am working on). Attached
are also two screenshots that I took one after another on the same
machine. In one the sample was run with 2.5.2.8 and it shows what I want
it to look like (white text, dark green background). The other one was run
with 2.6.0.1 (the one with good font color but bad system default
background color).

I am puzzled.
Any ideas?
Appreciate it,
Ratko

test.py (901 Bytes)

Hi,

I'm trying to make a dragable grid, and a column of dates. I'd like the user can use the DatePickerCtrl to edit the dates in-place. The problem is that GridDragable extends from PyGridTableBase, which doesn't support the method SetCellEditor. So how do I change the default cell editor for GridDragable?

By the way, I've made a custom cell editor, wrapping around the DatePickerCtrl. I wonder if there is a default cell editor for dates?

Thanks

Dirksen

Dirksen Lau wrote:

Hi,

I'm trying to make a dragable grid, and a column of dates. I'd like the user can use the DatePickerCtrl to edit the dates in-place. The problem is that GridDragable extends from PyGridTableBase, which doesn't support the method SetCellEditor. So how do I change the default cell editor for GridDragable?

Are you talking about the GridDraggable.py in the demo? In that case only CustomDataTable derives from PyGridTableBase, the grid class does derive from wx.grid.Grid.

There are a few ways to do what you are seeking. You can use SetCellEditor or set the column attributes to include your date editor, or etc. Or, since you'll have a table to manage the data you can also have it manage telling the grid what the type of the data is and let it choose editors and renderers as needed. For example you can call grid.RegisterDataType(name, renderer, editor) to associate a cell editor and renderer with a custom type name, and then in the table class override GetTypeName(self, row, col) to return the appropriate type name for the given cell.

By the way, I've made a custom cell editor, wrapping around the DatePickerCtrl. I wonder if there is a default cell editor for dates?

There's a GridCellDateTimeRenderer class, but no editor.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Anybody?
I even tried running all the wxPython demos and NONE of them had the
colors set the way they should be (or they way they were under 2.5.2.8).
They were all system default (just like my app). The font colors were
all changed successfully but not the panel colors... Is there nothing
that can be done about this? I am having a hard time believing that
since everything worked properly before my upgrade to 2.6.0.1.
I would appreciate any ideas/hacks that people might have.
Thanks,

Ratko

> > Also, I don't believe that the theme doesn't allow the colors to
> > be changed since it worked fine before.
>
> Just for kicks try running your app with no active theme and see how

> it
> behaves then. Just unset GTK2_RC_FILES in a shell window and run

the

> app from there. (You may also have to comment out some include
> statements in ~/.gtkrc-2.0)

It works beautifully! All the SetFont and SetColour methods take
effect the way you would expect them to. Well, now I am really
confused.

OK, I've attached a simple test app that I ran under SUSE Linux 9.1

gtk2 (this is actually a small chunk of my app that I > am working on).
Attached are also two screenshots that I took one after another on the
same machine. In one the sample > > was run with 2.5.2.8 and it shows
what I want it to look like (white text, dark green background). The
other one was run > with 2.6.0.1 (the one with good font color but bad
system default background color).

···

I am puzzled.
Any ideas?
Appreciate it,
Ratko

Ratko Jagodic wrote:

Anybody?
I even tried running all the wxPython demos and NONE of them had the
colors set the way they should be (or they way they were under 2.5.2.8).
They were all system default (just like my app). The font colors were
all changed successfully but not the panel colors... Is there nothing
that can be done about this? I am having a hard time believing that
since everything worked properly before my upgrade to 2.6.0.1.
I would appreciate any ideas/hacks that people might have.

If it's something that works properly with no active gtk theme but doesn't with your usual theme then I think it is obvious where the problem is. Either there is a bug in how wxWidgets interacts with that theme, or the theme is buggy and wx causes it's bugs to become manifest. In either case the people that might know anything about it don't regularly read this mail list so please make a bug report about it using a category of "wxGTK specific" and give the details of your platform, theme, etc.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!