#5 Pages : Building Modern GUIs using Python | Full Course | 2025

THE SUMMARYAI-generated

Key Concepts

  • Pages: A feature in the platform that allows creating multiple screens or views within a single application.
  • Page Navigation: The process of moving between different pages within the application.
  • Event Handling: Responding to user interactions, such as button clicks, to trigger actions like page changes.
  • partial (from functools): A function that allows pre-filling some arguments of a function, creating a new callable.
  • UI Element: A component of the user interface, such as a button, image, or text.
  • Logic Properties: Settings associated with UI elements that define their behavior, such as the target page for navigation.

Pages Overview

The video introduces the concept of "pages" within the platform, which allows developers to create multi-screen applications. The presenter demonstrates how to create, add, and delete pages using the platform's interface. Each page can contain different UI elements, enabling the creation of distinct views within the application.

Manual Page Navigation via Code

The presenter initially demonstrates how to programmatically change pages using Python code.

  1. Attaching an Event: The presenter shows how to attach an event to a button on a specific page using UI.get("page_0").get("button_0").onclick.
  2. Defining a Callback Function: A function, change_page, is defined to handle the button click event. Initially, this function only prints "change page" to the console.
  3. Passing UI Elements to the Callback: To enable the change_page function to modify the UI (specifically, to change the current page), the presenter uses functools.partial. This allows passing the UI dictionary as an argument to the change_page function.
    • from functools import partial
    • partial(change_page, UI=UI)
  4. Changing the Current Page: Inside the change_page function, the pages.set_current_page(1) method is used to switch to page one.
  5. Example:
    from functools import partial
    
    def change_page(instance, UI):
        UI.pages.set_current_page(1)
    
    UI.get("page_0").get("button_0").onclick = partial(change_page, UI=UI)
    

Simplified Page Navigation via Logic Properties

The presenter then introduces a simpler, code-free method for page navigation using the "Logic Properties" of UI elements.

  1. Accessing Logic Properties: By selecting a UI element (e.g., a button) on a specific page, the presenter accesses its "Logic Properties" in the platform's interface.
  2. Setting the "Open Page" Property: The "Open Page" property is used to specify the target page that should be displayed when the UI element is clicked. For example, setting "Open Page" to "page 0" on a button on page one will navigate back to page zero when the button is clicked.
  3. Benefits: This method eliminates the need to write code for simple page navigation, making the development process faster and more intuitive.

Applying Page Navigation to Different UI Elements

The presenter demonstrates that the "Open Page" logic property is not limited to buttons. It can also be applied to:

  • Icons: Icons can be configured to act as navigation elements, similar to buttons.
  • Text: Text elements can be styled (e.g., underlined) and used as clickable links to navigate between pages.

Project Preview

The video concludes by previewing a future project that will integrate the "pages" feature with other elements like windows, buttons, setup configurations, and text. The goal is to create a reusable project template that developers can incorporate into their existing projects.

Conclusion

The video provides a comprehensive introduction to the "pages" feature, demonstrating both code-based and visual methods for creating multi-screen applications. The use of functools.partial for event handling and the "Logic Properties" for simplified navigation are key takeaways. The presenter emphasizes the flexibility of the platform, allowing developers to choose the approach that best suits their needs.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.