--- nfo/projects/netfraggle/bin/FraggleDialogModules.py 2004/09/01 20:56:32 1.1 +++ nfo/projects/netfraggle/bin/FraggleDialogModules.py 2004/09/05 12:17:20 1.5 @@ -1,39 +1,79 @@ -#Boa:Dialog:wxModuleDialog +#Boa:Dialog:FraggleDialogModules from wxPython.wx import * +import FraggleCtlModules + def create(parent): - return wxModuleDialog(parent) + return FraggleDialogModules(parent) -[wxID_WXMODULEDIALOG, wxID_WXMODULEDIALOGBUTTON1, - wxID_WXMODULEDIALOGBUTTONSAVECLOSE, wxID_WXMODULEDIALOGCHECKLISTBOXMODULES, +[wxID_FRAGGLEDIALOGMODULES, wxID_FRAGGLEDIALOGMODULESBUTTON1, + wxID_FRAGGLEDIALOGMODULESBUTTONSAVECLOSE, + wxID_FRAGGLEDIALOGMODULESCHECKLISTBOXMODULES, ] = map(lambda _init_ctrls: wxNewId(), range(4)) -class wxModuleDialog(wxDialog): - def _init_utils(self): - # generated method, don't edit - pass - +class FraggleDialogModules(wxDialog): + def _init_ctrls(self, prnt): # generated method, don't edit - wxDialog.__init__(self, id=wxID_WXMODULEDIALOG, name='wxModuleDialog', - parent=prnt, pos=wxPoint(256, 167), size=wxSize(189, 288), - style=wxDEFAULT_DIALOG_STYLE, title='Module Setup') - self._init_utils() + wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGMODULES, + name='FraggleDialogModules', parent=prnt, pos=wxPoint(256, 167), + size=wxSize(197, 315), style=wxDEFAULT_DIALOG_STYLE, + title='Module Setup') self.SetClientSize(wxSize(189, 288)) self.checkListBoxModules = wxCheckListBox(choices=[], - id=wxID_WXMODULEDIALOGCHECKLISTBOXMODULES, + id=wxID_FRAGGLEDIALOGMODULESCHECKLISTBOXMODULES, name='checkListBoxModules', parent=self, pos=wxPoint(8, 8), size=wxSize(168, 248), style=0, validator=wxDefaultValidator) + EVT_CHECKLISTBOX(self.checkListBoxModules, + wxID_FRAGGLEDIALOGMODULESCHECKLISTBOXMODULES, + self.OnCheckListBoxModulesChecklistbox) - self.buttonSaveClose = wxButton(id=wxID_WXMODULEDIALOGBUTTONSAVECLOSE, + self.buttonSaveClose = wxButton(id=wxID_FRAGGLEDIALOGMODULESBUTTONSAVECLOSE, label='Save and Close', name='buttonSaveClose', parent=self, pos=wxPoint(8, 264), size=wxSize(88, 16), style=0) - - self.button1 = wxButton(id=wxID_WXMODULEDIALOGBUTTON1, label='Cancel', - name='button1', parent=self, pos=wxPoint(104, 264), - size=wxSize(72, 16), style=0) - + EVT_BUTTON(self.buttonSaveClose, + wxID_FRAGGLEDIALOGMODULESBUTTONSAVECLOSE, + self.OnButtonSaveCloseButton) + + self.button1 = wxButton(id=wxID_FRAGGLEDIALOGMODULESBUTTON1, + label='Cancel', name='button1', parent=self, pos=wxPoint(104, + 264), size=wxSize(72, 16), style=0) + + def __init_listbox__(self,parent): + + try: + for i in self.modulesCtl.modules.keys(): + self.checkListBoxModules.Append(i) + except AttributeError: + print "No Modules found" + + for b in self.selections: + self.checkListBoxModules.Check(self.modulesCtl.modules.keys().index(b)) + + def __init__(self, parent): + self.modulesCtl = parent.engine.modules + self.selections = self.modulesCtl.LoadModules() self._init_ctrls(parent) + self.__init_listbox__(parent) + + def OnCheckListBoxModulesChecklistbox(self, event): + try: + if self.checkListBoxModules.IsChecked(event.GetInt()): + print "Checked" + self.selections.Append(self.modulesCtl.modules.keys()[event.GetInt()]) + else: + print "Unchecked" + self.selections.pop(event.GetInt()) + except AttributeError: + self.selections = [self.modulesCtl.modules.keys()[event.GetInt()]] + #print event.GetInt() + + + def OnButtonSaveCloseButton(self, event): + self.modulesCtl.SaveModules(self.selections) + self.Hide() + event.Skip() +