My menu

Hello There, PandaForum!

Ive got some problems regarding my Menu.
(local and global variables, too - but in context to the menu)

I want to make a Menu where you can either (Directbutton) press Start - Options - Credits (f.ex.) and then it should clear all buttons and the program will run in the subprogram

f.ex: def menu():
#style of menu with onscreentext and directbuttons and stuff

(sub-program) def Sound():
#style of Sound menu but without the menu´s onscreentext and directbuttons, options to change the sound
(button back to menu)…,command=menu)

so basically what im saying is:

Is there a function that deletes all objects or something?

thanks for your help :slight_smile:

if you’r working with DirectGUI elements you can simply do


in case you set up a DirectGui frame and reparented all your main-menu elements to it it will remove them all at once.

the other thing you can do is to simply hide() and show() your menu. which avoids the recreation every time you want to show it again.

ive started writing my gamelike menu :slight_smile: so u can grab code from here:

and if anyone want to join here is svn:

Hey EraseIt! That was really helpful! Thanks a lot!
I am ready with my menu so far. The only problem, I have is: how do I programm a button “Back” from the optionsMenu? I tried just to copy “command=parent.gotoMain” from the same button in the ingameMenu, but it doesn’t work. In the command line I get a message:
“(all display modules loaded.)
Traceback (most recent call last):
File “”, line 18, in
w = World()
File “”, line 9, in init
self.gui = UserInterface()
File “local directory\panda3dmenu\trunk\data\”, line 28, in init
File “local directory\panda3dmenu\trunk\data\gui\”, line 36, in
NameError: global name ‘parent’ is not defined”

I really tried what I could. So, I would be very grateful for your (or someone else’s) help. :slight_smile:

Hello Sharkz,

The main idea is to create multiple frames and switch between them.
To follow your exemple : “Options” -“Credits” will be parented to a frame called Father. Clicking on “Options” should hide Father and show your second frame, let’s say called, ChildOne with all your options and a Back Button.
Clicking on Back will hide frame ChildOne and show Father frame.

An other one is to use FSM which will do more or less what explained above but in a more robust way.
Reading this article will explain it better than I :

Im not sure if that helps, too but i posted a simple menu in

gimme few hours and i will make that adjustment:
its like closing current menu and showing parent

Well if you still have many other free hours after that, I’m having thousands of line codes to type :wink: LOL

ok made some changes… :slight_smile: u can checkout/download

but this isnt the final version, its just working copy :slight_smile:

i need to think over whole struct, so actually in future main menu and in game menu will be separated.

so ask if u need something :slight_smile:

Yes! The menu works fine now. :slight_smile: Thanks to all for your explanations and examples. Now I know what the idea behind this all is. Used EraseIt’s example, which is more than sufficient. Just need to optimize it a bit, because I won’t make a multiplayer or save/load functions. If I’ll have any other questions, I’ll ask here.

EraseIt big thanks one more time!