Re: SimGUI with a lot of parameters
Klaus G. Muller <kgmuller <at> xs4all.nl>
2009-11-16 13:37:42 GMT
Bonnie,
the first measure is to create a SimGUI window which uses the full
height of the screen, but I think you have done that already..
The second measure is to create multiple "Edit" menu entries (with
different labels, of course).
Let us take the SimGUI.py script itself as an example:
At line 69, insert multiple menu item commands, like so:
self.makeEdit1Menu()
self.makeEdit2Menu()
etc.
After line 87, insert multiple menu methods, like so:
def makeEdit1Menu(self):
self.edit1 = Menu(self.top)
self.edit1.add_command(label = 'Change parameters',
command = self.changeParameters1,
underline = 0)
self.edit1.add_command(label = 'Clear console',
command = self.clearConsole, underline = 1)
self.top.add_cascade(label = 'Edit1',
menu = self.edit1, underline = 0)
def makeEdit2Menu(self):
self.edit2 = Menu(self.top)
self.edit2.add_command(label = 'Change parameters',
command = self.changeParameters2,
underline = 0)
self.edit2.add_command(label = 'Clear console',
command = self.clearConsole, underline = 1)
self.top.add_cascade(label = 'Edit2',
menu = self.edit2, underline = 0)
etc.
All that remains is to partition the parameters into subsets which are
not too long to be shown in the window. Say there are three subsets, like:
Subset 1:
"first par"
. . . .
. . . .
"last par of this subset"
Subset 2:
"one par"
. . . .
. . . .
"another par"
Subset 3:
"yet another par"
. . . .
. . . .
"and another par"
Obviously, you have to pick the real names from the list returned by
self._parameters.__dict__.keys(). The edit boxes are generated in
lexical order of the parameter names.
Change changeParameters (l. 227) as follows:
def changeParameters(self):
"""Offers first subset of entry fields for parameter change"""
self.findParameters()
if not self._parameters:
showwarning('SimGUI warning', 'No Parameters instance found.')
return
t1 = Toplevel(self.root)
top = Frame(t1)
self.lbl={}
self.ent={}
i = 1
parKey={"start":"first par","end":"last par of this subset"
adding = False
done = False
for p in self._parameters.__dict__.keys():
if done:
break
if not adding:
continue
if p == parKey["start"]:
adding =True
if p == parKey["end"]:
done = True
self.lbl[p] = Label(top, text = p)
self.lbl[p].grid(row = i, column = 0)
self.ent[p] = Entry(top)
self.ent[p].grid(row = i, column = 1)
self.ent[p].insert(0, self._parameters.__dict__[p])
i += 1
top.pack(side = TOP, fill = BOTH, expand = YES)
commitBut = Button(top, text = 'Change parameters', command =
self.commit)
commitBut.grid(row = i, column = 1)
At line 249 insert multiple change parameter methods, like so:
def changeParameters1(self):
"""Offers a subset of entry fields for parameter change"""
self.findParameters()
if not self._parameters:
showwarning('SimGUI warning', 'No Parameters instance found.')
return
t1 = Toplevel(self.root)
top = Frame(t1)
self.lbl={}
self.ent={}
i = 1
parKey={"start":"one par","end":"another par"}
adding = False
done = False
for p in self._parameters.__dict__.keys():
if done:
break
if not adding:
continue
if p == parKey["start"]:
adding =True
if p == parKey["end"]:
done = True
self.lbl[p] = Label(top, text = p)
self.lbl[p].grid(row = i, column = 0)
self.ent[p] = Entry(top)
self.ent[p].grid(row = i, column = 1)
self.ent[p].insert(0, self._parameters.__dict__[p])
i += 1
top.pack(side = TOP, fill = BOTH, expand = YES)
commitBut = Button(top, text = 'Change parameters', command =
self.commit)
commitBut.grid(row = i, column = 1)
def changeParameters2(self):
"""Offers a subset of entry fields for parameter change"""
self.findParameters()
if not self._parameters:
showwarning('SimGUI warning', 'No Parameters instance found.')
return
t1 = Toplevel(self.root)
top = Frame(t1)
self.lbl={}
self.ent={}
i = 1
parKey={"start":"yet another par","end":"and another par"}
adding = False
done = False
for p in self._parameters.__dict__.keys():
if done:
break
if not adding:
continue
if p == parKey["start"]:
adding =True
if p == parKey["end"]:
done = True
self.lbl[p] = Label(top, text = p)
self.lbl[p].grid(row = i, column = 0)
self.ent[p] = Entry(top)
self.ent[p].grid(row = i, column = 1)
self.ent[p].insert(0, self._parameters.__dict__[p])
i += 1
top.pack(side = TOP, fill = BOTH, expand = YES)
commitBut = Button(top, text = 'Change parameters', command =
self.commit)
commitBut.grid(row = i, column = 1)
Now, I did not test this code, but something like this should solve your
problem of "parameter glut".
Let me know how it worked out, ok?
Klaus müller
Bonnie Douglas wrote:
> I was wondering if anyone has used SimGUI with a lot (I have 60) of parameters.
> I can only display about 44 in the Parameters window at a time and there is no
> scroll bar. If you have figured out how to display more than 40 or so
> parameters I'm very interested in your solution.
> Kind Regards,
> Bonnie Douglas
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Simpy-users mailing list
> Simpy-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simpy-users
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july