Ich habe ein Programm mit zwei Panel-Klassen, die ich in das Hauptpgrogramm mitteils import einbinde. Wenn ich jetzt aber über einen Button eine Methode der Application-Klasse das Hauptprogramms aufrufen will, müsste ich diese wiederum durch import einfügen. Dann kommt aber immer der Fehler:
Code: Alles auswählen
Traceback (most recent call last):
File "createxml.py", line 2, in ?
import configPanel
File "/home/l142051/work/ldap/autoyast/script/python_gui/neu2/configPanel.py", line 2, in ?
from createxml import Application
File "/home/l142051/work/ldap/autoyast/script/python_gui/neu2/createxml.py", line 124, in ?
frame = application()
File "/home/l142051/work/ldap/autoyast/script/python_gui/neu2/createxml.py", line 19, in __init__
self.pConfig = configPanel.Panel(self, self.ldapconfig, self.autoyastconfig, self.configFile)
AttributeError: 'module' object has no attribute 'Panel'
Code: Alles auswählen
import wx
import configPanel
import serverPanel
ID_CONFIG=100
ID_SERVER=102
ID_EXIT=110
ID_ABOUT=301
class application(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "createXML", size = (600,500))
self.sizer = wx.BoxSizer()
self.CreateToolBar()
self.CreateStatusBar()
self.createMenubar()
self.configFile = "/home/l142051/work/ldap/autoyast/script/python_gui/config"
self.ldapconfig = self.configLdap()
self.autoyastconfig = self.configAutoyast()
self.pConfig = configPanel.Panel(self, self.ldapconfig, self.autoyastconfig, self.configFile)
self.pServer = serverPanel.Panel(self)
self.sizer.Add(self.pConfig,1,wx.EXPAND)
self.sizer.Add(self.pServer,1,wx.EXPAND)
self.sizer.Show(self.pConfig, False)
self.sizer.Show(self.pServer,False)
self.SetSizerAndFit(self.sizer)
self.sizer.Layout()
self.Show(True)
Code: Alles auswählen
import wx
import createxml
class Panel(wx.Panel):
def __init__(self, parent, ldapconfig, autoyastconfig, configFile):
wx.Panel.__init__(self, parent, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN | wx.FULL_REPAINT_ON_RESIZE)
self.sConfig = wx.GridBagSizer(5,5)
self.SetSizerAndFit(self.sConfig)
width = 400
self.ldapText = wx.StaticText(self, -1, "LDAP configuration")
self.host = wx.StaticText(self, -1, "LDAP Server IP:")
self.hostconf = wx.TextCtrl(self, -1, ldapconfig["host"], size=(width, -1))
self.hostconf.SetInsertionPoint(0)
self.port = wx.StaticText(self, -1, "openLDAP port:")
self.portconf = wx.TextCtrl(self, -1, ldapconfig["port"], size=(width, -1))
self.portconf.SetInsertionPoint(0)
self.version = wx.StaticText(self, -1, "openLDAP version:")
self.versionconf = wx.TextCtrl(self, -1, ldapconfig["version"], size=(width, -1))
self.versionconf.SetInsertionPoint(0)
self.autoyastText = wx.StaticText(self, -1, "AutoYaST configuration")
self.base = wx.StaticText(self, -1, "ayBaseconfig:")
self.baseconf = wx.TextCtrl(self, -1, autoyastconfig["baseconfig"], size=(width, -1))
self.baseconf.SetInsertionPoint(0)
self.server = wx.StaticText(self, -1, "ayServer:")
self.serverconf = wx.TextCtrl(self, -1, autoyastconfig["server"], size=(width, -1))
self.serverconf.SetInsertionPoint(0)
self.hw = wx.StaticText(self, -1, "ayHardwarepool:")
self.hwconf = wx.TextCtrl(self, -1, autoyastconfig["hardwarepool"], size=(width, -1))
self.hwconf.SetInsertionPoint(0)
self.report = wx.StaticText(self, -1, "ayReport:")
self.reportconf = wx.TextCtrl(self, -1, autoyastconfig["report"], size=(width, -1))
self.reportconf.SetInsertionPoint(0)
self.security = wx.StaticText(self, -1, "aySecurity:")
self.securityconf = wx.TextCtrl(self, -1, autoyastconfig["security"], size=(width, -1))
self.securityconf.SetInsertionPoint(0)
self.software = wx.StaticText(self, -1, "aySoftware:")
self.softwareconf = wx.TextCtrl(self, -1, autoyastconfig["software"], size=(width, -1))
self.softwareconf.SetInsertionPoint(0)
self.x11 = wx.StaticText(self, -1, "ayX11Conf:")
self.x11conf = wx.TextCtrl(self, -1, autoyastconfig["x11conf"], size=(width, -1))
self.x11conf.SetInsertionPoint(0)
#self.safeButton = wx.Button(self.pConfig, wx.ID_SAVE, "")
self.safeButton = wx.Button(self, -1, "Save")
self.Bind(wx.EVT_BUTTON, saveConfig, self.safeButton)
self.undoButton = wx.Button(self, -1, "Undo")
self.Bind(wx.EVT_BUTTON, undoConfig, self.undoButton)
i = 1
j = 1
self.sConfig.Add(self.ldapText, (i,j))
i = i + 1
self.sConfig.Add(self.host, (i,j))
self.sConfig.Add(self.hostconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.port, (i,j))
self.sConfig.Add(self.portconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.version, (i,j))
self.sConfig.Add(self.versionconf, (i,j+1))
i = i + 2
self.sConfig.Add(self.autoyastText, (i,j))
i = i + 1
self.sConfig.Add(self.base, (i,j))
self.sConfig.Add(self.baseconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.hw, (i,j))
self.sConfig.Add(self.hwconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.software, (i,j))
self.sConfig.Add(self.softwareconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.server, (i,j))
self.sConfig.Add(self.serverconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.report, (i,j))
self.sConfig.Add(self.reportconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.security, (i,j))
self.sConfig.Add(self.securityconf, (i,j+1))
i = i + 1
self.sConfig.Add(self.x11, (i,j))
self.sConfig.Add(self.x11conf, (i,j+1))
i = i + 1
self.sConfig.Add(self.undoButton, (i,j))
self.sConfig.Add(self.safeButton, (i,j+1))
self.Show(False)
Tobias