File: SimGUImanual.html

package info (click to toggle)
python-simpy 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 17,300 kB
  • ctags: 2,568
  • sloc: python: 11,172; makefile: 145
file content (589 lines) | stat: -rw-r--r-- 36,608 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>SimGUI Manual &mdash; SimPy 2.3.1 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '2.3.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="top" title="SimPy 2.3.1 documentation" href="../../index.html" />
    <link rel="up" title="SimPy Tools" href="../../SimPy_Tools.html" />
    <link rel="next" title="Visualize model events and states using SimulationGUIDebug" href="../../SimulationGUIDebug.html" />
    <link rel="prev" title="SimPlot Manual" href="../PlotManual/ManualPlotting.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../SimulationGUIDebug.html" title="Visualize model events and states using SimulationGUIDebug"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../PlotManual/ManualPlotting.html" title="SimPlot Manual"
             accesskey="P">previous</a> |</li>
        <li><a href="../../index.html">SimPy 2.3.1 documentation</a> &raquo;</li>
          <li><a href="../../SimPy_Tools.html" accesskey="U">SimPy Tools</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="simgui-manual">
<h1><a class="toc-backref" href="#id1">SimGUI Manual</a><a class="headerlink" href="#simgui-manual" title="Permalink to this headline">¶</a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Authors:</th><td class="field-body">Klaus Muller &lt;<a class="reference external" href="mailto:Muller&#37;&#52;&#48;users&#46;sourceforge&#46;net">Muller<span>&#64;</span>users<span>&#46;</span>sourceforge<span>&#46;</span>net</a>&gt;</td>
</tr>
<tr class="field-even field"><th class="field-name">SimPy release:</th><td class="field-body">2.3.1</td>
</tr>
<tr class="field-odd field"><th class="field-name">Web-site:</th><td class="field-body"><a class="reference external" href="http://simpy.sourceforge.net/">http://simpy.sourceforge.net/</a></td>
</tr>
<tr class="field-even field"><th class="field-name">Python-Version:</th><td class="field-body">2.6 and later</td>
</tr>
<tr class="field-odd field"><th class="field-name">Date:</th><td class="field-body">December 2011</td>
</tr>
</tbody>
</table>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#simgui-manual" id="id1">SimGUI Manual</a><ul>
<li><a class="reference internal" href="#acknowledgements" id="id2">Acknowledgements</a></li>
<li><a class="reference internal" href="#introduction" id="id3">Introduction</a></li>
<li><a class="reference internal" href="#simgui-overview" id="id4">SimGUI overview</a></li>
<li><a class="reference internal" href="#the-simgui-api" id="id5">The SimGUI API</a></li>
<li><a class="reference internal" href="#miscellaneous-simgui-capabilities" id="id6">Miscellaneous SimGUI capabilities</a></li>
</ul>
</li>
</ul>
</div>
<p>This manual describes <strong>SimGUI</strong>, a GUI framework for SimPy simulation applications.</p>
<div class="section" id="acknowledgements">
<h2><a class="toc-backref" href="#id2">Acknowledgements</a><a class="headerlink" href="#acknowledgements" title="Permalink to this headline">¶</a></h2>
<p>The initial ideas for using a Tk/Tkinter-based GUI for SimPy simulation models
and first applications came from Mike Mellor and Prof. Simon Frost of University
of California, San Diego. Simon has been a very productive co-developer of SimGUI.</p>
<p>Following an idea by Simon Frost, SimGUI uses a great Tkinter-based console for conversing
with the Python interpreter, developed by Ka-Ping Yee &lt;<a class="reference external" href="mailto:ping&#37;&#52;&#48;lfw&#46;org">ping<span>&#64;</span>lfw<span>&#46;</span>org</a>&gt;.</p>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id3">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>SimGUI is a GUI framework for SimPy simulation programs. It provides for:</p>
<blockquote>
<div><ul class="simple">
<li>a standard layout of the user interface, including its menu structure</li>
<li>running a simulation</li>
<li>viewing simulation output</li>
<li>saving the output to a file</li>
<li>changing the simulation model parameters</li>
<li>viewing a model description</li>
<li>viewing the simulation program&#8217;s code</li>
<li>a Python console for debugging</li>
</ul>
</div></blockquote>
<p>SimGUI is based on the Tk GUI library.</p>
</div>
<div class="section" id="simgui-overview">
<h2><a class="toc-backref" href="#id4">SimGUI overview</a><a class="headerlink" href="#simgui-overview" title="Permalink to this headline">¶</a></h2>
<p>Here is a minimalistic program which does nothing but show the SimGUI user interface:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## SimGUIminimal.py</span>
<span class="kn">from</span> <span class="nn">SimPy.SimGUI</span> <span class="kn">import</span> <span class="o">*</span>
<span class="n">root</span><span class="o">=</span><span class="n">Tk</span><span class="p">()</span>
<span class="n">gu</span><span class="o">=</span><span class="n">SimGUI</span><span class="p">(</span><span class="n">root</span><span class="p">,</span><span class="n">consoleHeight</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
<span class="n">gu</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
<p>Running it produces this output:</p>
<img alt="../../_images/Minimal.png" src="../../_images/Minimal.png" />
<p>The large frame is the <strong>SimGUI application window</strong>. To its right are
the standard menu items of SimGUI. To show them, the menus have been torn off by
clicking on the dotted line on all SimGUI drop-down menu items.</p>
<p>The SimGUI application window consists of five widgets:</p>
<blockquote>
<div><ul>
<li><p class="first">the outside frame is a Tk Toplevel widget with a default title (which can be changed),</p>
<blockquote>
<div><ul>
<li><p class="first">a <strong>menu bar</strong>, a Tk Menu widget which can be adapted by the application program (contained in toplevel)</p>
</li>
<li><p class="first">the <strong>output window</strong>, a Tk Frame widet for SimPy program output (contained in toplevel)</p>
<blockquote>
<div><ul class="simple">
<li>the <strong>status bar</strong> for one-line status messages, a Tk Label widget (contained in output window)</li>
<li>the <strong>output console</strong> for application output, a Tk Text widget (contained in output window)</li>
</ul>
</div></blockquote>
</li>
</ul>
</div></blockquote>
</li>
</ul>
</div></blockquote>
<p>The <strong>File</strong> sub-menu is for saving or opening files and also for quitting the application. By default, it supports
saving the content of the output console.</p>
<p>The <strong>Edit</strong> sub-menu is for any editing or change operations. By default, it supports changing model parameters
and clearing the output console.</p>
<p>The <strong>Run</strong> sub-menu is for running the SimPy model. By default, it is empty, as there is no model to run.</p>
<p>The <strong>View</strong> sub-menu is for calling up any application output, e.g. plots or statistics. By default, it has the ability
to automatically show the data from any Monitor instance in the SimPy application.</p>
<p>The <strong>Help</strong> sub-menu is for viewing any information about SimGUI and the specific application behind it.
By default, it provides information about the version of SimGUI, lists the application&#8217;s code and allows
the launching of a Python console for testing and debugging purposes.</p>
<p>To show how simple it is to interface a model to SimGUI, here is an example with a simple simulation model:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python</span>
<span class="n">__doc__</span><span class="o">=</span><span class="s">&quot;&quot;&quot; GUIdemo.py</span>
<span class="s">This is a very basic model, demonstrating the ease</span>
<span class="s">of interfacing to SimGUI.</span>
<span class="s">&quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">generators</span>
<span class="kn">from</span> <span class="nn">SimPy.Simulation</span>  <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">random</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">SimPy.SimGUI</span> <span class="kn">import</span> <span class="o">*</span>

<span class="k">class</span> <span class="nc">Launcher</span><span class="p">(</span><span class="n">Process</span><span class="p">):</span>
    <span class="n">nrLaunched</span><span class="o">=</span><span class="mi">0</span>
    <span class="k">def</span> <span class="nf">launch</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
            <span class="n">gui</span><span class="o">.</span><span class="n">writeConsole</span><span class="p">(</span><span class="s">&quot;Launch at </span><span class="si">%.1f</span><span class="s">&quot;</span><span class="o">%</span><span class="n">now</span><span class="p">())</span>
            <span class="n">Launcher</span><span class="o">.</span><span class="n">nrLaunched</span><span class="o">+=</span><span class="mi">1</span>
            <span class="n">gui</span><span class="o">.</span><span class="n">launchmonitor</span><span class="o">.</span><span class="n">observe</span><span class="p">(</span><span class="n">Launcher</span><span class="o">.</span><span class="n">nrLaunched</span><span class="p">)</span>
            <span class="k">yield</span> <span class="n">hold</span><span class="p">,</span><span class="bp">self</span><span class="p">,</span><span class="n">uniform</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">gui</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">maxFlightTime</span><span class="p">)</span>
            <span class="n">gui</span><span class="o">.</span><span class="n">writeConsole</span><span class="p">(</span><span class="s">&quot;Boom!!! Aaaah!! at </span><span class="si">%.1f</span><span class="s">&quot;</span><span class="o">%</span><span class="n">now</span><span class="p">())</span>

<span class="k">def</span> <span class="nf">model</span><span class="p">():</span>
    <span class="n">gui</span><span class="o">.</span><span class="n">launchmonitor</span><span class="o">=</span><span class="n">Monitor</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;Rocket counter&quot;</span><span class="p">,</span>
                              <span class="n">ylab</span><span class="o">=</span><span class="s">&quot;nr launched&quot;</span><span class="p">,</span><span class="n">tlab</span><span class="o">=</span><span class="s">&quot;time&quot;</span><span class="p">)</span>
    <span class="n">initialize</span><span class="p">()</span>
    <span class="n">Launcher</span><span class="o">.</span><span class="n">nrLaunched</span><span class="o">=</span><span class="mi">0</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">gui</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">nrLaunchers</span><span class="p">):</span>
        <span class="n">lau</span><span class="o">=</span><span class="n">Launcher</span><span class="p">()</span>
        <span class="n">activate</span><span class="p">(</span><span class="n">lau</span><span class="p">,</span><span class="n">lau</span><span class="o">.</span><span class="n">launch</span><span class="p">())</span>
    <span class="n">simulate</span><span class="p">(</span><span class="n">until</span><span class="o">=</span><span class="n">gui</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">duration</span><span class="p">)</span>
    <span class="n">gui</span><span class="o">.</span><span class="n">noRunYet</span><span class="o">=</span><span class="bp">False</span>
    <span class="n">gui</span><span class="o">.</span><span class="n">writeStatusLine</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> rockets launched in </span><span class="si">%.1f</span><span class="s"> minutes&quot;</span><span class="o">%</span>
                        <span class="p">(</span><span class="n">Launcher</span><span class="o">.</span><span class="n">nrLaunched</span><span class="p">,</span><span class="n">now</span><span class="p">()))</span>

<span class="k">class</span> <span class="nc">MyGUI</span><span class="p">(</span><span class="n">SimGUI</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">win</span><span class="p">,</span><span class="o">**</span><span class="n">par</span><span class="p">):</span>
        <span class="n">SimGUI</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">win</span><span class="p">,</span><span class="o">**</span><span class="n">par</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">run</span><span class="o">.</span><span class="n">add_command</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">&quot;Start fireworks&quot;</span><span class="p">,</span>
                             <span class="n">command</span><span class="o">=</span><span class="n">model</span><span class="p">,</span><span class="n">underline</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">=</span><span class="n">Parameters</span><span class="p">(</span><span class="n">duration</span><span class="o">=</span><span class="mi">2000</span><span class="p">,</span><span class="n">maxFlightTime</span><span class="o">=</span><span class="mf">11.7</span><span class="p">,</span><span class="n">nrLaunchers</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>

<span class="n">root</span><span class="o">=</span><span class="n">Tk</span><span class="p">()</span>
<span class="n">gui</span><span class="o">=</span><span class="n">MyGUI</span><span class="p">(</span><span class="n">root</span><span class="p">,</span><span class="n">title</span><span class="o">=</span><span class="s">&quot;RocketGUI&quot;</span><span class="p">,</span><span class="n">doc</span><span class="o">=</span><span class="n">__doc__</span><span class="p">,</span><span class="n">consoleHeight</span><span class="o">=</span><span class="mi">40</span><span class="p">)</span>
<span class="n">gui</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span>
</pre></div>
</div>
<p>It produces the following output when the model run command is selected:</p>
<img alt="../../_images/GUIdemo.png" src="../../_images/GUIdemo.png" />
<p>class MyGUI adds one menu item under the Run menu. It also defines three parameters
(duration, maxFlighTime and nrLaunchers) with their initial values which the user can
change interactively before each run. The MyGUI instance named gui sets the
window title, the model description (the __doc__ string) and the height of the
output window.</p>
<p>The simulation part of the program writes to the output console and to the status line.</p>
<p>The model uses a Monitor for keeping track of the number of rockets launched over
time. Because it is made an attribute of the MyGUI instance, the super class
(SimGUI) can output the Monitor after a run. This requires no application code.
When the menu item &#8216;Collected data&#8217; under the View menu is selected, this
results in:</p>
<img alt="../../_images/GUIdemoMoni.png" src="../../_images/GUIdemoMoni.png" />
</div>
<div class="section" id="the-simgui-api">
<h2><a class="toc-backref" href="#id5">The SimGUI API</a><a class="headerlink" href="#the-simgui-api" title="Permalink to this headline">¶</a></h2>
<div class="section" id="structure">
<h3>Structure<a class="headerlink" href="#structure" title="Permalink to this headline">¶</a></h3>
<p>The SimGUI module exposes the following API to the applications programmer:</p>
<div class="highlight-python"><pre>class SimGUI(object)
        def __init__
                self.doc = doc
                self.noRunYet=True
                self.top = Menu
                self.file = Menu
                self.edit = Menu
                self.run = Menu
                self.view = Menu
                self.help = Menu
        def makeFileMenu
        def makeEditMenu
        def makeRunMenu
        def makeViewMenu
        def makeHelpMenu
        def writeConsole
        def saveConsole
        def clearConsole
        def writeStatusLine
        def about
        def notdone
        def showTextBox
        def mainloop

class Parameters
        def __init__
        def show</pre>
</div>
</div>
<div class="section" id="class-simgui-init-constructor">
<h3><strong>class SimGUI, __init__ constructor</strong><a class="headerlink" href="#class-simgui-init-constructor" title="Permalink to this headline">¶</a></h3>
<p>Encapsulates the SimGUI functionality.</p>
<dl class="docutils">
<dt>Call:</dt>
<dd><strong>&lt;variable&gt;.SimGUI(win[,optional parameters])</strong></dd>
<dt>Mandatory parameters:</dt>
<dd><ul class="first last simple">
<li><strong>win</strong> : the master widget in which the SimGUI widgets are embedded</li>
</ul>
</dd>
<dt>Optional parameters:</dt>
<dd><ul class="first last simple">
<li><strong>title=SimGUI</strong> : the title of the top level window (string)</li>
<li><strong>doc=None</strong> : the model description (string)</li>
<li><strong>consoleHeight=50</strong> : the height of the output console in lines (positive integer)</li>
</ul>
</dd>
<dt>Return value:</dt>
<dd>Returns a reference to the SimGUI instance.</dd>
</dl>
</div>
<div class="section" id="simgui-instance-fields">
<h3><strong>SimGUI instance fields</strong><a class="headerlink" href="#simgui-instance-fields" title="Permalink to this headline">¶</a></h3>
<p>In addition to the constructor parameters, the SimGUI fields of interest
to the applications programmer are:</p>
<blockquote>
<div><ul class="simple">
<li><strong>self.noRunYet=True</strong> : a predicate indicating whether the model has been run yet; must be set to True after each model run; should be tested by application program before any run-dependent output is produced (boolean)</li>
<li><strong>self.top = Menu</strong> : the top level menu widget (menu bar)</li>
<li><strong>self.file = Menu</strong> : the &#8216;File&#8217; menu widger</li>
<li><strong>self.edit = Menu</strong> : the &#8216;Edit&#8217; menu widget</li>
<li><strong>self.run = Menu</strong> : the &#8216;Run&#8217; menu widget</li>
<li><strong>self.view = Menu</strong> : the &#8216;View&#8217; menu widget</li>
<li><strong>self.help = Menu</strong> : the &#8216;Help&#8217; menu widget</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="adding-menu-items">
<h3><strong>Adding menu items</strong><a class="headerlink" href="#adding-menu-items" title="Permalink to this headline">¶</a></h3>
<p>Menu items can be added to SimGUI submenus by:</p>
<blockquote>
<div><strong>&lt;menufield&gt;.add_command(label= &lt;string,command=&lt;callable&gt;, underline=&lt;integer&gt;)</strong></div></blockquote>
<p>E.g. <em>self.run.add_command(label=&#8221;Start fireworks&#8221;,command=model,underline=0)</em>. This is all
standard Tk/Tkinter syntax &#8211; read any Tk/Tkinter manual or book.</p>
</div>
<div class="section" id="changing-menus">
<h3><strong>Changing menus</strong><a class="headerlink" href="#changing-menus" title="Permalink to this headline">¶</a></h3>
<p>Any of the submenus provided by SimGUI can be replaced by overloading one or
more of the methods <strong>makeFileMenu, makeEditMenu, makeRunMenu, makeViewMenu,
makeHelpMenu</strong>. This is done by defining the methods to be overloaded in the SimGUI
subclass.</p>
<p>The overloading method should look like:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">makeFileMenu</span><span class="p">():</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file</span> <span class="o">=</span> <span class="n">Menu</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">top</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file</span><span class="o">.</span><span class="n">add_command</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;Save some results&#39;</span><span class="p">,</span>
                      <span class="n">command</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">saveResults</span><span class="p">,</span> <span class="n">underline</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file</span><span class="o">.</span><span class="n">add_command</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;Get out of here&#39;</span><span class="p">,</span>
                 <span class="n">command</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">win</span><span class="o">.</span><span class="n">quit</span><span class="p">,</span><span class="n">underline</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">top</span><span class="o">.</span><span class="n">add_cascade</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;File&#39;</span><span class="p">,</span><span class="n">menu</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">file</span><span class="p">,</span><span class="n">underline</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
<p><em>Note: It is advisable to keep the basic the SimGUI menu structure in order
to maintain the SimGUI look-and-feel.</em></p>
</div>
<div class="section" id="writeconsole">
<h3><strong>writeConsole</strong><a class="headerlink" href="#writeconsole" title="Permalink to this headline">¶</a></h3>
<p>Writes a string into the output console Text widget, with newline at end.</p>
<p>Call:</p>
<blockquote>
<div><strong>&lt;SimGUI instance&gt;.writeConsole(text)</strong></div></blockquote>
<dl class="docutils">
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd><ul class="first last simple">
<li><strong>text=&#8217;&#8216;</strong> : text to write (string)</li>
</ul>
</dd>
<dt>Return value:</dt>
<dd>None.</dd>
</dl>
</div>
<div class="section" id="saveconsole">
<h3><strong>saveConsole</strong><a class="headerlink" href="#saveconsole" title="Permalink to this headline">¶</a></h3>
<p>Saves output console to a text file which the user is prompted to name.</p>
<dl class="docutils">
<dt>Call:</dt>
<dd><strong>&lt;SimGUI instance&gt;.saveConsole()</strong></dd>
<dt>Mandatory parameters:</dt>
<dd>None</dd>
<dt>Optional parameters:</dt>
<dd>None</dd>
<dt>Return value:</dt>
<dd>None</dd>
</dl>
</div>
<div class="section" id="clearconsole">
<h3><strong>clearConsole</strong><a class="headerlink" href="#clearconsole" title="Permalink to this headline">¶</a></h3>
<p>Clears output console.</p>
<dl class="docutils">
<dt>Call:</dt>
<dd><strong>&lt;SimGUI instance&gt;.clearConsole()</strong></dd>
<dt>Mandatory parameters:</dt>
<dd>None</dd>
<dt>Optional parameters:</dt>
<dd>None</dd>
<dt>Return value:</dt>
<dd>None</dd>
</dl>
</div>
<div class="section" id="writestatusline">
<h3><strong>writeStatusLine</strong><a class="headerlink" href="#writestatusline" title="Permalink to this headline">¶</a></h3>
<p>Writes a one-line string to the status line.</p>
<p>Call:</p>
<blockquote>
<div><strong>&lt;SimGUI instance&gt;.writeStatusLine(text)</strong></div></blockquote>
<dl class="docutils">
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd><ul class="first last simple">
<li><strong>text=&#8217;&#8216;</strong> : text to write (string, not longer than 80 character)</li>
</ul>
</dd>
<dt>Return value:</dt>
<dd>None.</dd>
</dl>
</div>
<div class="section" id="notdone">
<h3><strong>notdone</strong><a class="headerlink" href="#notdone" title="Permalink to this headline">¶</a></h3>
<p>Brings up a warning box staing that a feature is not implemented yet.
Useful during development of application.</p>
<p>Call:</p>
<blockquote>
<div><strong>&lt;SimGUI instance&gt;.notdone()</strong></div></blockquote>
<dl class="docutils">
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd>None.</dd>
<dt>Return value:</dt>
<dd>None.</dd>
</dl>
</div>
<div class="section" id="showtextbox">
<h3><strong>showTextBox</strong><a class="headerlink" href="#showtextbox" title="Permalink to this headline">¶</a></h3>
<p>Pops up a text box (Text widget)with a text in it.</p>
<p>Call:</p>
<blockquote>
<div><strong>&lt;SimGUI instance&gt;.showTextBox(optional parameters)</strong></div></blockquote>
<dl class="docutils">
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd><ul class="first last simple">
<li><strong>title=&#8217;&#8216;</strong> : title of text box (string)</li>
<li><strong>text=&#8217;&#8216;</strong> : text to write (string)</li>
<li><strong>width=80</strong> : width of box in characters (positive integer)</li>
<li><strong>height=10</strong> : height of box in lines (positive integer)</li>
</ul>
</dd>
<dt>Return value:</dt>
<dd>None.</dd>
</dl>
</div>
<div class="section" id="mainloop">
<h3><strong>mainloop</strong><a class="headerlink" href="#mainloop" title="Permalink to this headline">¶</a></h3>
<p>Starts up SimGUI execution.</p>
<dl class="docutils">
<dt>Call:</dt>
<dd><strong>&lt;SimGUI instance&gt;.mainloop()</strong></dd>
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd>None.</dd>
<dt>Return value:</dt>
<dd>None</dd>
</dl>
</div>
<div class="section" id="class-parameters-init-constructor-and-adding-parameters">
<h3><strong>class Parameters, __init__ constructor and adding parameters</strong><a class="headerlink" href="#class-parameters-init-constructor-and-adding-parameters" title="Permalink to this headline">¶</a></h3>
<p>This class provides for interactive user changes of model parameters. Any user-input
is checked against the type of the original (default) value of the parameter.In this version,
parameters of type integer, floating point, text and list are supported.
Boolean parameters can be implemented by using 0 for False and 1 for True.</p>
<dl class="docutils">
<dt>Example:</dt>
<dd><p class="first">gui.params=Parameters(endtime=2000,
numberCustomers=50,
interval=10.0,
trace=0)</p>
<p class="last">This results in parameters gui.params.numberCustomers, gui.params.interval and gui.params.trace.</p>
</dd>
<dt>Call:</dt>
<dd><strong>&lt;SimGUI instance&gt;.params=Parameters(par)</strong> (constructor)
<strong>&lt;SimGUI instance&gt;.params.&lt;name&gt;=&lt;value&gt;</strong> (adding parameters)</dd>
<dt>Mandatory parameters:</dt>
<dd><ul class="first last simple">
<li><strong>par</strong> : one or more pairs <em>&lt;name&gt;=&lt;value&gt;</em>, separated by commas. &lt;value&gt; must be one of the four types supported.</li>
<li><strong>&lt;name&gt;</strong> : the parameter name (any legal Python identifier)</li>
<li><strong>&lt;value&gt;</strong> : the parameter&#8217;s initial value (must be one of the four types supported, i.e. integer/boolean, floating point, text and list)</li>
</ul>
</dd>
<dt>Optional parameters:</dt>
<dd>None.</dd>
<dt>Return value:</dt>
<dd>A Parameter instance.</dd>
</dl>
</div>
<div class="section" id="show">
<h3><strong>show</strong><a class="headerlink" href="#show" title="Permalink to this headline">¶</a></h3>
<p>Returns the parameter name/value pairs of a Parameter instance in pretty-printed form
(one pair per line).</p>
<dl class="docutils">
<dt>Call:</dt>
<dd><strong>&lt;Parameter instance&gt;.show()</strong></dd>
<dt>Mandatory parameters:</dt>
<dd>None.</dd>
<dt>Optional parameters:</dt>
<dd>None.</dd>
<dt>Return value:</dt>
<dd>A string with the name/value pairs separated by newline (&#8216;n&#8217;).</dd>
</dl>
</div>
</div>
<div class="section" id="miscellaneous-simgui-capabilities">
<h2><a class="toc-backref" href="#id6">Miscellaneous SimGUI capabilities</a><a class="headerlink" href="#miscellaneous-simgui-capabilities" title="Permalink to this headline">¶</a></h2>
<div class="section" id="source-code-listing">
<h3><strong>Source code listing</strong><a class="headerlink" href="#source-code-listing" title="Permalink to this headline">¶</a></h3>
<p>The &#8216;Model code&#8217; item of the &#8216;Help&#8217; submenu lists the application code
of a running SimGUI application by outputting the content of sys.argv[0].
No user programming is required for this.</p>
</div>
<div class="section" id="automatic-display-of-monitor-instances">
<h3><strong>Automatic display of Monitor instances</strong><a class="headerlink" href="#automatic-display-of-monitor-instances" title="Permalink to this headline">¶</a></h3>
<p>After a model run, any Monitor instance which is referred to by a SimGUI (sub)class instance
is shown in the output console by the &#8216;Collected data&#8217; item on the &#8216;View&#8217;
submenu. Just e.g. <strong>gui.waitMon=Monitor(&#8220;Waiting times&#8221;)</strong>, where gui refers to
a SimGUI (sub)class instance, is enough to facilitate this.</p>
<p>$Revision: 297 $ $Date: 2009-03-31 02:24:46 +1300 (Tue, 31 Mar 2009) $ kgm</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sm_SimPy_Logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">SimGUI Manual</a><ul>
<li><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#simgui-overview">SimGUI overview</a></li>
<li><a class="reference internal" href="#the-simgui-api">The SimGUI API</a><ul>
<li><a class="reference internal" href="#structure">Structure</a></li>
<li><a class="reference internal" href="#class-simgui-init-constructor"><strong>class SimGUI, __init__ constructor</strong></a></li>
<li><a class="reference internal" href="#simgui-instance-fields"><strong>SimGUI instance fields</strong></a></li>
<li><a class="reference internal" href="#adding-menu-items"><strong>Adding menu items</strong></a></li>
<li><a class="reference internal" href="#changing-menus"><strong>Changing menus</strong></a></li>
<li><a class="reference internal" href="#writeconsole"><strong>writeConsole</strong></a></li>
<li><a class="reference internal" href="#saveconsole"><strong>saveConsole</strong></a></li>
<li><a class="reference internal" href="#clearconsole"><strong>clearConsole</strong></a></li>
<li><a class="reference internal" href="#writestatusline"><strong>writeStatusLine</strong></a></li>
<li><a class="reference internal" href="#notdone"><strong>notdone</strong></a></li>
<li><a class="reference internal" href="#showtextbox"><strong>showTextBox</strong></a></li>
<li><a class="reference internal" href="#mainloop"><strong>mainloop</strong></a></li>
<li><a class="reference internal" href="#class-parameters-init-constructor-and-adding-parameters"><strong>class Parameters, __init__ constructor and adding parameters</strong></a></li>
<li><a class="reference internal" href="#show"><strong>show</strong></a></li>
</ul>
</li>
<li><a class="reference internal" href="#miscellaneous-simgui-capabilities">Miscellaneous SimGUI capabilities</a><ul>
<li><a class="reference internal" href="#source-code-listing"><strong>Source code listing</strong></a></li>
<li><a class="reference internal" href="#automatic-display-of-monitor-instances"><strong>Automatic display of Monitor instances</strong></a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../PlotManual/ManualPlotting.html"
                        title="previous chapter">SimPlot Manual</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../../SimulationGUIDebug.html"
                        title="next chapter">Visualize model events and states using <strong>SimulationGUIDebug</strong></a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/Manuals/GUIManual/SimGUImanual.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../SimulationGUIDebug.html" title="Visualize model events and states using SimulationGUIDebug"
             >next</a> |</li>
        <li class="right" >
          <a href="../PlotManual/ManualPlotting.html" title="SimPlot Manual"
             >previous</a> |</li>
        <li><a href="../../index.html">SimPy 2.3.1 documentation</a> &raquo;</li>
          <li><a href="../../SimPy_Tools.html" >SimPy Tools</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2002-2011, Klaus Müller, Tony Vignaux, Ontje Lünsdorf, Stefan Scherfke.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>