fowlertrainer@anonym.hu wrote:
This is my wxFreeDB main form.
My problem is that: I want to self.btnExit is aligned to right of the
form. I try with everything, but not everything has been failed.All of the controls are must be aligned to left, but btn_exit must be
aligned to rigth of the form.See this:
<Label><TextCtrl><SearchBtn>< ------------ expanded space -----------><ExitBtn>
what you need is for the space to have the stretch option set to >= 1, and not the others, except maybe the TextCtrl. Also, you've got it on a Panel, so when you add that panel to the main sizer, it needs to be able to stretch, using the wxEXPAND flag. here's a few select lines:
topsizer = wxBoxSizer(wxHORIZONTAL)
topsizer.Add(self.Label, 0,wxLEFT|wxALIGN_LEFT,2)
topsizer.Add(self.Text, 2,wxLEFT|wxALIGN_LEFT,2)
topsizer.Add(self.btnSearch, 1,wxLEFT|wxALIGN_LEFT,2)
topsizer.Add((1,1),1)
topsizer.Add(self.btnExit, 0, wxLEFT|wxALIGN_RIGHT,2)
I've added the TextCtrl with a stretch factor of 2, and teh space with a stretch factor of 1, this way they will both stretch, but the TextCtrl will stretch more.
self.MainSizer.Add(self.toppanel,0,wxEXPAND|wxALL|wxALIGN_CENTER_HORIZONTAL,2)
the wxEXPAND flag lets it stretch to fill the space in the opposite direction of the sizer.
A few other notes:
when you send code to the list, make sure it's stand-alone, freedb is not a standard module (all I had to do was comment out the import). Also, send out more than a few lines of code as an enclosure, some mail apps mangle white space.
you have a bunch of panels here, that are probably not required. Sizers can be nested, so you could do the same layout, all on the main dilaog. The only reason' I'd use panels is if you want to group controls in a way that you can re-use the group in other dialogs. In that case, you'll want to create separate class for your group, and use that.
you have set the size of the panels, which you probably don't want to do if you're using sizers (you can do something with SetSizeHints, if you want to set limits)
put some blank lines in your code, and organise it a little better. This is a mater of taste, but I found your code hard to read as everything is jammed together, and you got lines like the EVT_CLOSE binding right in the middle of code setting up your form.
Use the new "import wx" namespace. It's the way of the future, and really is cleaner.
Enclosed is a working version that I think gives you what you want.
junk.py (7.02 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