Painting wx.grid control leftover

Hi!

When I delete some rows or columns, my grid becomes smaller, but not the container Frame.
If I left with only few columns or rows, the remainder of the surface of the main frame becomes white.
I want to paint it to to the default frame gray colour.

At first I tried to set frame background colour, because any part of the frame uncovered
by any widgets on it should show frame and it’s background colour, but it is not the case
with the grid.

    wx.Frame.__init__(self, ...)
    self.SetBackgroundColour(COLOUR)
    . . .
    self.grid = wx.grid.Grid(self)

Next I tried set the grid background colour, but with the same success …
I also tried with panel and it works, but whole table shrinks to a small rectangular.
And if I use grid.Fit() command, grid control expand, but I lose scroll bars from it on larger tables …

What can I do about it ( other then leaving remainder surface with white colour :slight_smile: ) ?

Kind regards,

Neven

When you change a widget's appearance, you should call Layout on the
parent. Calling Refresh() might fix it too. I think the default color
is one of the wx.SYS_COLOUR_XXX, but I'm not sure which one it is.
Check out http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.SystemSettings.html
for more info.

···

On Mar 3, 4:41 am, Neven Goršić <neven.gor...@gmail.com> wrote:

Hi!

When I delete some rows or columns, my grid becomes smaller, but not the
container Frame.
If I left with only few columns or rows, the remainder of the surface of the
main frame becomes white.
I want to paint it to to the default frame gray colour.

At first I tried to set frame background colour, because any part of the
frame uncovered
by any widgets on it should show frame and it's background colour, but it is
not the case
with the grid.

    wx\.Frame\.\_\_init\_\_\(self, \.\.\.\)
    self\.SetBackgroundColour\(COLOUR\)
    \. \. \.
    self\.grid = wx\.grid\.Grid\(self\)

Next I tried set the grid background colour, but with the same success ...
I also tried with panel and it works, but whole table shrinks to a small
rectangular.
And if I use grid.Fit() command, grid control expand, but I lose scroll bars
from it on larger tables ...

What can I do about it ( other then leaving remainder surface with white
colour :slight_smile: ) ?

Kind regards,

Neven

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

Blog: http://blog.pythonlibrary.org

Hi!

I am not sure if I understand you quite right. I don’t want to change any system settings.
I just want to set background colour on the right side of grid in case when right and down
boundary of the border column and row is visible. On defult that remainder surface is white.

Layout and Force refresh of the parent doesn’t help.

Why setting frame or grid background colour is not enough?
Can you write down explicitly how to solve my problem?
Thank you,

Neven

···

On Wed, Mar 3, 2010 at 6:00 PM, Mike Driscoll kyosohma@gmail.com wrote:

On Mar 3, 4:41 am, Neven Goršić neven.gor...@gmail.com wrote:

Hi!

When I delete some rows or columns, my grid becomes smaller, but not the

container Frame.

If I left with only few columns or rows, the remainder of the surface of the

main frame becomes white.

I want to paint it to to the default frame gray colour.

At first I tried to set frame background colour, because any part of the

frame uncovered

by any widgets on it should show frame and it’s background colour, but it is

not the case

with the grid.

    wx.Frame.__init__(self, ...)
    self.SetBackgroundColour(COLOUR)
    . . .
    self.grid = wx.grid.Grid(self)

Next I tried set the grid background colour, but with the same success …

I also tried with panel and it works, but whole table shrinks to a small

rectangular.

And if I use grid.Fit() command, grid control expand, but I lose scroll bars

from it on larger tables …

What can I do about it ( other then leaving remainder surface with white

colour :slight_smile: ) ?

Kind regards,

Neven

When you change a widget’s appearance, you should call Layout on the

parent. Calling Refresh() might fix it too. I think the default color

is one of the wx.SYS_COLOUR_XXX, but I’m not sure which one it is.

Check out http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.SystemSettings.html

for more info.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

I wasn't suggesting that you change any of your system's settings.
Instead, you probably just need to reset the color on the panel
(although I don't know why...Refresh() should have done that).

Anyway, I found that I had written this up last year here:

Here's the part you probably care about:

<code>
color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND)
panel.SetBackgroundColour(color)
</code>

Good luck!

···

On Mar 3, 1:36 pm, Neven Goršić <neven.gor...@gmail.com> wrote:

Hi!

I am not sure if I understand you quite right. I don't want to change any
system settings.
I just want to set background colour on the right side of grid in case when
right and down
boundary of the border column and row is visible. On defult that remainder
surface is white.

Layout and Force refresh of the parent doesn't help.

Why setting frame or grid background colour is not enough?
Can you write down explicitly how to solve my problem?
Thank you,

Neven

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

Blog: http://blog.pythonlibrary.org

Thank you!

···

On Wed, Mar 3, 2010 at 9:22 PM, Mike Driscoll kyosohma@gmail.com wrote:

On Mar 3, 1:36 pm, Neven Goršić neven.gor...@gmail.com wrote:

Hi!

I am not sure if I understand you quite right. I don’t want to change any

system settings.

I just want to set background colour on the right side of grid in case when

right and down

boundary of the border column and row is visible. On defult that remainder

surface is white.

Layout and Force refresh of the parent doesn’t help.

Why setting frame or grid background colour is not enough?

Can you write down explicitly how to solve my problem?

Thank you,

Neven

I wasn’t suggesting that you change any of your system’s settings.

Instead, you probably just need to reset the color on the panel

(although I don’t know why…Refresh() should have done that).

Anyway, I found that I had written this up last year here:

http://www.blog.pythonlibrary.org/2009/09/03/wxpython-resetting-the-background-color/

Here’s the part you probably care about:

color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND)

panel.SetBackgroundColour(color)

Good luck!


Mike Driscoll

Blog: http://blog.pythonlibrary.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

You are probably seeing the grid itself, not the frame. The grid is not always the same size as the number of cells, and by default the extra space is filled with white. If you want to verify this you can add the WIT to your app so you can have it show you the outlines of the widgets in the app. http://wiki.wxpython.org/Widget_Inspection_Tool

···

On 3/3/10 2:41 AM, Neven Goršić wrote:

Hi!

When I delete some rows or columns, my grid becomes smaller, but not the
container Frame.
If I left with only few columns or rows, the remainder of the surface of
the main frame becomes white.
I want to paint it to to the default frame gray colour.

At first I tried to set frame background colour, because any part of the
frame uncovered
by any widgets on it should show frame and it's background colour, but
it is not the case
with the grid.

         wx.Frame.__init__(self, ...)
         self.SetBackgroundColour(COLOUR)
         . . .
         self.grid = wx.grid.Grid(self)

Next I tried set the grid background colour, but with the same success ...
I also tried with panel and it works, but whole table shrinks to a small
rectangular.
And if I use grid.Fit() command, grid control expand, but I lose scroll
bars from it on larger tables ...

What can I do about it ( other then leaving remainder surface with white
colour :slight_smile: ) ?

--
Robin Dunn
Software Craftsman

Thank you. I am longing for consistency in my knowedge, but I don’t understand many things in wx.Python, and the following are among others:

My first idea was, if that remaining area is a part of grid, I will set grid background to gray and white remainder space will disappear. Why it is not so?

My second idea was, if it is a part of frame, I will set frame background to gray and white remainder space will disappear. Why it is not so?

Does the definition of background says that the background is any uncovered area of container by child widgets? Is the grid an exception? Or I miss interpret the definition and meaning?

···

On Fri, Mar 5, 2010 at 6:14 AM, Robin Dunn robin@alldunn.com wrote:

On 3/3/10 2:41 AM, Neven Goršić wrote:

Hi!

When I delete some rows or columns, my grid becomes smaller, but not the

container Frame.

If I left with only few columns or rows, the remainder of the surface of

the main frame becomes white.

I want to paint it to to the default frame gray colour.

At first I tried to set frame background colour, because any part of the

frame uncovered

by any widgets on it should show frame and it’s background colour, but

it is not the case

with the grid.

     wx.Frame.__init__(self, ...)

     self.SetBackgroundColour(COLOUR)

     . . .

     self.grid = wx.grid.Grid(self)

Next I tried set the grid background colour, but with the same success …

I also tried with panel and it works, but whole table shrinks to a small

rectangular.

And if I use grid.Fit() command, grid control expand, but I lose scroll

bars from it on larger tables …

What can I do about it ( other then leaving remainder surface with white

colour :slight_smile: ) ?

You are probably seeing the grid itself, not the frame. The grid is not always the same size as the number of cells, and by default the extra space is filled with white. If you want to verify this you can add the WIT to your app so you can have it show you the outlines of the widgets in the app. http://wiki.wxpython.org/Widget_Inspection_Tool

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Add the WIT to your code and it will let you see the structure of the widgets in the app, their properties, and also let you highlight each so you can see where it is located. http://wiki.wxpython.org/Widget_Inspection_Tool

···

On 3/6/10 2:02 PM, Neven Goršić wrote:

Thank you. I am longing for consistency in my knowedge, but I don't
understand many things in wx.Python, and the following are among others:

My first idea was, if that remaining area is a part of grid, I will set
grid background to gray and white remainder space will disappear. Why it
is not so?

My second idea was, if it is a part of frame, I will set frame
background to gray and white remainder space will disappear. Why it is
not so?

Does the definition of background says that the background is any
uncovered area of container by child widgets? Is the grid an exception?
Or I miss interpret the definition and meaning?

--
Robin Dunn
Software Craftsman