Dear Users,
This is my first time on this list, normally post many messages on the
VTK users forum. I've now got that bit of the program working and need
help with some GUI issues. My code is written in Python and also uses
VTK, but I haven't even got to adding the render windows to the GUI.
Tha main GUI with menu controls and status bars etc all on one class
which calls on another class which creates the user input frames were
default values may be adjusted. This user input class also refers to
another class which contains default values and lists for combo boxes
as well as text to go along side the combo boxes.
I've created it in this manner so that it is easy to change the
language of the program as one of our project partners are German, and
to be able to have another class record entered values and change the
lists and default values on the combo boxes to ease user interaction.
Right, description aside here's my problem. The main GUI calls a
function in a different class to create the menu which in turn creates
a frame and fills it with panels of checkboxes or comboboxes which are
created by other funtions in the same class. The program creates the
option window but does not wait for the window to be canceled, or
confirmed. I need to know how the window has been closed, whether by
the cross in the top corner, by the ok button, or perhaps by a cancel
button that I haven't created yet. If the widow has been closed or
canceled I want the program not to any calculations where as if it is
confirmed there are a few more functions I would like to call which
will use the values just set.
I've included a reduced section of my code bellow. All the bits that
are missing are similar to bits which are shown. The code is called by
the GUI just by creating an instance of the gather variables class.
class GatherVariables:
def __init__(self, mainwindow):
self.values = DefaultValues()
self.mainwindow = mainwindow
self.cells = self.values.cells
self.extents = self.values.extents
self.type = self.values.type
self.segment = self.values.segment
self.dzlyr = self.values.dzlyr
self.RegularBlockVariables()
def RegularBlockVariables(self):
wxFrame.__init__(self.mainwindow, NULL, -1, 'parent',
wxDefaultPosition, (500, 300))
self.frame = wxFrame(self.mainwindow, -1, "Sizer & input test")
axispanel = wxPanel(self.frame, -1, size=(100,100),
style=wxSUNKEN_BORDER)
panel1 = self.NumCellsPanel(axispanel)
panel2 = self.LowValuePanel(axispanel)
panel3 = self.ExtentPanel(axispanel)
panel4 = self.LayerPanel(self.frame)
panel5 = self.OkPanel(self.frame)
axispanelsizer = wxBoxSizer(wxHORIZONTAL)
axispanelsizer.Add( panel1, 1, wxALL, 0 )
axispanelsizer.Add( panel2, 1, wxALL, 0 )
axispanelsizer.Add( panel3, 1, wxALL, 0 )
axispanel.SetAutoLayout(1)
axispanel.SetSizer(axispanelsizer)
axispanelsizer.Fit(axispanel)
axispanelsizer.SetSizeHints(axispanel)
assemblysizer = wxBoxSizer(wxVERTICAL)
assemblysizer.Add( axispanel, 1, wxGROW, 20 )
assemblysizer.Add( panel4, 0, wxGROW, 20 )
assemblysizer.Add( panel5, 0, wxGROW, 20 )
self.frame.SetAutoLayout(1)
self.frame.SetSizer(assemblysizer)
assemblysizer.Fit(self.frame)
assemblysizer.SetSizeHints(self.frame)
self.frame.Show(1)
def NumCellsPanel(self, parent):
ID_NCELLSX = wxNewId()
ID_NCELLSY = wxNewId()
ID_NCELLSZ = wxNewId()
panel = wxPanel(parent, -1, size=(100,100), style=wxSUNKEN_BORDER)
sizer = wxGridSizer(cols = 2)
wxtext0 = wxStaticText(panel, -1, self.values.text0)
wxtext1 = wxStaticText(panel, -1, self.values.text1)
wxtext2 = wxStaticText(panel, -1, self.values.text2)
ncellsxinp = wxComboBox(panel, ID_NCELLSX, '%.0f' %
self.values.cells[0], wxPoint(80, 50), wxSize(95, -1),
self.values.ncellsxlst, wxCB_DROPDOWN)
ncellsyinp = wxComboBox(panel, ID_NCELLSY, '%.0f' %
self.values.cells[1], wxPoint(80, 50), wxSize(95, -1),
self.values.ncellsylst, wxCB_DROPDOWN)
ncellszinp = wxComboBox(panel, ID_NCELLSZ, '%.0f' %
self.values.cells[2], wxPoint(80, 50), wxSize(95, -1),
self.values.ncellszlst, wxCB_DROPDOWN)
sizer.Add( wxtext0, 1, wxALL, 10 )
sizer.Add( ncellsxinp, 1, wxALL, 10 )
sizer.Add( wxtext1, 1, wxALL, 10 )
sizer.Add( ncellsyinp, 1, wxALL, 10 )
sizer.Add( wxtext2, 1, wxALL, 10 )
sizer.Add( ncellszinp, 1, wxALL, 10 )
EVT_COMBOBOX(self.mainwindow, ID_NCELLSX, self.EvtComboBox0)
EVT_TEXT_ENTER(self.mainwindow, ID_NCELLSX, self.EvtComboBox0)
EVT_COMBOBOX(self.mainwindow, ID_NCELLSY, self.EvtComboBox1)
EVT_TEXT_ENTER(self.mainwindow, ID_NCELLSY, self.EvtComboBox1)
EVT_COMBOBOX(self.mainwindow, ID_NCELLSZ, self.EvtComboBox2)
EVT_TEXT_ENTER(self.mainwindow, ID_NCELLSZ, self.EvtComboBox2)
panel.SetAutoLayout(1)
panel.SetSizer(sizer)
sizer.Fit(panel)
sizer.SetSizeHints(panel)
return panel
def OkPanel(self, parent):
ID_OK = wxNewId()
panel = wxPanel(parent, -1, size=(100,100), style=wxSUNKEN_BORDER)
sizer = wxGridSizer(cols = 1)
okbutton = wxButton(panel, ID_OK, 'Ok')
sizer.Add( okbutton, -1, wxALIGN_CENTRE, 10 )
EVT_BUTTON(self.mainwindow, ID_OK, self.EvtTextOk)
panel.SetAutoLayout(1)
panel.SetSizer(sizer)
sizer.Fit(panel)
sizer.SetSizeHints(panel)
return panel
def EvtComboBox0(self, event):
self.values.cells[0] = float(event.GetString())
def EvtTextOk(self, event):
self.frame.Destroy()
Thank you very much for any help or advice you can offer! As of
February 2004 I'm new to programming (as may be very apparent!) and
the GUI creation is the part I'm least familiar with.
Yours Faithfully,
Wesley Brooks