Displaying a staticbitmap

I have a panel into which I want to place a wx.Window and into that a wx.StaticBitmap.
I want the window/bitmap to be centered on the panel. When I do this directly, the image is
more-or-less centered on the panel but the image's minor axis is compressed somewhat.
When I cause a redraw by dragging the frame off the desktop and then back on
then the image appears in its proper proportions. so:

1) How can I center the image knowing the dimensions of the panel ? and,

2) How can a force a redraw so that the proper-sized image appears ?
(or prevent the compressed appearance directly)

3) When I want a new bitmap to be displayed, how can I "erase" the previous image
before I lay down the new one ?

Thanks,
Ray Pasco

Ray Pasco wrote:

I have a panel into which I want to place a wx.Window and into that a wx.StaticBitmap.
I want the window/bitmap to be centered on the panel. When I do this directly, the image is
more-or-less centered on the panel but the image's minor axis is compressed somewhat.
When I cause a redraw by dragging the frame off the desktop and then back on
then the image appears in its proper proportions. so:

1) How can I center the image knowing the dimensions of the panel ? and,

You're best bet is probably to use Sizers, rather than figuring it out yourself.

2) How can a force a redraw so that the proper-sized image appears ?
(or prevent the compressed appearance directly)

That's weird, and shouldn't happen anyway. Post a small working sample here that demonstrates the problem, and someone will probably help you figure out what's up.

3) When I want a new bitmap to be displayed, how can I "erase" the previous image
before I lay down the new one ?

Have you looked at:

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

It should give you some hints.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Ray Pasco wrote:

I have a panel into which I want to place a wx.Window and into that a wx.StaticBitmap.
I want the window/bitmap to be centered on the panel. When I do this directly, the image is
more-or-less centered on the panel but the image's minor axis is compressed somewhat.
When I cause a redraw by dragging the frame off the desktop and then back on
then the image appears in its proper proportions. so:

1) How can I center the image knowing the dimensions of the panel ? and,

You're best bet is probably to use Sizers, rather than figuring it out yourself.

2) How can a force a redraw so that the proper-sized image appears ?
(or prevent the compressed appearance directly)

That's weird, and shouldn't happen anyway. Post a small working sample here that demonstrates the problem, and someone will probably help you figure out what's up.

3) When I want a new bitmap to be displayed, how can I "erase" the previous image
before I lay down the new one ?

Have you looked at:

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

It should give you some hints.

-Chris

(Python 2.3.5, wxPython 2.4.5.1 on XP)

The wiki example does not work correctly ! The wiki code has been attached.

To get it to work right in some fashion I had to rewrite it extensively by creating a whole new frame
just to display it. On the next image display I destroyed any previous frame and created a new one,
a weird hack, but at least this works properly.

BITMAPS.WIKI.PY (3.01 KB)

Ray Pasco wrote:

Chris Barker wrote:

Have you looked at:

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

(Python 2.3.5, wxPython 2.4.5.1 on XP)

Is there really a 2.4.5.1? Perhaps you mean 2.5.4.1?
                     ^

The wiki example does not work correctly ! The wiki code has been attached.

I just updated it a little, but probably didn't change anything that would fix your problem. I've tested it with wxGTK 2.5.3.1. I think a few things with Sizers may have changed a little in the upgrade to

To get it to work right in some fashion I had to rewrite it extensively by creating a whole new frame
just to display it. On the next image display I destroyed any previous frame and created a new one,
a weird hack, but at least this works properly.

That is too weird a hack. We need to find a better way. Please try the enclosed code first, then tell us what your symptoms are. You could post your version too, if you like. Maybe I'll try this on 2.5.4.1 on my Mac.

-Chris

wxStaticBitmap.py (3.18 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Ray Pasco wrote:

Chris Barker wrote:
  Have you looked at:
(Python 2.3.5, wxPython 2.4.5.1 on XP)

Is there really a 2.4.5.1? Perhaps you mean 2.5.4.1?

                ^
The wiki example does not work correctly !  

The wiki code has been attached.

I just updated it a little, but probably didn’t change anything that
would fix your problem. I’ve tested it with wxGTK 2.5.3.1. I think a
few things with Sizers may have changed a little in the upgrade to

To get it to work right in some fashion  I

had to rewrite it extensively by creating a whole new frame

just to display it. On the next image display I destroyed any previous
frame and created a new one,

a weird hack, but at least this works properly.

That is too weird a hack. We need to find a better way. Please try the
enclosed code first, then tell us what your symptoms are. You could
post your version too, if you like. Maybe I’ll try this on 2.5.4.1 on
my Mac.

-Chris



---


#!/usr/bin/env python2.3
# I Always specify the python version in the #! line, it makes it much
# easier to have multiple versions on your system
import wxversion
# This has been tested with 2.4.2 and 2.5.3.1
wxversion.select("2.5")
#wxversion.select("2.4")

No, I really meant 2.5.4.1 (a bit of finger dyslexia at play, I guess)

The attached still does not display correctly. This has been broken for
at least a year.

I remember playing with the wiki example for a long time without
getting it to work

properly until I radically rewrote it in a way that is not generally
useful… The bitmap scaling

and/or display is definitely wacko. IMO this is a bug or at there needs
to be some extra calls

to make it work under MSW.

BTW, having multiple versions of Python on MSW is problematic

since there can only be one set of Registry settings.

The line “#!/usr/bin/env” is totally meaningless for plain MSW. Perhaps
for MinGW or MSYS.

STATICBITMAP.MODIFIED WIKI EXAMPLE.PY (3.17 KB)

···

http://wiki.wxpython.org/index.cgi/wxStaticBitmap

Ray Pasco wrote:

No, I really meant 2.5.4.1 (a bit of finger dyslexia at play, I guess)

The attached still does not display correctly. This has been broken for at least a year.
I remember playing with the wiki example for a long time without getting it to work
properly until I radically rewrote it in a way that is not generally useful.. The bitmap scaling
and/or display is definitely wacko. IMO this is a bug or at there needs to be some extra calls
to make it work under MSW.

This is the Refresh bug mentioned last week. Try it with the last 2.5.5 preview. Or you can use self.Image.Refresh() instead of self.Refresh().

BTW, having multiple versions of Python on MSW is problematic
since there can only be one set of Registry settings.
The line "#!/usr/bin/env" is totally meaningless for plain MSW. Perhaps

The Python registry settings are versioned, so you can have multiple major.minor versions with no problems. And if you have batch files or aliases or something that let you run each version then you can get it to be almost as nice as on a POSIX system.

···

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

Robin Dunn wrote:

Ray Pasco wrote:

No, I really meant 2.5.4.1 (a bit of finger dyslexia at play, I guess)

The attached still does not display correctly. This has been broken for at least a year.
I remember playing with the wiki example for a long time without getting it to work
properly until I radically rewrote it in a way that is not generally useful.. The bitmap scaling
and/or display is definitely wacko. IMO this is a bug or at there needs to be some extra calls
to make it work under MSW.

This is the Refresh bug mentioned last week. Try it with the last 2.5.5 preview. Or you can use self.Image.Refresh() instead of self.Refresh().

BTW, having multiple versions of Python on MSW is problematic
since there can only be one set of Registry settings.
The line "#!/usr/bin/env" is totally meaningless for plain MSW. Perhaps

The Python registry settings are versioned, so you can have multiple major.minor versions with no problems. And if you have batch files or aliases or something that let you run each version then you can get it to be almost as nice as on a POSIX system.

I missed the discussion from last week. How does one review older messages ?

Compiling 2.5.5 preview is out of the question for me so I tried using Image.Refresh() on both the frame
and the wx.Window. The method is not available. What does the .Image part refer to ?
Refresh() is available but does not correct the problem.

Any idea when 2.5.5 will get an installer for MSW ?

Thanks again

Ray Pasco wrote:

Robin Dunn wrote:

Ray Pasco wrote:

No, I really meant 2.5.4.1 (a bit of finger dyslexia at play, I guess)

The attached still does not display correctly. This has been broken for at least a year.
I remember playing with the wiki example for a long time without getting it to work
properly until I radically rewrote it in a way that is not generally useful.. The bitmap scaling
and/or display is definitely wacko. IMO this is a bug or at there needs to be some extra calls
to make it work under MSW.

This is the Refresh bug mentioned last week. Try it with the last 2.5.5 preview. Or you can use self.Image.Refresh() instead of self.Refresh().

BTW, having multiple versions of Python on MSW is problematic
since there can only be one set of Registry settings.
The line "#!/usr/bin/env" is totally meaningless for plain MSW. Perhaps

The Python registry settings are versioned, so you can have multiple major.minor versions with no problems. And if you have batch files or aliases or something that let you run each version then you can get it to be almost as nice as on a POSIX system.

I missed the discussion from last week. How does one review older messages ?

Compiling 2.5.5 preview is out of the question for me so I tried using Image.Refresh() on both the frame
and the wx.Window. The method is not available. What does the .Image part refer to ?
Refresh() is available but does not correct the problem.

Any idea when 2.5.5 will get an installer for MSW ?

Thanks again
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I was able to download 2.5.5.0pre and installed it.
This version, together with a call to .Refresh() solves the problem !

Thanks muchly,
Ray Pasco

Ray Pasco wrote:

I was able to download 2.5.5.0pre and installed it.
This version, together with a call to .Refresh() solves the problem !

Does this mean that the wxStaticBitmap in the Wiki needs a .Refresh() to work correctly on Windows? If so, could you please add that? I'd like to have that sample working on all systems.

If you don't want to deal with the Wiki, send me a corrected version, and I'll put it in.

thanks, -Chris

Chris Barker wrote:

Ray Pasco wrote:

I was able to download 2.5.5.0pre and installed it.
This version, together with a call to .Refresh() solves the problem !

Does this mean that the wxStaticBitmap in the Wiki needs a .Refresh() to work correctly on Windows? If so, could you please add that? I'd like to have that sample working on all systems.

If you don't want to deal with the Wiki, send me a corrected version, and I'll put it in.

thanks, -Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Even with the .Refresh the wiki example still doesn't work. I think its because
the bitmap doesn't have its own wx.Window to go into. I will try that and let you know.

Ray Pasco

Ray Pasco wrote:

Chris Barker wrote:

Ray Pasco wrote:

I was able to download 2.5.5.0pre and installed it.
This version, together with a call to .Refresh() solves the problem !

Does this mean that the wxStaticBitmap in the Wiki needs a .Refresh() to work correctly on Windows? If so, could you please add that? I'd like to have that sample working on all systems.

If you don't want to deal with the Wiki, send me a corrected version, and I'll put it in.

thanks, -Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Even with the .Refresh the wiki example still doesn't work. I think its because
the bitmap doesn't have its own wx.Window to go into. I will try that and let you know.

Ray Pasco

I tried to rewrite the wiki example without success, but I think I know why my version works:
I create a wx.Window for holding the static bitmap. I then create a PIL image that
is exacly the size of the window and fill it with the background color. I scale the PIL file image
and merge it into the background PIL image, centered. Then I convert the merged PIL
image into a bitmap and load it into the statcbitmap. This works properly even if the app frame is resized.
Even with this procedure, .Refresh() still needs to be called on the bitmap window after each
staticbitmap load.

I am not familiar with wx.Image and its associated methods, but I think the same procedure
should be able to be done using wx.Python.

I hope this helps.

Ray Pasco.

BITMAPS.WIKI.PY (3.57 KB)

Ray Pasco wrote:

I missed the discussion from last week. How does one review older messages ?

http://lists.wxwidgets.org/

Compiling 2.5.5 preview is out of the question for me so I tried using Image.Refresh() on both the frame
and the wx.Window. The method is not available. What does the .Image part refer to ?

It was the wx.StaticBitmap in one of the samples that either you or Chris sent.

···

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

Chris Barker wrote:

Ray Pasco wrote:

I was able to download 2.5.5.0pre and installed it.
This version, together with a call to .Refresh() solves the problem !

Does this mean that the wxStaticBitmap in the Wiki needs a .Refresh() to work correctly on Windows?

Just for 2.5.4.1.

···

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

Ray Pasco wrote:

Even with the .Refresh the wiki example still doesn't work.

weird.

I think its because
the bitmap doesn't have its own wx.Window to go into.

wxStaticBitmap is a wx.Window, it shouldn't need another one.

I tried to rewrite the wiki example without success, but I think I know why my version works:
I create a wx.Window for holding the static bitmap. I then create a PIL image that
is exacly the size of the window and fill it with the background color. I scale the PIL file image
and merge it into the background PIL image, centered. Then I convert the merged PIL
image into a bitmap and load it into the statcbitmap. This works properly even if the app frame is resized.

This sounds like WAY too much work. Maybe I'll wait for the next release, and try that out. But even with this release, all it should need is an extra .Refresh() call.

I am not familiar with wx.Image and its associated methods, but I think the same procedure
should be able to be done using wx.Python.

Yes, wx.Image supports all that functionality, but it still seems like too much work, You may have uncovered another bug.

I'll add the Refresh() , and see if others can test and find the same problem.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Ray Pasco wrote:

Even with the .Refresh the wiki example still doesn't work.

weird.

I think its because
the bitmap doesn't have its own wx.Window to go into.

wxStaticBitmap is a wx.Window, it shouldn't need another one.

Really ? Well, I know how to position a Window, but not a staticbitmap

I tried to rewrite the wiki example without success, but I think I know why my version works:
I create a wx.Window for holding the static bitmap. I then create a PIL image that
is exacly the size of the window and fill it with the background color. I scale the PIL file image
and merge it into the background PIL image, centered. Then I convert the merged PIL
image into a bitmap and load it into the statcbitmap. This works properly even if the app frame is resized.

This sounds like WAY too much work. Maybe I'll wait for the next release, and try that out. But even with this release, all it should need is an extra .Refresh() call.

Actually, this rigamorole took only 5 lines of code, once the image was resized.

I am not familiar with wx.Image and its associated methods, but I think the same procedure
should be able to be done using wx.Python.

Yes, wx.Image supports all that functionality, but it still seems like too much work, You may have uncovered another bug.

I'll add the Refresh() , and see if others can test and find the same problem.

-Chris

Thanks,
Ray

Ray Pasco wrote:

Chris Barker wrote:

wxStaticBitmap is a wx.Window, it shouldn't need another one.

Really ? Well, I know how to position a Window, but not a staticbitmap

Exactly the same way you would position a wx.Window, call its SetPosition method, let a sizer manage its layout, or etc.

···

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