# # This file is part of Documancer (http://documancer.sf.net) # # Copyright (C) 2003 Vaclav Slavik # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: confgui.py,v 1.2 2005/01/26 22:07:37 vaclavslavik Exp $ # # Info pages documentation provider - GUI configuration panel (Unix) # from wxPython.wx import * ID_PAGE_CHECKBOX = wxNewId() ID_PAGE = wxNewId() from provider import getInfopagesList class InfoSettingsPanel(wxPanel): def __init__(self, *args, **kwds): # begin wxGlade: InfoSettingsPanel.__init__ kwds["style"] = wxTAB_TRAVERSAL wxPanel.__init__(self, *args, **kwds) self.page_checkbox = wxCheckBox(self, ID_PAGE_CHECKBOX, "Only one &page:") self.page = wxChoice(self, ID_PAGE, choices=[""]) self.__set_properties() self.__do_layout() # end wxGlade self.__inOnChange = 0 EVT_CHECKBOX(self, ID_PAGE_CHECKBOX, self.OnChange) EVT_CHOICE(self, ID_PAGE, self.OnChange) def __set_properties(self): # begin wxGlade: InfoSettingsPanel.__set_properties self.page.SetSize(wxDLG_SZE(self.page, (100, -1))) self.page.Enable(0) self.page.SetSelection(0) # end wxGlade bcur = wxBusyCursor() self.page.Clear() self.allPagesList = [key for key,title,url in getInfopagesList()] self.page.AppendItems(self.allPagesList) def __do_layout(self): # begin wxGlade: InfoSettingsPanel.__do_layout sizer_8 = wxBoxSizer(wxVERTICAL) sizer_1 = wxBoxSizer(wxHORIZONTAL) sizer_1.Add(self.page_checkbox, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5) sizer_1.Add(self.page, 1, 0, 0) sizer_8.Add(sizer_1, 0, wxALL|wxEXPAND, 5) self.SetAutoLayout(1) self.SetSizer(sizer_8) sizer_8.Fit(self) sizer_8.SetSizeHints(self) # end wxGlade def SetDialog(self, dlg): self.dialog = dlg def OnChange(self, event): if self.__inOnChange: return self.__inOnChange = 1 self.page.Enable(self.page_checkbox.IsChecked()) self.dialog.UpdateBook() self.__inOnChange = 0 def SetData(self, attr): self.__inOnChange = 1 if 'page' in attr and attr['page'] != '': page = attr['page'] if page in self.allPagesList: self.page.SetStringSelection(page) else: wxLogError('Unknown info page %s' % page) self.page.Enable(1) self.page_checkbox.SetValue(1) else: self.page.Enable(0) self.page_checkbox.SetValue(0) self.__inOnChange = 0 def GetData(self): d = {} if self.page_checkbox.GetValue(): d['page'] = self.page.GetStringSelection() else: d['page'] = '' return d # end of class InfoSettingsPanel