[Boa Constr] Re: StaticBoxSizer & StaticBox Label - Newbie question
Status: Beta
Brought to you by:
riaan
From: Werner F. B. <wer...@fr...> - 2004-10-20 07:56:02
|
Hi Tim, Are you mixing Anchors and Sizers on purpose? I believe one uses one or the other. Tried to have a look at it in Boa but the indent etc is all screwed up, can you send the file as an attachment. See you Werner Tim Black wrote: > Dear list, > > I added a StaticBoxSizer to a panel and associated it > with a StaticBox > which already had a label. When I did this, the label > and border of the > StaticBox no longer displayed, and the controls which > are children of > the FlexGridSizer which is a child of the > StaticBoxSizer are no longer > aligned correctly. I think my mistake is a simple > one, but I can't find > it. Could anyone offer a quick pointer? Thank you! > > The code is below. > > Tim Black > > ---------------------- > > #Boa:Frame:wxFrame1 > > from wxPython.wx import * > from wxPython.lib.anchors import LayoutAnchors > import os > > def create(parent): > return wxFrame1(parent) > > [wxID_WXFRAME1, wxID_WXFRAME1BUTTONGO, > wxID_WXFRAME1NOTEBOOK1, > wxID_WXFRAME1PANELHVN, wxID_WXFRAME1PANELSETTINGS, > wxID_WXFRAME1SPINCTRLNEWVOLS, > wxID_WXFRAME1SPINCTRLVOLSINSPAN, > wxID_WXFRAME1STATICBOXRANGE, > wxID_WXFRAME1STATICBOXSETTINGSALTERNATENUMBERINGS, > wxID_WXFRAME1STATICTEXTFIRSTVN, > wxID_WXFRAME1STATICTEXTLASTVN, > wxID_WXFRAME1STATICTEXTNEWVOLS, > wxID_WXFRAME1STATICTEXTSPANDELIMITER, > wxID_WXFRAME1STATICTEXTVOLSINRANGE, > wxID_WXFRAME1STATICTEXTVOLUMEPREFIX, > wxID_WXFRAME1TEXTCTRLFIRSTVN, > wxID_WXFRAME1TEXTCTRLLASTVN, > wxID_WXFRAME1TEXTCTRLSPANDELIMITER, > wxID_WXFRAME1TEXTCTRLVOLUMEPREFIX, > ] = map(lambda _init_ctrls: wxNewId(), range(19)) > > class wxFrame1(wxFrame): > def _init_coll_staticBoxSizerRange_Items(self, > parent): > # generated method, don't edit > > parent.AddSizer(self.flexGridSizerRange, 0, > border=0, flag=0) > > def > _init_coll_boxSizerVPanelAddHoldings_Items(self, > parent): > # generated method, don't edit > > parent.AddSizer(self.boxSizerHStaticBoxes, 0, > border=0, flag=0) > parent.AddWindow(self.buttonGo, 0, border=0, > flag=0) > > def _init_coll_flexGridSizerRange_Items(self, > parent): > # generated method, don't edit > > parent.AddWindow(self.staticTextFirstVN, 0, > border=0, flag=0) > parent.AddWindow(self.textCtrlFirstVN, 0, > border=0, flag=0) > parent.AddWindow(self.staticTextLastVN, 0, > border=0, flag=0) > parent.AddWindow(self.textCtrlLastVN, 0, > border=0, flag=0) > parent.AddWindow(self.staticTextNewVols, 0, > border=0, flag=0) > parent.AddWindow(self.spinCtrlNewVols, 0, > border=0, flag=0) > > def > _init_coll_staticBoxSizerSettingsAltNumberings_Items(self, > parent): > # generated method, don't edit > > > parent.AddSizer(self.flexGridSizerSettingsAltNumberings, > 0, > border=0, > flag=0) > > def _init_coll_notebook1_Pages(self, parent): > # generated method, don't edit > > parent.AddPage(imageId=-1, page=self.panelHVN, > select=True, > text='Add Holdings Vol Nums') > parent.AddPage(imageId=-1, > page=self.panelSettings, select=False, > text='Settings') > > def _init_sizers(self): > # generated method, don't edit > self.notebookSizer1 = > wxNotebookSizer(nb=self.notebook1) > > self.boxSizerVPanelAddHoldings = > wxBoxSizer(orient=wxVERTICAL) > > self.boxSizerHStaticBoxes = > wxBoxSizer(orient=wxHORIZONTAL) > > self.flexGridSizerRange = > wxFlexGridSizer(cols=2, hgap=0, rows=3, > vgap=0) > > self.staticBoxSizerRange = > wxStaticBoxSizer(box=self.staticBoxRange, > orient=wxVERTICAL) > > self.staticBoxSizerSettingsAltNumberings = > wxStaticBoxSizer(box=self.staticBoxSettingsAlternateNumberings, > orient=wxVERTICAL) > > self.flexGridSizerSettingsAltNumberings = > wxFlexGridSizer(cols=2, > hgap=0, rows=3, vgap=0) > > > self._init_coll_boxSizerVPanelAddHoldings_Items(self.boxSizerVPanelAddHoldings) > > self._init_coll_flexGridSizerRange_Items(self.flexGridSizerRange) > > self._init_coll_staticBoxSizerRange_Items(self.staticBoxSizerRange) > > self._init_coll_staticBoxSizerSettingsAltNumberings_Items(self.staticBoxSizerSettingsAltNumberings) > > def _init_ctrls(self, prnt): > # generated method, don't edit > wxFrame.__init__(self, id=wxID_WXFRAME1, > name='wxFrame1', > parent=prnt, > pos=wxPoint(258, 422), size=wxSize(494, > 284), > style=wxDEFAULT_FRAME_STYLE, > title='Library Task Manager') > self.SetClientSize(wxSize(486, 250)) > self.SetToolTipString('') > > self.SetIcon(wxIcon('book_bundle.ico',wxBITMAP_TYPE_ICO)) > self.SetStatusBarPane(0) > > self.notebook1 = > wxNotebook(id=wxID_WXFRAME1NOTEBOOK1, > name='notebook1', > parent=self, pos=wxPoint(0, 0), > size=wxSize(486, 250), > style=0) > self.notebook1.SetToolTipString('') > self.notebook1.Show(True) > self.notebook1.SetThemeEnabled(True) > > self.panelHVN = > wxPanel(id=wxID_WXFRAME1PANELHVN, name='panelHVN', > parent=self.notebook1, pos=wxPoint(0, > 0), size=wxSize(478, > 224), > style=wxTAB_TRAVERSAL) > self.panelHVN.SetAutoLayout(False) > self.panelHVN.SetToolTipString('') > > self.panelSettings = > wxPanel(id=wxID_WXFRAME1PANELSETTINGS, > name='panelSettings', > parent=self.notebook1, > pos=wxPoint(0, 0), > size=wxSize(478, 224), > style=wxTAB_TRAVERSAL) > self.panelSettings.SetToolTipString('') > self.panelSettings.SetLabel('') > > self.textCtrlFirstVN = > wxTextCtrl(id=wxID_WXFRAME1TEXTCTRLFIRSTVN, > name='textCtrlFirstVN', > parent=self.panelHVN, pos=wxPoint(122, > 13), size=wxSize(68, 0), > style=wxTE_PROCESS_ENTER, value='') > self.textCtrlFirstVN.SetToolTipString('') > self.textCtrlFirstVN.SetAutoLayout(False) > EVT_TEXT_ENTER(self.textCtrlFirstVN, > wxID_WXFRAME1TEXTCTRLFIRSTVN, > self.OnTextCtrlFirstVNTextEnter) > > self.textCtrlLastVN = > wxTextCtrl(id=wxID_WXFRAME1TEXTCTRLLASTVN, > name='textCtrlLastVN', > parent=self.panelHVN, > pos=wxPoint(122, 13), > size=wxSize(68, 21), > style=wxTE_PROCESS_ENTER, value='') > self.textCtrlLastVN.SetToolTipString('') > self.textCtrlLastVN.SetAutoLayout(False) > EVT_TEXT_ENTER(self.textCtrlLastVN, > wxID_WXFRAME1TEXTCTRLLASTVN, > self.OnTextCtrlLastVNTextEnter) > > self.spinCtrlNewVols = > wxSpinCtrl(id=wxID_WXFRAME1SPINCTRLNEWVOLS, > initial=1, max=100, min=0, > name='spinCtrlNewVols', > parent=self.panelHVN, pos=wxPoint(122, > 34), > size=wxSize(86, 21), > style=wxSP_ARROW_KEYS) > self.spinCtrlNewVols.SetToolTipString('') > self.spinCtrlNewVols.SetValue(1) > > self.textCtrlVolumePrefix = > wxTextCtrl(id=wxID_WXFRAME1TEXTCTRLVOLUMEPREFIX, > name='textCtrlVolumePrefix', > parent=self.panelHVN, > pos=wxPoint(368, 66), size=wxSize(68, > 21), style=0, > value='v.') > > self.textCtrlVolumePrefix.SetToolTipString('Enter > "v.", "no.", > or leave this blank') > > self.spinCtrlVolsInSpan = > wxSpinCtrl(id=wxID_WXFRAME1SPINCTRLVOLSINSPAN, > initial=0, max=100, min=1, > name='spinCtrlVolsInRange', > parent=self.panelHVN, pos=wxPoint(368, > 30), > size=wxSize(86, 21), > style=wxSP_ARROW_KEYS) > self.spinCtrlVolsInSpan.SetToolTipString('For > range containing > v.4-6, enter "3"') > self.spinCtrlVolsInSpan.SetValue(1) > > self.textCtrlSpanDelimiter = > wxTextCtrl(id=wxID_WXFRAME1TEXTCTRLSPANDELIMITER, > name='textCtrlSpanDelimiter', > parent=self.panelHVN, > pos=wxPoint(368, 98), size=wxSize(68, > 21), style=0, value='-') > > self.textCtrlSpanDelimiter.SetToolTipString("Enter a > forward > slash '/' for volumes spanning multiple years,\nor a > dash '-' for > physical volumes spanning multiple original volume > numbers") > > self.buttonGo = > wxButton(id=wxID_WXFRAME1BUTTONGO, label='Go', > name='buttonGo', parent=self.panelHVN, > pos=wxPoint(0, 136), > size=wxSize(68, 23), style=0) > self.buttonGo.SetToolTipString('') > self.buttonGo.SetThemeEnabled(True) > self.buttonGo.SetAutoLayout(False) > > self.buttonGo.SetConstraints(LayoutAnchors(self.buttonGo, > False, > False, > False, False)) > EVT_BUTTON(self.buttonGo, > wxID_WXFRAME1BUTTONGO, > self.OnButtonGoButton) > > self.staticTextNewVols = > wxStaticText(id=wxID_WXFRAME1STATICTEXTNEWVOLS, > label='&Number of labels to print:', > name='staticTextNewVols', > parent=self.panelHVN, pos=wxPoint(5, > 34), size=wxSize(117, > 13), > style=wxALIGN_RIGHT) > self.staticTextNewVols.SetToolTipString('') > > self.staticTextFirstVN = > wxStaticText(id=wxID_WXFRAME1STATICTEXTFIRSTVN, > label='&First volume number:', > name='staticTextFirstVN', > parent=self.panelHVN, pos=wxPoint(5, > 13), size=wxSize(97, 0), > style=wxALIGN_RIGHT) > > self.staticTextFirstVN.SetConstraints(LayoutAnchors(self.staticTextFirstVN, > True, True, False, False)) > self.staticTextFirstVN.SetAutoLayout(False) > > self.staticTextSpanDelimiter = > wxStaticText(id=wxID_WXFRAME1STATICTEXTSPANDELIMITER, > label='Span delimiter:', > name='staticTextSpanDelimiter', > parent=self.panelHVN, pos=wxPoint(264, > 102), > size=wxSize(69, 13), > style=0) > > self.staticTextSpanDelimiter.SetToolTipString('') > > self.staticTextVolsInRange = > wxStaticText(id=wxID_WXFRAME1STATICTEXTVOLSINRANGE, > label="# of &vol's in one bound > volume:", > name='staticTextVolsInRange', > parent=self.panelHVN, > pos=wxPoint(256, 26), size=wxSize(96, > 30), style=0) > > self.staticTextVolsInRange.SetToolTipString('') > > self.staticBoxRange = > wxStaticBox(id=wxID_WXFRAME1STATICBOXRANGE, > label='Enter range of volume numbers:', > name='staticBoxRange', > parent=self.panelHVN, pos=wxPoint(0, 0), > size=wxSize(0, 0), > style=wxCAPTION) > > self.staticBoxRange.SetConstraints(LayoutAnchors(self.staticBoxRange, > False, False, False, False)) > self.staticBoxRange.SetToolTipString('Enter > the range of volume > numbers to be entered') > self.staticBoxRange.SetAutoLayout(True) > > self.staticBoxSettingsAlternateNumberings = > wxStaticBox(id=wxID_WXFRAME1STATICBOXSETTINGSALTERNATENUMBERINGS, > label='Settings for alternate > numberings:', > > name='staticBoxSettingsAlternateNumberings', > parent=self.panelHVN, > pos=wxPoint(0, 0), size=wxSize(0, 0), > style=wxCAPTION) > > self.staticBoxSettingsAlternateNumberings.SetAutoLayout(True) > > self.staticTextLastVN = > wxStaticText(id=wxID_WXFRAME1STATICTEXTLASTVN, > label='&Last volume number:', > name='staticTextLastVN', > parent=self.panelHVN, pos=wxPoint(5, > 13), size=wxSize(98, 13), > style=wxALIGN_RIGHT) > > self.staticTextVolumePrefix = > wxStaticText(id=wxID_WXFRAME1STATICTEXTVOLUMEPREFIX, > label='Volume &prefix:', > name='staticTextVolumePrefix', > parent=self.panelHVN, pos=wxPoint(264, > 70), > size=wxSize(66, 13), > style=0) > > self.staticTextVolumePrefix.SetToolTipString('') > > > self._init_coll_notebook1_Pages(self.notebook1) > > self._init_sizers() > > def __init__(self, parent): > self._init_ctrls(parent) > self.textCtrlFirstVN.SetFocus() > # set accelerator keys > wxID_FIRSTVN, wxID_LASTVN, wxID_PREFIX, > wxID_RANGE = wxNewId(), > wxNewId(), wxNewId(), wxNewId() > self.SetAcceleratorTable(wxAcceleratorTable([ > (wxACCEL_ALT, ord('F'), wxID_FIRSTVN), > (wxACCEL_ALT, ord('L'), wxID_LASTVN), > (wxACCEL_ALT, ord('P'), wxID_PREFIX), > (wxACCEL_ALT, ord('V'), wxID_RANGE)])) > EVT_MENU(self, wxID_FIRSTVN, self.OnFirstVN) > EVT_MENU(self, wxID_LASTVN, self.OnLastVN) > EVT_MENU(self, wxID_PREFIX, self.OnPrefix) > EVT_MENU(self, wxID_RANGE, self.OnRange) > > def OnButtonGoButton(self, event): > # set variables > if self.textCtrlFirstVN.GetValue() != "": > firstVN = > int(self.textCtrlFirstVN.GetValue()) > else: self.msg('Please enter a value!') > if self.textCtrlLastVN.GetValue() != "": > lastVN = > int(self.textCtrlLastVN.GetValue()) > else: self.msg('Please enter a value!') > volumePrefix = > str(self.textCtrlVolumePrefix.GetValue()) > VolsInSpan = > str(self.spinCtrlVolsInSpan.GetValue()) > spanDelimiter = > str(self.textCtrlSpanDelimiter.GetValue()) > # execute system call > if firstVN < lastVN: > cmd = 'AutoHotkey.exe > add_periodical_holdings_cmdln.ahk ' + > str(firstVN) + ' ' + str(lastVN) + ' "' + volumePrefix > + '" ' + > VolsInSpan + ' "' + spanDelimiter + '"' > os.system(cmd) > else: > dlg = wxMessageDialog(self, 'The last > volume number is not > larger than the first volume number!\nPlease enter a > valid range.', > 'Invalid range!', wxOK | > wxICON_EXCLAMATION) > try: > dlg.ShowModal() > finally: > dlg.Destroy() > self.textCtrlFirstVN.SetFocus() > self.textCtrlFirstVN.SelectAll() > > def msg(self, msg): > dlg = wxMessageDialog(self, msg, > 'Message', wxOK ) > try: > dlg.ShowModal() > finally: > dlg.Destroy() > > def OnTextCtrlFirstVNTextEnter(self, event): > self.OnButtonGoButton(event) > > def OnTextCtrlLastVNTextEnter(self, event): > self.OnButtonGoButton(event) > > def OnFirstVN(self, event): > self.textCtrlFirstVN.SetFocus() > self.textCtrlFirstVN.SelectAll() > > def OnLastVN(self, event): > self.textCtrlLastVN.SetFocus() > self.textCtrlLastVN.SelectAll() > > def OnPrefix(self, event): > self.textCtrlVolumePrefix.SetFocus() > self.textCtrlVolumePrefix.SelectAll() > > def OnRange(self, event): > self.spinCtrlVolsInSpan.SetFocus() > > > > > _______________________________ > Do you Yahoo!? > Declare Yourself - Register online to vote today! > http://vote.yahoo.com > > > ------------------------------------------------------- > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl |