Skip to content

Commit

Permalink
Merge pull request #386 from lawsie/add-book
Browse files Browse the repository at this point in the history
Add info about book to docs
  • Loading branch information
Martin O'Hanlon authored Oct 28, 2020
2 parents 965cc55 + a7fc75b commit 626789d
Show file tree
Hide file tree
Showing 48 changed files with 1,073 additions and 528 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# guizero

[guizero](https://lawsie.github.io/guizero) is a Python 3 library for creating simple GUIs.
[guizero](https://lawsie.github.io/guizero) is a Python 3 library for creating simple GUIs.

It is designed to allow new learners to quickly and easily create GUIs for their programs.

Expand Down Expand Up @@ -50,3 +50,7 @@ Contributions are very welcome - please see [lawsie.github.io/guizero/contributi
## Issues

All issues should be raised on [github.com/lawsie/guizero/issues](https://github.com/lawsie/guizero/issues)

## Book

The authors of guizero have written a book for beginners which you can [buy in print](https://store.rpipress.cc/products/create-graphical-user-interfaces-with-python) or download as a [free PDF](https://magpi.raspberrypi.org/books/create-guis).
9 changes: 9 additions & 0 deletions docs-src/docs/book.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Book

### Create Graphical User Interfaces with Python

The authors of guizero have written a book containing ten fun guizero projects. The book starts from a very basic GUI and shows you how to create gradually more complex GUI programs including a painting program and a stop-motion animation creator.

You can [buy the book in print](https://store.rpipress.cc/products/create-graphical-user-interfaces-with-python) or download it as a [free PDF](https://magpi.raspberrypi.org/books/create-guis).

![guizero book](images/guizero-book.jpg)
10 changes: 5 additions & 5 deletions docs-src/docs/contributing.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Contributing
# Contributing

Contibutions are very welcome; be that changes, bug fixing, issue resolution or support.
Contributions are very welcome; be that changes, bug fixing, issue resolution or support.

## Issues

All issues should be raise on [github.com/lawsie/guizero/issues](https://github.com/lawsie/guizero/issues)
All issues should be raised on [github.com/lawsie/guizero/issues](https://github.com/lawsie/guizero/issues)

## Code

When providing code changes please:

- use the `dev` branch as the base for all changes
- create a single pull requests for each fix / addition
- create a single pull request for each fix / addition
- follow the existing coding style
- provide documentation for all changes as markdown in `/docs-src`
- provide tests for all changes in `/test`
- provide tests for all changes in `/test`
8 changes: 4 additions & 4 deletions docs-src/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ To run the automated tests:

```
cd guizero\test
pytest -v
pytest -v
```

If running the tests inside a virtual environment you will need to install pytest in that virtual enviroment.
If running the tests inside a virtual environment you will need to install pytest in that virtual environment.

```
pip install pytest
```

_Note - tkinter can error when running the tests usually when the interpreter doesn't start properly, it doesnt seem to like being initialised and destroyed hundreds of times, I suspect a file locking issue as you dont see the problem on Linux. So sometimes you might get a test fail with an error like `This probably means that tk wasn't installed properly.`. Just re-run the last failed errors! `pytest --lf -v`_
_Note - tkinter can error when running the tests usually when the interpreter doesn't start properly, it doesn't seem to like being initialised and destroyed hundreds of times, I suspect a file locking issue as you don't see the problem on Linux. So sometimes you might get a test fail with an error like `This probably means that tk wasn't installed properly.`. Just re-run the last failed errors! `pytest --lf -v`_

## Documents

Expand All @@ -72,4 +72,4 @@ cd guizero\docs-src
mkdocs serve
```

Open [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
Open [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
Binary file added docs-src/docs/images/guizero-book.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs-src/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nav:
- Events: events.md
- Using tkinter: usingtk.md
- Getting help: gettinghelp.md
- Recipes: recipes.md
- Widgets:
- Overview: widgetoverview.md
- App: app.md
Expand All @@ -36,6 +35,8 @@ nav:
- TextBox: textbox.md
- Waffle: waffle.md
- Window: window.md
- Recipes: recipes.md
- Book : book.md
- Contributing:
- Notes: contributing.md
- Developing: development.md
Expand Down
21 changes: 13 additions & 8 deletions docs/about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Widgets <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -274,6 +268,18 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li >
<a href="../book/">Book</a>
</li>



<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contributing <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -350,7 +356,7 @@ <h3 id="what-is-guizero">What is guizero?</h3>
<p>guizero is a Python 3 library for creating simple GUIs. </p>
<p>It is designed to allow new learners to quickly and easily create GUIs for their programs.</p>
<p><img alt="So have a go with guizero and see what you can create" src="../images/have-a-go.png" /></p>
<pre><code class="python">from guizero import App, Text, PushButton
<pre><code class="language-python">from guizero import App, Text, PushButton

app = App(title=&quot;guizero&quot;)

Expand All @@ -359,7 +365,6 @@ <h3 id="what-is-guizero">What is guizero?</h3>

app.display()
</code></pre>

<h3 id="aims">Aims</h3>
<p>The aim of guizero is to make the process of creating simple GUIs quick, accessible and understandable for new learners.</p>
<ul>
Expand Down
53 changes: 24 additions & 29 deletions docs/alerts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Widgets <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -274,6 +268,18 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li >
<a href="../book/">Book</a>
</li>



<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contributing <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -350,14 +356,12 @@ <h1 id="pop-ups">Pop-ups</h1>
<p><img alt="Alert popup" src="../images/alert_info_windows.png" /></p>
<h3 id="using-pop-ups">Using pop-ups</h3>
<p>Pop-ups can be called from an <code>App</code> or <code>Window</code> object, for example:</p>
<pre><code class="python">app.info(&quot;info&quot;, &quot;this is a guizero app&quot;)
<pre><code class="language-python">app.info(&quot;info&quot;, &quot;this is a guizero app&quot;)
</code></pre>

<p>Pop-ups can also be imported individually at the start of your program, for example:</p>
<pre><code class="python">from guizero import info
<pre><code class="language-python">from guizero import info
info(&quot;info&quot;, &quot;this is a guizero app&quot;)
</code></pre>

<h3 id="purpose">Purpose</h3>
<p>These functions pop up a box on the screen that displays a message or asks a question. The functions available are:</p>
<ul>
Expand All @@ -373,12 +377,11 @@ <h3 id="purpose">Purpose</h3>
<h3 id="examples">Examples</h3>
<p><strong>Warning box</strong></p>
<p>This will pop up a warning box with the title <code>"Uh oh!"</code> and the message <code>"You are almost out of biscuits!"</code>.</p>
<pre><code class="python">from guizero import App
<pre><code class="language-python">from guizero import App
app = App(title=&quot;Biscuit monitor&quot;)
app.warn(&quot;Uh oh!&quot;, &quot;You are almost out of biscuits!&quot;)
app.display()
</code></pre>

<p>On Windows, the box looks like this:</p>
<p><img alt="Warning popup" src="../images/warning_windows.png" /></p>
<p>The <code>info</code> and <code>error</code> boxes work in exactly the same way but will display different icons.</p>
Expand All @@ -389,7 +392,7 @@ <h3 id="examples">Examples</h3>
<li>If <code>No</code> was pressed, return <code>False</code></li>
</ul>
<p>You can store this value in a variable and test it:</p>
<pre><code class="python">from guizero import App
<pre><code class="language-python">from guizero import App
app = App(title=&quot;Snowman&quot;)
build_a_snowman = app.yesno(&quot;A question...&quot;, &quot;Do you want to build a snowman?&quot;)
if build_a_snowman == True:
Expand All @@ -398,7 +401,6 @@ <h3 id="examples">Examples</h3>
app.error(&quot;Snowman&quot;, &quot;Okay bye...&quot;)
app.display()
</code></pre>

<p>This code will first display the yes/no box</p>
<p><img alt="Yes No popup" src="../images/yesno_windows.png" /></p>
<p>If <code>Yes</code> is pressed, an information box will be displayed:</p>
Expand All @@ -407,12 +409,11 @@ <h3 id="examples">Examples</h3>
<p><img alt="Info popup" src="../images/error_windows.png" /></p>
<p><strong>Example: Using an alert as a callback</strong></p>
<p>You can also use these functions in a <em>callback</em> (when you have to provide a function for another widget to call). Here is an example with a <code>PushButton</code> which pops up an <code>info</code> box when it is pressed.</p>
<pre><code class="python">from guizero import App, PushButton, info
<pre><code class="language-python">from guizero import App, PushButton, info
app = App()
button = PushButton(app, command=app.info, args=[&quot;Info&quot;, &quot;You pressed the button&quot;])
app.display()
</code></pre>

<p>The arguments provided to the <code>PushButton</code> are:</p>
<ul>
<li>Where the button should be created (within the <code>app</code>)</li>
Expand All @@ -421,7 +422,7 @@ <h3 id="examples">Examples</h3>
</ul>
<p><strong>Example: Do you really want to close?</strong></p>
<p>You can use a <code>yesno</code> box to check whether someone really wants to exit your app. If they click yes, the app is closed, if not, nothing happens and they can continue with what they were doing.</p>
<pre><code class="python">from guizero import App, Text
<pre><code class="language-python">from guizero import App, Text

# Ask the user if they really want to close the window
def do_this_when_closed():
Expand All @@ -438,10 +439,9 @@ <h3 id="examples">Examples</h3>
app.display()

</code></pre>

<p><strong>Example: Asking a question</strong></p>
<p>You can use a <code>question</code> pop-up to get information from the user. In this example the user is asked to enter their name when a button is pressed.</p>
<pre><code class="python">from guizero import App, PushButton, Text
<pre><code class="language-python">from guizero import App, PushButton, Text

def button_pressed():
name = app.question(&quot;Hello&quot;, &quot;What's your name?&quot;)
Expand All @@ -455,11 +455,10 @@ <h3 id="examples">Examples</h3>
hello = Text(app)
app.display()
</code></pre>

<p><img alt="question popu" src="../images/question_windows.png" /></p>
<p><strong> Example: Get a file name</strong></p>
<p>Ask the user to select a file using the <code>select_file</code> pop-up.</p>
<pre><code class="python">from guizero import App, PushButton, Text
<pre><code class="language-python">from guizero import App, PushButton, Text

def get_file():
file_name.value = app.select_file()
Expand All @@ -471,20 +470,17 @@ <h3 id="examples">Examples</h3>

app.display()
</code></pre>

<p><img alt="select file popup" src="../images/select_file_windows.png" /></p>
<p>You can change the file type filter by providing a list of type descriptions and extensions as the <code>filetypes</code> parameter e.g. </p>
<pre><code class="python">file_name.value = app.select_file(filetypes=[[&quot;All files&quot;, &quot;*.*&quot;], [&quot;Text documents&quot;, &quot;*.txt&quot;]])
<pre><code class="language-python">file_name.value = app.select_file(filetypes=[[&quot;All files&quot;, &quot;*.*&quot;], [&quot;Text documents&quot;, &quot;*.txt&quot;]])
</code></pre>

<p>The default is to show an <em>Open</em> button, this can be changed to a <em>Save</em> button by setting the <code>save</code> parameter to <code>True</code> e.g.</p>
<pre><code class="python">file_name.value = app.select_file(save=True)
<pre><code class="language-python">file_name.value = app.select_file(save=True)
</code></pre>

<p><img alt="select save file popup" src="../images/select_file_save_windows.png" /></p>
<p><strong> Example: Get a folder name</strong></p>
<p>Select a folder using the <code>select_folder</code> pop-up.</p>
<pre><code class="python">from guizero import App, PushButton, Text
<pre><code class="language-python">from guizero import App, PushButton, Text

def get_folder():
path.value = app.select_folder()
Expand All @@ -496,10 +492,9 @@ <h3 id="examples">Examples</h3>

app.display()
</code></pre>

<p><img alt="select folder popup" src="../images/select_file_windows.png" /></p>
<p>You can set the initial folder by passing a path to the <code>folder</code> parameter </p>
<pre><code class="python">file_name.value = app.select_file(folder=&quot;c:\users\lawsie&quot;)
<pre><code class="language-python">file_name.value = app.select_file(folder=&quot;c:\users\lawsie&quot;)
</code></pre></div>


Expand Down
30 changes: 16 additions & 14 deletions docs/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Widgets <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -274,6 +268,18 @@



<li >
<a href="../recipes/">Recipes</a>
</li>



<li >
<a href="../book/">Book</a>
</li>



<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contributing <b class="caret"></b></a>
<ul class="dropdown-menu">
Expand Down Expand Up @@ -353,7 +359,7 @@

<h1 id="app">App</h1>
<p>(Contains a <code>tkinter.Tk</code> object)</p>
<pre><code class="python">__init__(
<pre><code class="language-python">__init__(
self,
title=&quot;guizero&quot;,
width=500,
Expand All @@ -363,17 +369,15 @@ <h1 id="app">App</h1>
bg=None,
visible=True)
</code></pre>

<h3 id="what-is-it">What is it?</h3>
<p>The <code>App</code> object is the basis of all GUIs created using guizero. It is the main window which contains all of the other widgets.</p>
<p><img alt="App" src="../images/app.png" /></p>
<h3 id="how-do-i-make-one">How do I make one?</h3>
<p>Create an <code>App</code> object like this:</p>
<pre><code class="python">from guizero import App
<pre><code class="language-python">from guizero import App
app = App()
app.display()
</code></pre>

<h3 id="starting-parameters">Starting parameters</h3>
<p>When you create an <code>App</code> object you can specify any of the following parameters, all of which are optional. Specify parameters in the brackets like this: <code>app = App(bg="red", height=200)</code></p>
<table>
Expand Down Expand Up @@ -662,19 +666,17 @@ <h3 id="examples">Examples</h3>
<p><strong>Creating an App object</strong></p>
<p>Create an <code>App</code> object by calling the <code>App()</code> constructor. You should give the object a name so you can refer to it later - in this case we have called it <code>app</code>. It is best to keep the name you give to your <code>App</code> object quite short, as you will have to use it to tell other widgets where they should be stored.</p>
<p>At the end of the program you <strong>MUST</strong> tell the app object to begin the display loop.</p>
<pre><code class="python">from guizero import App
<pre><code class="language-python">from guizero import App
app = App(title=&quot;My app&quot;, height=300, width=200)
app.display()
</code></pre>

<p><strong>Changing the title</strong></p>
<p>You can change the title of the app object once it has been created like this:</p>
<pre><code class="python">from guizero import App
<pre><code class="language-python">from guizero import App
app = App(title=&quot;My app&quot;, height=300, width=200)
app.title = &quot;A different title&quot;
app.display()
</code></pre>

<p>This will display the app with the updated title:</p>
<p><img alt="App title" src="../images/app_set_title.png" /></p></div>

Expand Down
Loading

0 comments on commit 626789d

Please sign in to comment.