1
\$\begingroup\$

I would like to structure my gui into different panels. so to help keep my code managable i thought it might be a good idea to have a main panel. with its own manager and then a secondary panel with its own manager that gets drawn ontop of the main panel.

Ideally I would have a main screen with a couple of buttons on the left. In the centre of the main screen I can show different panels. (Think of a website with a navbar on the side)

This would make it easier to work on the individual panels and also allow me to place buttons on the panels relative to the panels they will appear on as opposed to having to place them relative to the main panel.

My problem now is that I can't seem to get the events from any of the secondary managers into pygame's event queue.

Is this at all possible? Do I need to show my not-working code?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

In the Pygame GUI UI Manager documentation, it states:

The UI Manager class helps keep track of all the moving parts in the pygame_gui system.

Before doing anything else with pygame_gui, create a UIManager and remember to update it every frame.

This seems to suggest that you can only have one UI Manager.

Instead, what I think you want is the UI Layers feature, which allows you to create multiple GUIs and layer them on top of each other. (Documentation) This is done through UIPanel elements.

From the UI Layers documentation:

UI Layers start at 0, which represents the lowest level, and progress upwards as they are needed. Things in higher layers will be drawn on top of things in lower layers if they overlap... HUDs may overlap UI elements that appear ‘in’ game worlds; such as monster health bars. For these occasions there is the UIPanel element which works as a container, much like a UI Window, except you specify what layer of the UI it will draw on (and thus what it will appear on top of).

\$\endgroup\$
2
  • \$\begingroup\$ when you say it like that this makes a lot of sense! Thanks! \$\endgroup\$ Nov 30, 2020 at 17:09
  • \$\begingroup\$ followup question: now I have created a gui panel i can't figure out how to draw anything in it. I can place buttons and other elements. but i cannot set a background let alone draw any of the oygame surfaces on it. \$\endgroup\$ Dec 5, 2020 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .