3. Basic Window¶
The text interface works, but it is very limited and outdated.
Therefore, now that the logic behind the show works, let’s create a user interface and improve this text one.
- Let’s start with a basic interface, again using the
brython
module. We will use some tools or widgets that are found in Brython.
These tools are already implemented.
They allow the creation of dialogs or small windows to interact with the user.
- Let’s start with a basic interface, again using the
3.1. Window with Brython¶
You may have noticed that in the basic window the buttons did nothing.
It is necessary to link an event to each button.
This is called event-driven programming.
We need to wait for user actions.
3.2. Capturing an Event¶
To capture an event from a button, it is necessary to create a function.
In the function, all the logic that is wanted for the button will be found.
We will create a new window with a button and we will capture or link an event.
We will show a message on the screen every time the user presses the button.
Perfect, now you know how to capture events.
- You can capture events using the
.bind()
function specifying the event or using a@bind
instruction, also called decorator. This instruction is written on a line previous to the button handling function.
- You can capture events using the
Knowing this logic we can finish the Zombie Question Show.
Remember the reproduction of sounds and the logic of the different options.