def __init__(self, parent, fileOpen=None):
""" Constructor of the PLCOpenEditor class.
:param parent: The parent window.
:param fileOpen: The filepath to open if no controler defined (default: None).
"""
self.icon = wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"), wx.BITMAP_TYPE_ICO)
IDEFrame.__init__(self, parent)
result = None
# Open the filepath if defined
if fileOpen is not None:
fileOpen = DecodeFileSystemPath(fileOpen, False)
if os.path.isfile(fileOpen):
# Create a new controller
controler = PLCControler()
result = controler.OpenXMLFile(fileOpen)
self.Controler = controler
self.LibraryPanel.SetController(controler)
self.ProjectTree.Enable(True)
self.PouInstanceVariablesPanel.SetController(controler)
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
# Define PLCOpenEditor icon
self.SetIcon(self.icon)
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
if result is not None:
(num, line) = result
self.ShowErrorMessage(_("PLC syntax error at line {a1}:\n{a2}").format(a1=num, a2=line))
评论列表
文章目录