Panel aus-/einblenden klappt nicht
Verfasst: Mittwoch 7. Dezember 2005, 11:06
Hallo!
Ich habe eine Applikation mit einem Frame, zwei Panels mit ihren Sizern und ein Menü. In dem Menü kann ich über zwei Buttons ein Server-Panel und ein Configure-Panel aufrufen. Wenn diese noch nicht initialisiert sind, wird dies getan ansonsten soll bloß das Panel gewechselt werden (ausblenden des einen und einblenden des andere. Auszug:
Wenn ich über den Button das Server-Panel aufrufe und dann das Configure-Panel, dann blendet sich das erste aus und das zweite ein. Andersherum funktioniert es leider nicht.
Hat jemand eine Idee?
Danke schon mal im Voraus.
Tobias
Ich habe eine Applikation mit einem Frame, zwei Panels mit ihren Sizern und ein Menü. In dem Menü kann ich über zwei Buttons ein Server-Panel und ein Configure-Panel aufrufen. Wenn diese noch nicht initialisiert sind, wird dies getan ansonsten soll bloß das Panel gewechselt werden (ausblenden des einen und einblenden des andere. Auszug:
Code: Alles auswählen
class Application(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "createXML", size = (400,300))
self.pServer = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN | wx.FULL_REPAINT_ON_RESIZE)
self.pConfig = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN | wx.FULL_REPAINT_ON_RESIZE)
space = 5
self.sServer = wx.GridBagSizer(space, space)
self.sConfig = wx.GridBagSizer(space, space)
#self.sServer.AddGrowableCol(1)
self.pServer.SetSizerAndFit(self.sServer)
self.pConfig.SetSizerAndFit(self.sConfig)
#self.CreateToolBar()
self.CreateStatusBar()
self.createMenubar()
self.Show(True)
self.ldapconfig = self.configLdap()
self.autoyastconfig = self.configAutoyast()
self.checkConfig()
self.configureInit = 1
self.serverInit = 1
def createFilemenu(self):
"""Create the File menu."""
self.filemenu = wx.Menu()
self.filemenu.Append(ID_CONFIG,"&Configure"," Configure...")
wx.EVT_MENU(self, ID_CONFIG, self.configure)
self.filemenu.Append(ID_SERVER,"&Get Serverlist"," Show a list of available server...")
wx.EVT_MENU(self, ID_SERVER, self.buildServerList)
self.filemenu.AppendSeparator()
self.filemenu.Append(ID_EXIT,"E&xit"," Terminate the program...")
wx.EVT_MENU(self, ID_EXIT, self.onExit)
def createHelpmenu(self):
"""Create the Help menu"""
self.helpmenu = wx.Menu()
self.helpmenu.Append(ID_ABOUT, "&About"," Information about this program")
wx.EVT_MENU(self, ID_ABOUT, self.onAbout)
def createMenubar(self):
"""Create the menubar with its menus"""
# create the file menu
self.createFilemenu()
# create the help menu
self.createHelpmenu()
self.menuBar = wx.MenuBar()
# add the menus to the MenuBar
self.menuBar.Append(self.filemenu,"&File")
self.menuBar.Append(self.helpmenu,"&Help")
# add the MenuBar to the Frame content
self.SetMenuBar(self.menuBar)
def __configureInit(self):
"""Initialize the configure panel"""
self.configureInit = 0
width = 250
base = wx.StaticText(self.pConfig, -1, "ayBaseconfig:")
baseconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["baseconfig"], size=(width, -1))
baseconf.SetInsertionPoint(0)
server = wx.StaticText(self.pConfig, -1, "ayServer:")
serverconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["server"], size=(width, -1))
serverconf.SetInsertionPoint(0)
hw = wx.StaticText(self.pConfig, -1, "ayHardwarepool:")
hwconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["hardwarepool"], size=(width, -1))
hwconf.SetInsertionPoint(0)
report = wx.StaticText(self.pConfig, -1, "ayReport:")
reportconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["report"], size=(width, -1))
reportconf.SetInsertionPoint(0)
security = wx.StaticText(self.pConfig, -1, "aySecurity:")
securityconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["security"], size=(width, -1))
securityconf.SetInsertionPoint(0)
software = wx.StaticText(self.pConfig, -1, "aySoftware:")
softwareconf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["software"], size=(width, -1))
softwareconf.SetInsertionPoint(0)
x11 = wx.StaticText(self.pConfig, -1, "ayX11Conf:")
x11conf = wx.TextCtrl(self.pConfig, -1, self.autoyastconfig["x11conf"], size=(width, -1))
x11conf.SetInsertionPoint(0)
self.sConfig.Add(base, (1,0))
self.sConfig.Add(baseconf, (1,1))
self.sConfig.Add(server, (2,0))
self.sConfig.Add(serverconf, (2,1))
self.sConfig.Add(hw, (3,0))
self.sConfig.Add(hwconf, (3,1))
self.sConfig.Add(report, (4,0))
self.sConfig.Add(reportconf, (4,1))
self.sConfig.Add(security, (5,0))
self.sConfig.Add(securityconf, (5,1))
self.sConfig.Add(software, (6,0))
self.sConfig.Add(softwareconf, (6,1))
self.sConfig.Add(x11, (7,0))
self.sConfig.Add(x11conf, (7,1))
self.pConfig.SetSizerAndFit(self.sConfig)
self.sConfig.Layout()
def buildServerList(self, event):
"""Get a list of configured server to create the AutoYaST XML file"""
if ( self.serverInit == 1 ):
self.__serverInit()
self.sConfig.Show(self.pConfig,show=False,recursive=False)
self.sConfig.Layout()
self.sServer.Show(self.pServer,show=True,recursive=False)
self.sServer.Layout()
def __serverInit(self):
"""Initialize the server panel"""
self.serverInit = 0
# radio boxes for the different server
self.selectedServer = 0
self.serverList = self.getvalue(self.ldapsearch(self.ldapconfig["host"],self.autoyastconfig["server"],"cn=*"),"cn")
self.serverBox = wx.RadioBox(self.pServer, 10, "Choose Server:", wx.DefaultPosition, wx.DefaultSize, self.serverList, 1, wx.RA_SPECIFY_COLS)
self.serverBox.SetToolTip(wx.ToolTip("Choose a server to build a autoyast.xml file for"))
self.Bind(wx.EVT_RADIOBOX, self.evtRadioBox, self.serverBox)
# button to choose the server
self.create = wx.Button(self.pServer, 20,"Build autoyast.xml file")
self.Bind(wx.EVT_BUTTON, self.evtChooseServer, self.create)
# logger to show events
self.logger = wx.TextCtrl(self.pServer,30, "", size = (200,100), style = wx.TE_MULTILINE | wx.TE_READONLY)
self.logger.SetToolTip(wx.ToolTip("This logger shows events."))
self.sServer.Add(self.serverBox, (1,0))
self.sServer.Add(self.create, (2,0))
self.sServer.Add(self.logger, (1,1), (2,1), wx.EXPAND)
self.pServer.SetSizerAndFit(self.sServer)
self.sServer.Layout()
Hat jemand eine Idee?
Danke schon mal im Voraus.
Tobias