Skip to content

Manipulate glfw windows from python when using hello-imgui #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Aman-Anas opened this issue Feb 28, 2025 · 3 comments
Open

Manipulate glfw windows from python when using hello-imgui #322

Aman-Anas opened this issue Feb 28, 2025 · 3 comments
Labels
faq A frequent issue, remaining opened to facilitate discoverability

Comments

@Aman-Anas
Copy link
Contributor

Aman-Anas commented Feb 28, 2025

I am using the python bindings with hello_imgui, and trying out the borderless window feature. I was wondering if it is possible to maximize the window (like when using WindowSizeState.maximized on startup) during runtime.

This would allow me to add a maximize button to the menu bar. Minimize functionality would also be great, if it's possible.

(My use case is that I need to display a prompt if the user tries to close the application, and using borderless window gives me control over this. Plus it looks great :D)

@pthom pthom changed the title Maximizing and/or resizing windows at runtime Manipulate glfw windows from python when using hello-imgui Mar 18, 2025
@pthom
Copy link
Owner

pthom commented Mar 18, 2025

Try this:

"""Demonstrates how to manipulate the glfw window created by HelloImGui.

 glfw_utils.glfw_window_hello_imgui is a function that returns the main glfw window used by HelloImGui
"""

from imgui_bundle import hello_imgui, imgui, glfw_utils
import glfw


def gui():
    imgui.text("Hello")
    if imgui.button("maximize window"):
        win = glfw_utils.glfw_window_hello_imgui()  # get the main glfw window used by HelloImGui
        glfw.maximize_window(win)


glfw.init()  # needed by glfw_utils.glfw_window_hello_imgui
hello_imgui.run(gui)

@pthom pthom added the faq A frequent issue, remaining opened to facilitate discoverability label Mar 18, 2025
@Aman-Anas
Copy link
Contributor Author

Thanks, having access to the glfw window handle solves pretty much all of my problems. :)

@pthom
Copy link
Owner

pthom commented Mar 19, 2025

Reopening, as this is a FAQ issue.

@pthom pthom reopened this Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
faq A frequent issue, remaining opened to facilitate discoverability
Projects
None yet
Development

No branches or pull requests

2 participants