Skip to content

The Main Window

In GooeyPie, the Main Window is the heart of your application. When you create your app using app = gp.GooeyPieApp('My App'), you aren’t just making a window, you’re setting up the entire engine that keeps your program running.

Because the app object represents both the window and the application itself, this is where you’ll control things like the title, the size of the screen, and even how the program shuts down.

Think of these as the “look and feel” variables for your app. You can change these at any time to update your window’s appearance.

After you have created your app with app = gp.GooeyPieApp('My App'), you can access the following properties to customize your main window:

PropertyTypeDescription
.themestringThe color theme of the app, which can be set to "light", "dark", or "system" (which follows the system theme). Default is "system".
.titlestringThe title of your app, which appears in the title bar of the window.
.widthintegerThe width of the window in pixels.
.heightintegerThe height of the window in pixels.
.resizable_horizontalbooleanWhether the user can make the window wider or narrower. Default is True.
.resizable_verticalbooleanWhether the user can make the window taller or shorter. Default is True.
app.set_icon(icon_file)

Sets a custom icon for your app’s window, where icon_file is the path and filename of the image to be displayed, relative to the current file.

Sometimes you need to tell the window to do something specific, rather than just changing a setting.


app.set_size(width, height)

A quick way to change the window’s dimensions all at once.


app.copy_to_clipboard(text)

Takes whatever text you give it and saves it to the user’s system clipboard (so they can paste it elsewhere!).

Just like widgets have events (like clicking a button), the app itself has “life cycle” events.


app.on_load(my_load_function)

This tells the app to run the given function the moment the window appears on the screen.


app.on_quit(my_quit_function)

This is like a “safety check” before the app closes. The function you use must return True to let the app close, or False to keep it open. This is perfect for asking “Are you sure you want to exit?” or for checking if the user has unsaved work before they leave.


app.quit()

The standard way to close your app through code. It will still trigger your .on_quit function if you’ve set one.


app.force_quit()

Use this if you need to shut down immediately without asking any questions!

Usually, your app does things in response to user actions like clicking a button, but sometimes you want something to happen automatically after a certain amount of time has passed. That’s where timer methods come in!

Use a timeout when you want to wait a bit before doing something once.


timeout_id = app.set_timeout(time, my_function)

This will call my_function once after a time millisecond delay. The set_timeout method returns an id that you can use to cancel the timeout if needed.


app.clear_timeout(timeout_id)

This will cancel the timeout with the given timeout_id. If the function has already executed, this will have no effect.

Use an interval when you want to do something repeatedly at a regular time interval.

interval_id = app.set_interval(time, my_function)

This will call my_function repeatedly every time milliseconds. Like set_timeout, it returns an id that you can use to stop the interval.


app.clear_interval(interval_id)

This will cancel the interval with the given interval_id.

Don’t forget: no matter how many properties you set, your window won’t actually appear until you call:

app.run()