-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
615 lines (530 loc) · 21.1 KB
/
index.html
File metadata and controls
615 lines (530 loc) · 21.1 KB
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
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="The easiest way to build tkinter GUIs in Python.">
<meta name="author" content="Richard Jarvis">
<link rel="canonical" href="http://appjar.info/">
<link rel="shortcut icon" href="img/favicon.ico">
<title>appJar</title>
<link href="css/bootstrap-custom.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/base.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
<link href="extra.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="js/jquery-1.10.2.min.js" defer></script>
<script src="js/bootstrap-3.0.3.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-79206647-1', 'appjar.info');
ga('send', 'pageview');
</script>
<meta name="keywords" content="Python, GUI, widgets, tkinter, appJar, label, button">
<meta name="title" content="Python library for building GUIs, using tkinter toolkit">
</head>
<body class="homepage">
<div class="corner-ribbon">
<a href="https://github.com/jarvisteach/appJar/blob/appJar/releases/appJar.zip?raw=true">Version 0.94 out now!</a>
</div>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=".">appJar</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Fillings <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="#">Widgets</a>
<ul class="dropdown-menu">
<li >
<a href="outputWidgets/">Output Widgets</a>
</li>
<li >
<a href="inputWidgets/">Input Widgets</a>
</li>
<li >
<a href="pythonImages/">Images</a>
</li>
<li >
<a href="pythonWidgetGrouping/">Containers</a>
</li>
<li >
<a href="pythonDevWidgets/">Beta Widgets</a>
</li>
<li >
<a href="simpleAppJar/">(v1.0 Naming)</a>
</li>
</ul>
</li>
<li >
<a href="pythonBars/">Bars</a>
</li>
<li >
<a href="pythonDialogs/">Pop-ups</a>
</li>
<li >
<a href="pythonSound/">Sounds</a>
</li>
<li >
<a href="pythonWidgetGrouping/">Grouping Widgets</a>
</li>
<li >
<a href="pythonSubWindows/">Multiple Windows</a>
</li>
<li >
<a href="multiplePages/">Multiple Pages</a>
</li>
<li >
<a href="splash/">Splashscreen</a>
</li>
<li >
<a href="specialCharacters/">Special Characters</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Configuration <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="pythonGuiOptions/">GUI Options</a>
</li>
<li class="dropdown-submenu">
<a href="#">Widgets</a>
<ul class="dropdown-menu">
<li >
<a href="pythonWidgetLayout/">Layout</a>
</li>
<li >
<a href="pythonWidgetOptions/">Configuration</a>
</li>
<li >
<a href="pythonContextManager/">The power of WITH</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#">Events</a>
<ul class="dropdown-menu">
<li >
<a href="pythonEvents/">Events</a>
</li>
<li >
<a href="pythonLoopsAndSleeps/">Loops & Sleeps</a>
</li>
<li >
<a href="pythonThreads/">Threads</a>
</li>
<li >
<a href="pythonDnD/">Drag'n Drop</a>
</li>
</ul>
</li>
<li >
<a href="pythonInternationalisation/">Internationalisation</a>
</li>
<li >
<a href="pythonSettings/">Saving Settings</a>
</li>
<li >
<a href="pythonLogging/">Logging</a>
</li>
<li >
<a href="pythonCommandLine/">Command Line Arguments</a>
</li>
<li >
<a href="pythonTtk/">ttk (BETA)</a>
</li>
<li >
<a href="clipboard/">Clipboard</a>
</li>
<li >
<a href="simpleProperties/">(v1.0 Properties)</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Help <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="guidance/">Guidance</a>
</li>
<li class="dropdown-submenu">
<a href="#">Examples</a>
<ul class="dropdown-menu">
<li >
<a href="examples/minecraft/">Raspberry Pi Minecraft</a>
</li>
<li >
<a href="examples/simple/">Simple Layout</a>
</li>
<li >
<a href="examples/stylesheets/">Stylesheets</a>
</li>
<li >
<a href="examples/kanban/">Kanban/To Do</a>
</li>
</ul>
</li>
<li >
<a href="Install/">Installation</a>
</li>
<li >
<a href="packaging/">Packaging</a>
</li>
<li >
<a href="License/">License</a>
</li>
<li >
<a href="Support/">Support</a>
</li>
<li >
<a href="appJarLimitations/">Limitations</a>
</li>
<li >
<a href="Thanks/">Acknowledgements</a>
</li>
<li >
<a href="advertising/">Advertising</a>
</li>
<li >
<a href="contributing/">Contributing</a>
</li>
<li >
<a href="whatsNew/">Change-Log</a>
</li>
<li >
<a href="oldDocs/">Old Documentation</a>
</li>
<li class="dropdown-submenu">
<a href="#">Other Help</a>
<ul class="dropdown-menu">
<li >
<a href="pythonBasics/">Python</a>
</li>
<li >
<a href="algorithms/">Algorithms</a>
</li>
<li >
<a href="gitGuide/">Git & PyPi</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a href="/pythonLessons" target="_blank">
<i class="fa fa-mortar-board"></i> Learn
</a>
</li>
<li class="nav-item">
<a href="https://www.youtube.com/channel/UCe_fC78lGgA-EHyK9nZXNVA" target="_blank">
<i class="fa fa-youtube"></i> Watch
</a>
</li>
<li class="nav-item">
<a href="https://github.com/jarvisteach/appJar/">
<i class="fa fa-github"></i> GitHub
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#appjar">appJar</a></li>
<li><a href="#hello-appjar">Hello appJar</a></li>
<li><a href="#interactivity">Interactivity</a></li>
<li><a href="#appearance-counts">Appearance counts</a></li>
<li><a href="#make-your-own">Make your own</a></li>
<li><a href="#full-code-listing">Full code-listing</a></li>
<li><a href="#upcoming-in-v10">Upcoming in v1.0</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 id="appjar">appJar</h1>
<p><em>The easiest way to create GUIs in Python.</em> </p>
<hr />
<p>Written by a teacher, in the classroom, for students. </p>
<p><strong>appJar</strong> is designed to run on as many versions of <a href="https://www.python.org/downloads/">Python</a> as possible - so it should work in your school. </p>
<p>There are no other dependencies - simply <a href="https://github.com/jarvisteach/appJar/blob/appJar/releases/appJar.zip?raw=true">download</a>, unzip, and put it in your code folder.<br />
Check out the <a href="/Install">installation</a> instructions for other ways to get <strong>appJar</strong> working. </p>
<h3 id="hello-appjar">Hello appJar</h3>
<hr />
<p><a href="https://en.wikipedia.org/wiki/Graphical_user_interface">GUIs</a> in <strong>appJar</strong> require three steps. </p>
<ul>
<li>First, import the library & create a GUI variable.<br />
(from now on, we do everything to the GUI variable) </li>
</ul>
<pre><code class="python"># import the library
from appJar import gui
# create a GUI variable called app
app = gui()
</code></pre>
<ul>
<li>Then, using the gui variable, add and configure an output widget:<br />
(if you've tried <a href="https://docs.python.org/3.6/library/turtle.html">turtle</a> this will all look very familiar) </li>
</ul>
<pre><code class="python"># add & configure widgets - widgets get a name, to help referencing them later
app.addLabel("title", "Welcome to appJar")
app.setLabelBg("title", "red")
</code></pre>
<ul>
<li>Finally, start the GUI:<br />
(<strong>NB.</strong> don't put any code after this line) </li>
</ul>
<pre><code class="python"># start the GUI
app.go()
</code></pre>
<ul>
<li>
<p>And, that's it: </p>
<p><img alt="simpleApp" src="img/simpleApp.png" /> </p>
</li>
</ul>
<h3 id="interactivity">Interactivity</h3>
<hr />
<p>Of course, the whole point of making a GUI, is to be interactive - this requires <strong>events</strong>. </p>
<p>The idea behind <a href="https://en.wikipedia.org/wiki/Event-driven_programming">event-driven programming</a> is that each time the user clicks or types (an event) the GUI should respond. </p>
<ul>
<li>So, we add some input widgets (<a href="/inputWidgets/#entry">Entry Boxes</a>), for the user to type in:</li>
</ul>
<pre><code class="python">app.addLabelEntry("Username")
app.addLabelSecretEntry("Password")
</code></pre>
<ul>
<li>Then, we need a <strong>function</strong> - a block of code to call, when an event happens: </li>
</ul>
<pre><code class="python">def press(button):
if button == "Cancel":
app.stop()
else:
usr = app.getEntry("Username")
pwd = app.getEntry("Password")
print("User:", usr, "Pass:", pwd)
</code></pre>
<ul>
<li>Finally, a <a href="/inputWidgets/#button">button</a> to create the event: </li>
</ul>
<pre><code class="python"># link the buttons to the function called press
app.addButtons(["Submit", "Cancel"], press)
</code></pre>
<ul>
<li>
<p>We now have an interactive GUI: </p>
<p><img alt="testLog" src="img/testLog.png" /></p>
</li>
</ul>
<p>When the user presses a button, the <code>press</code> function is called, passing the name of the button as a parameter. </p>
<h3 id="appearance-counts">Appearance counts</h3>
<hr />
<p>We also want to change the way the <a href="/pythonGuiOptions">GUI looks</a>: </p>
<ul>
<li>For starters, you can specify a name and size for your GUI, when you create it: </li>
</ul>
<pre><code class="python">app = gui("Login Window", "400x200")
</code></pre>
<ul>
<li>You can change the general appearance of the GUI: </li>
</ul>
<pre><code class="python">app.setBg("orange")
app.setFont(18)
</code></pre>
<ul>
<li>You can even specify where you want the cursor to be when the GUI starts: </li>
</ul>
<pre><code class="python">app.setFocus("Username")
</code></pre>
<ul>
<li>
<p>It now looks a bit better: </p>
<p><img alt="testLog" src="img/testLog2.png" /> </p>
<p>(<strong>NB.</strong> We also set the fg/bg colours on the label - see <a href="#full-code-listing">below</a>) </p>
</li>
</ul>
<h3 id="make-your-own">Make your own</h3>
<hr />
<p>And, that's all you need to know. Check out: </p>
<ul>
<li>All the different <a href="/inputWidgets">input widgets</a> & <a href="/outputWidgets">output widgets</a> available. </li>
<li>Our support for <a href="/pythonImages">images</a> and <a href="pythonSound">sound</a>. </li>
<li>How to include <a href="/pythonBars">toolbars, menubars & statusbars</a>. </li>
<li>How to create simple <a href="/pythonDialogs">pop-ups</a>. </li>
<li>How to use a <a href="/pythonWidgetLayout">grid layout</a>. </li>
<li>How to use <a href="/pythonWidgetGrouping">containers</a> for more advanced layouts. </li>
</ul>
<h3 id="full-code-listing">Full code-listing</h3>
<hr />
<p>Below is the full code-listing for the above GUI: </p>
<pre><code class="python"># import the library
from appJar import gui
# handle button events
def press(button):
if button == "Cancel":
app.stop()
else:
usr = app.getEntry("Username")
pwd = app.getEntry("Password")
print("User:", usr, "Pass:", pwd)
# create a GUI variable called app
app = gui("Login Window", "400x200")
app.setBg("orange")
app.setFont(18)
# add & configure widgets - widgets get a name, to help referencing them later
app.addLabel("title", "Welcome to appJar")
app.setLabelBg("title", "blue")
app.setLabelFg("title", "orange")
app.addLabelEntry("Username")
app.addLabelSecretEntry("Password")
# link the buttons to the function called press
app.addButtons(["Submit", "Cancel"], press)
app.setFocus("Username")
# start the GUI
app.go()
</code></pre>
<h3 id="upcoming-in-v10">Upcoming in v1.0</h3>
<hr />
<p>In the upcoming 1.0 release, we're formally introducing a new set of options for buiding your GUI. </p>
<p>These are targetted at our more experienced users: </p>
<ul>
<li><a href="/pythonContextManager">Context Managers</a> allow you to create the GUI and any containers, in a visibly more understandable way. </li>
<li>New <a href="/simpleAppJar">functions</a> that allow you to add/get/set widgets all with the same command, including passing configuration paramters. </li>
<li>New <a href="/simpleProperties">properties</a> for configuring the GUI. </li>
</ul>
<p>Most of these are already live, and can be used, reducing the above GUI code to: </p>
<pre><code class="python">from appJar import gui
def press():
print("User:", app.entry("Username"), "Pass:", app.entry("Password"))
with gui("Login Window", "400x200", bg='orange', font={'size':18}) as app:
app.label("Welcome to appJar", bg='blue', fg='orange')
app.entry("Username", label=True, focus=True)
app.entry("Password", label=True, secret=True)
app.buttons(["Submit", "Cancel"], [press, app.stop])
</code></pre></div>
</div>
<footer class="col-md-12">
<!-- Google Ads -->
<hr>
<div style='text-align: center;'>
<em>Advertisement <sup><a href="/advertising">why?</a></sup></em>
<br>
<br>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Footer -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-6185596049817878"
data-ad-slot="2795191172"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>
<hr>
<p><p><a href='/License'>© Richard Jarvis, 2015-2019</a></p></p>
</footer>
<script>
var base_url = ".",
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
</script>
<script src="js/base.js" defer></script>
<script src="search/main.js" defer></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="Keyboard Shortcuts Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Keyboard Shortcuts</h4>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th style="width: 20%;">Keys</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="help shortcut"><kbd>?</kbd></td>
<td>Open this help</td>
</tr>
<tr>
<td class="next shortcut"><kbd>n</kbd></td>
<td>Next page</td>
</tr>
<tr>
<td class="prev shortcut"><kbd>p</kbd></td>
<td>Previous page</td>
</tr>
<tr>
<td class="search shortcut"><kbd>s</kbd></td>
<td>Search</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
<!--
MkDocs version : 1.0.4
Build Date UTC : 2019-05-25 21:21:37
-->