Skip to content

6. Tutorial ‐ Hello World (Preparing UI for interaction)

Rigved Maanas edited this page May 5, 2024 · 1 revision

In this tutorial you will learn how to prepare the UI for interaction

Step - 3 | UI Preperation

Since we need the button in the UI to trigger a command on click, we need to change it's name to a more suitable one.

  • Click on the added button in the viewport.
  • Change the option ID to click_me_button in the Geometry & Content Menu from the Properties Panel

Step - 2 | Export Code

  • Click on Export Code button from the tool bar.
  • In the popup window you can preview the generated code.
  • Choose OOP or No OOP in the left hand side of the popup window. (For this tutorial choose No OOP but we recommend using OOP)
  • Click on the button Export Code in the popup window.
  • Name your python file in the popup window and give it a destination.

Step - 3 | Access the button

You can now access your button through the variable click_me_button

  • Open your python file in your favourite editor
  • In order to print Hello World on click, add the following code before root.mainloop().
click_me_button.configure(command=lambda: print("Hello World"))

Well Done 👍 You have successfully completed the tutorial. We wish you to create better UI's from now on ⭐