Hi, please could someone point a programming newbie in the right
direction?
I'm working on my first wxPython app, using Python 2.5.2 and wxPython
2.6.3.2.2, under Ubuntu Linux 8.04 (Hardy Heron). Eventually I hope it
will be a front end to dgen, the megadrive/genesis emulator.
There's a menu bar, tool bar, status bar and a main panel. The main
panel has four children, 2 list boxes, a static bitmap and a static box.
I've then nested two vertical box sizers into a horizontal box sizer.
The result is a roughly quartered main panel - two list boxes on the
left (listing roms and save games), a static bitmap on the top-right
(in-game screenshots) and a static box on the bottom-right (rom
info/codes).
It looks ok and at start-up it will load a bitmap into the top-right
static bitmap, scaling it to the required initial size. If I click on
another item in the list of roms, it will load another bitmap, again
scaling it to the right size no matter what the size of the main window.
My problem comes when maximising/minimising or re-sizing the main
window. The sizers reposition the items lovely, except for the static
bitmap which stays the same size, i.e. if window is maximised the image
won't fill the whole sizer, but it will once I select another rom/game
in the list; if I then minimise or re-size from this state most of the
image is now obscured.
I sort of expected this and had already thought that I may have to
capture the resize event of the app and place some code there that will
re-scale the bitmap. However when I capture the re-size event to a
rescalebitmap function it would appear to get executed before the gui is
initially fully built and throws up errors (i.e. (python:17605):
Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget
with width -4 and height 17). Not only that but all the sizers seem to
get messed up and I end up with a near blank panel except for some kind
of small mess in the top-left hand corner of the panel. If you run the
attached code commenting/uncommenting out line 65 as required, you'll
see what I mean.
It's driving me mad. Could someone please advise me of an alternative
method to get the image to fill the sizer on resize of the main
window/panel or the proper way to bind the SIZE/SIZING events. I would
be very grateful.
Thanks in advance.
Rgds,
Martin
Cut-Down Sample Code Attached:
test.py (3.19 KB)