我在自己的模块中构建了多个菜单。menu.py 模块导入子菜单,然后创建一个显示子菜单的实例。
我的问题是从子菜单返回主菜单(menu.py)。这是主菜单代码。菜单.py
from gui import *
import wx
from tools import Tools
from vehicles import VehicleMainMenu
from ladders import LadderMainMenu
class TopMenu(MainMenu):
def __init__(self, parent):
MainMenu.__init__(self, parent)
def close_bigbutton_click(self, event):
exit(0)
def tools_button_click( self, event ):
self.GetParent() # This assigns parent frame to frame.
self.Close() # This then closes frame removing the main menu.
frame = Tools(None)
frame.Centre()
frame.Show()
def vehicle_button_click( self, event ):
self.GetParent() # This assigns parent frame to frame.
self.Close() # This then closes frame removing the main menu.
frame = VehicleMainMenu(None)
frame.Centre()
frame.Show()
def ladder_button_click( self, event ):
self.GetParent() # This assigns parent frame to frame.
self.Close() # This then closes frame removing the main menu.
frame = LadderMainMenu(None)
frame.Centre()
frame.Show()
我最初的想法是将主模块导入每个子模块,然后在每个子菜单模块中执行以下操作
车辆.py
class VehicleMainMenu(VehicleMenu):
def __init__(self, parent):
VehicleMenu.__init__(self, parent)
def veiw_vehicle_click(self, event):
self.GetParent() # This assigns parent frame to frame.
self.Close() # This then closes frame removing the main menu.
frame = VehicleListGrid(None)
frame.Centre()
frame.Show(
#This was the code to return to the main menu (main.py)
def back_click( self, event ):
self.GetParent() # This assigns parent frame to frame.
self.Close() # This then closes frame removing the main menu.
frame = TopMenu(None)
frame.Centre()
frame.Show()
我无法将菜单(menu.py)导入其他子菜单模块,因为这会引发错误。我尝试了各种许可,但无法返回主菜单。
请帮忙?