Help!

Help! I'm lost!

This page will assist you if you are having difficulty with your Python code. You might be new to Python, or something might just not be going the way you want it to. This page is separate from the troubleshooting guide, which is designed to fix problems inside GUI Pie. This page instead goes into more depth as for how to use GUI Pie with Python. If this page isn't applicable to you, feel free to search through the troubleshooting page if it might be more relevant

Step 1: Installing Python

Navigate to https://www.python.org/downloads/ and download the most recent version of Python for windows

Run the installer file you had downloaded. On the first screen of the installer file, check the box saying "Add Python to PATH". Follow the rest of the instructions on the screen to install Python

Then, open the command prompt (this can be accessed by searching via windows search "cmd" or "command prompt"). Run the following command : pip install pillow

Python should be installed!

Step 2: Using Python

There are two main segments to this - editing your Python script, and running Python. Python should install a text editor named "IDLE", which should appear in your list of applications, or via windows search. If it doesn't appear, try searching your C: drive for 'IDLE', or idle.bat. The advantage of using IDLE is that it both supports editing scripts and running scripts. There are also numerous text editors that can do this too, often with better features than IDLE. Feel free to use them. But, because it comes installed with Python, it will be used as an example. To edit a script in IDLE, either right click on an existing .py file, select 'open with', and select IDLE. You should be able to edit that script in your IDLE window. Else, you can, inside IDLE, select from the top: File -> New and create a new file. From that, you should be able to edit your new file. To run your file, press F5 or select from the top Run -> Run Module.

If you can't get IDLE working, or don't want to use it, the principles remain the same. You can edit your Python file however you want - you can even open it in notepad as a standard text editor and create your script there. To run any Python script without IDLE, you can right click on the file, select open with, and open it with Python. This should run your script.

Step 3: Using GUI Pie with Python

GUI Pie will generate a Python file containing your GUI. However, this is not your main Python file. Rather, you will import it into another script, known as your parent script. If you only had one file, every time you generated you GUI code, your existing code would be overwritten. To prevent this, using two files instead keeps your code safe, while making it hassle free to update your GUI.

Create a new script (see the above section) and name it main.py (or any other name. Main will be used as an example henceforth). In GUI Pie, when first creating your GUI, provide the parent script name in the field "parent script". Ensure that when you select your export location for your Python file, it is in the same folder as your main file.

Design your GUI. See the manual for how to do this.

Once designed, your GUI will export automatically. You can manually export it too by clicking on the 'convert' button in the ribbon.

To implement this window, open your main file in IDLE, or any other text editor, and add in the following lines as instructed below. When using GUI Pie, all your work will be done in your main file. You won't even need to open your GUI file!

Import: Every GUI file you import needs an import statement at the top of your Python file.

from <gui name> import <gui name>

For a GUI file named gui, this would look like from gui import gui

One of these is needed for every GUI file. If you have multiple screens, you will have multiple of these

Run: For the main window only, write the following to launch the screen. The run statement must be the final line of the file.

<gui name>.run()

For a GUI file named gui, this would look like gui.run()

For a GUI called 'gui', the code will look like the following:

from gui import gui

gui.run()

This should run your screen! Of course, if you have any interactive elements, you will need to add in additional code to run this. Follow this link here to the manual, where you will find all necessary code to interact with your widgets. Mostly, this will just look like reading or writing to a widget, both of which will only take a single line, and are written out for you in the manual.