예제 #1
0
    def __init__(self, parent, fileOpen = None):
        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(wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"),wx.BITMAP_TYPE_ICO))

        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)

        if result is not None:
            self.ShowErrorMessage(
                _("PLC syntax error at line %d:\n%s") % result)
예제 #2
0
    def __init__(self, parent, fileOpen=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))
예제 #3
0
    def OnProjectTreeRightUp(self, event):
        item = event.GetItem()
        item_infos = self.ProjectTree.GetItemData(item)

        if item_infos["type"] == ITEM_CONFNODE:
            confnode_menu = wx.Menu(title='')

            confnode = item_infos["confnode"]
            if confnode is not None:
                menu_items = confnode.GetContextualMenuItems()
                if menu_items is not None:
                    for text, helpstr, callback in menu_items:
                        item = confnode_menu.Append(wx.ID_ANY, text, helpstr)
                        self.Bind(wx.EVT_MENU, callback, item)
                else:
                    for name, XSDClass, helpstr in confnode.CTNChildrenTypes:
                        if not hasattr(XSDClass, 'CTNMaxCount') or not confnode.Children.get(name) \
                                or len(confnode.Children[name]) < XSDClass.CTNMaxCount:
                            item = confnode_menu.Append(wx.ID_ANY, _("Add") + " " + name, helpstr)
                            self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name, confnode), item)
            item = confnode_menu.Append(wx.ID_ANY, _("Delete"))
            self.Bind(wx.EVT_MENU, self.GetDeleteMenuFunction(confnode), item)

            self.PopupMenu(confnode_menu)
            confnode_menu.Destroy()

            event.Skip()
        elif item_infos["type"] == ITEM_RESOURCE:
            # prevent last resource to be delted
            parent = self.ProjectTree.GetItemParent(item)
            parent_name = self.ProjectTree.GetItemText(parent)
            if parent_name == _("Resources"):
                IDEFrame.OnProjectTreeRightUp(self, event)
        else:
            IDEFrame.OnProjectTreeRightUp(self, event)
예제 #4
0
    def OnNewProjectMenu(self, event):
        if self.CTR is not None and not self.CheckSaveBeforeClosing():
            return

        try:
            defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder").encode())
        except Exception:
            defaultpath = os.path.expanduser("~")

        dialog = wx.DirDialog(self, _("Choose an empty directory for new project"), defaultpath)
        if dialog.ShowModal() == wx.ID_OK:
            projectpath = dialog.GetPath()
            self.Config.Write("lastopenedfolder",
                              EncodeFileSystemPath(os.path.dirname(projectpath)))
            self.Config.Flush()
            self.ResetView()
            ctr = ProjectController(self, self.Log)
            result = ctr.NewProject(projectpath)
            if not result:
                self.CTR = ctr
                self.Controler = self.CTR
                self.LibraryPanel.SetController(self.Controler)
                self.ProjectTree.Enable(True)
                self.PouInstanceVariablesPanel.SetController(self.Controler)
                self.RefreshConfigRecentProjects(projectpath)
                if self.EnableDebug:
                    self.DebugVariablePanel.SetDataProducer(self.CTR)
                self.RefreshAfterLoad()
                IDEFrame.OnAddNewProject(self, event)
            else:
                self.ResetView()
                self.ShowErrorMessage(result)
            self.RefreshAll()
            self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU)
        dialog.Destroy()
예제 #5
0
 def GetProjectElementWindow(self, element, tagname):
     is_a_CTN_tagname = len(tagname.split("::")) == 1
     if is_a_CTN_tagname:
         confnode = self.CTR.GetChildByName(tagname)
         return confnode.GetView()
     else:
         return IDEFrame.GetProjectElementWindow(self, element, tagname)
예제 #6
0
 def ProjectTreeItemSelect(self, select_item):
     if select_item is not None and select_item.IsOk():
         item_infos = self.ProjectTree.GetPyData(select_item)
         if item_infos["type"] == ITEM_CONFNODE:
             item_infos["confnode"]._OpenView(onlyopened=True)
         elif item_infos["type"] == ITEM_PROJECT:
             self.CTR._OpenView(onlyopened=True)
         else:
             IDEFrame.ProjectTreeItemSelect(self, select_item)
예제 #7
0
 def LoadTab(self, notebook, page_infos):
     if page_infos[0] == "confnode":
         if page_infos[1] is None:
             confnode = self.CTR
         else:
             confnode = self.CTR.GetChildByName(page_infos[1])
         return notebook.GetPageIndex(confnode._OpenView(*page_infos[2:]))
     else:
         return IDEFrame.LoadTab(self, notebook, page_infos)
예제 #8
0
 def ResetView(self):
     IDEFrame.ResetView(self)
     if self.CTR is not None:
         self.CTR.CloseProject()
     self.CTR = None
     self.Log.flush()
     if self.EnableDebug:
         self.DebugVariablePanel.SetDataProducer(None)
         self.ResetConnectionStatusBar()
예제 #9
0
 def ShowHighlight(self, infos, start, end, highlight_type):
     config_name = self.Controler.GetProjectMainConfigurationName()
     if config_name is not None and infos[0] == ComputeConfigurationName(config_name):
         self.CTR._OpenView()
         selected = self.ActiveChild
         if selected and isinstance(selected.Children[0], Viewer):
             viewer = selected
             viewer.AddHighlight(infos[1:], start, end, highlight_type)
     else:
         IDEFrame.ShowHighlight(self, infos, start, end, highlight_type)
예제 #10
0
 def OnProjectTreeItemActivated(self, event):
     selected = event.GetItem()
     item_infos = self.ProjectTree.GetPyData(selected)
     if item_infos["type"] == ITEM_CONFNODE:
         item_infos["confnode"]._OpenView()
         event.Skip()
     elif item_infos["type"] == ITEM_PROJECT:
         self.CTR._OpenView()
     else:
         IDEFrame.OnProjectTreeItemActivated(self, event)
예제 #11
0
 def ShowHighlight(self, infos, start, end, highlight_type):
     config_name = self.Controler.GetProjectMainConfigurationName()
     if config_name is not None and infos[0] == ComputeConfigurationName(
             config_name):
         self.CTR._OpenView()
         selected = self.TabsOpened.GetSelection()
         if selected != -1:
             viewer = self.TabsOpened.GetPage(selected)
             viewer.AddHighlight(infos[1:], start, end, highlight_type)
     else:
         IDEFrame.ShowHighlight(self, infos, start, end, highlight_type)
예제 #12
0
 def GetTabInfos(self, tab):
     if (isinstance(tab, EditorPanel)
             and not isinstance(tab,
                                (Viewer, TextViewer, ResourceEditor,
                                 ConfigurationEditor, DataTypeEditor))):
         return ("confnode", tab.Controler.CTNFullName(), tab.GetTagName())
     elif (isinstance(tab, TextViewer)
           and (tab.Controler is None
                or isinstance(tab.Controler, MiniTextControler))):
         return ("confnode", None, tab.GetInstancePath())
     else:
         return IDEFrame.GetTabInfos(self, tab)
예제 #13
0
 def SelectProjectTreeItem(self, tagname):
     if self.ProjectTree is not None:
         root = self.ProjectTree.GetRootItem()
         if root and root.IsOk():
             words = tagname.split("::")
             if len(words) == 1:
                 if tagname == "Project":
                     self.SelectedItem = root
                     self.ProjectTree.SelectItem(root)
                     self.ResetSelectedItem()
                 else:
                     return self.RecursiveProjectTreeItemSelection(
                         root,
                         [(word, ITEM_CONFNODE) for word in tagname.split(".")])
             elif words[0] == "R":
                 return self.RecursiveProjectTreeItemSelection(root, [(words[2], ITEM_RESOURCE)])
             elif not os.path.exists(words[0]):
                 IDEFrame.SelectProjectTreeItem(self, tagname)
예제 #14
0
    def RefreshEditMenu(self):
        IDEFrame.RefreshEditMenu(self)
        if self.FindFocus() == self.LogConsole:
            self.EditMenu.Enable(wx.ID_COPY, True)
            self.Panes["MenuToolBar"].EnableTool(wx.ID_COPY, True)

        if self.CTR is not None:
            selected = self.ActiveChild
            if selected and isinstance(selected.Children[0], Viewer):
                panel = selected
                window = panel.Children[0]
            else:
                panel = None
            if panel != self.LastPanelSelected:
                for i in range(self.EditMenuSize, self.EditMenu.GetMenuItemCount()):
                    item = self.EditMenu.FindItemByPosition(self.EditMenuSize)
                    if item is not None:
                        if item.IsSeparator():
                            self.EditMenu.Remove(item)
                        else:
                            self.EditMenu.Delete(item.GetId())
                self.LastPanelSelected = panel
                if panel is not None:
                    if not hasattr(window, 'GetConfNodeMenuItems'):
                        print(window)
                    items = window.GetConfNodeMenuItems()
                else:
                    items = []
                if len(items) > 0:
                    self.EditMenu.AppendSeparator()
                    self.GenerateMenuRecursive(items, self.EditMenu)
            if panel is not None:
                window.RefreshConfNodeMenu(self.EditMenu)
        else:
            for i in range(self.EditMenuSize, self.EditMenu.GetMenuItemCount()):
                item = self.EditMenu.FindItemByPosition(i)
                if item is not None:
                    if item.IsSeparator():
                        self.EditMenu.Remove(item)
                    else:
                        self.EditMenu.Delete(item.GetId())
            self.LastPanelSelected = None
        self.MenuBar.Refresh()
예제 #15
0
    def RefreshEditMenu(self):
        IDEFrame.RefreshEditMenu(self)
        if self.FindFocus() == self.LogConsole:
            self.EditMenu.Enable(wx.ID_COPY, True)
            self.Panes["MenuToolBar"].EnableTool(wx.ID_COPY, True)

        if self.CTR is not None:
            selected = self.TabsOpened.GetSelection()
            if selected >= 0:
                panel = self.TabsOpened.GetPage(selected)
            else:
                panel = None
            if panel != self.LastPanelSelected:
                for i in xrange(self.EditMenuSize,
                                self.EditMenu.GetMenuItemCount()):
                    item = self.EditMenu.FindItemByPosition(self.EditMenuSize)
                    if item is not None:
                        if item.IsSeparator():
                            self.EditMenu.RemoveItem(item)
                        else:
                            self.EditMenu.Delete(item.GetId())
                self.LastPanelSelected = panel
                if panel is not None:
                    items = panel.GetConfNodeMenuItems()
                else:
                    items = []
                if len(items) > 0:
                    self.EditMenu.AppendSeparator()
                    self.GenerateMenuRecursive(items, self.EditMenu)
            if panel is not None:
                panel.RefreshConfNodeMenu(self.EditMenu)
        else:
            for i in xrange(self.EditMenuSize,
                            self.EditMenu.GetMenuItemCount()):
                item = self.EditMenu.FindItemByPosition(i)
                if item is not None:
                    if item.IsSeparator():
                        self.EditMenu.RemoveItem(item)
                    else:
                        self.EditMenu.Delete(item.GetId())
            self.LastPanelSelected = None
        self.MenuBar.UpdateMenus()
예제 #16
0
 def ResetPerspective(self):
     IDEFrame.ResetPerspective(self)
     self.RefreshStatusToolBar()
예제 #17
0
    def _init_utils(self):
        self.ConfNodeMenu = wx.Menu(title="")
        self.RecentProjectsMenu = wx.Menu(title="")

        IDEFrame._init_utils(self)
예제 #18
0
 def RefreshEditorToolBar(self):
     IDEFrame.RefreshEditorToolBar(self)
     self.AUIManager.GetPane("EditorToolBar").Position(2)
     self.AUIManager.GetPane("StatusToolBar").Position(1)
     self.AUIManager.Update()
예제 #19
0
 def _init_coll_AddMenu_Items(self, parent):
     IDEFrame._init_coll_AddMenu_Items(self, parent, False)
     self._RecursiveAddMenuItems(parent, GetAddMenuItems())
예제 #20
0
    def __init__(self,
                 parent,
                 projectOpen=None,
                 buildpath=None,
                 ctr=None,
                 debug=True):
        # Add beremiz's icon in top left corner of the frame
        self.icon = wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO)
        self.__init_execute_path()

        IDEFrame.__init__(self, parent, debug)
        self.Log = LogPseudoFile(self.LogConsole, self.SelectTab)

        self.local_runtime = None
        self.runtime_port = None
        self.local_runtime_tmpdir = None

        self.LastPanelSelected = None

        # Define Tree item icon list
        self.LocationImageList = wx.ImageList(16, 16)
        self.LocationImageDict = {}

        # Icons for location items
        for imgname, itemtype in [("CONFIGURATION", LOCATION_CONFNODE),
                                  ("RESOURCE", LOCATION_MODULE),
                                  ("PROGRAM", LOCATION_GROUP),
                                  ("VAR_INPUT", LOCATION_VAR_INPUT),
                                  ("VAR_OUTPUT", LOCATION_VAR_OUTPUT),
                                  ("VAR_LOCAL", LOCATION_VAR_MEMORY)]:
            self.LocationImageDict[itemtype] = self.LocationImageList.Add(
                GetBitmap(imgname))

        # Icons for other items
        for imgname, itemtype in [("Extension", ITEM_CONFNODE)]:
            self.TreeImageDict[itemtype] = self.TreeImageList.Add(
                GetBitmap(imgname))

        if projectOpen is not None:
            projectOpen = DecodeFileSystemPath(projectOpen, False)

        if projectOpen is not None and os.path.isdir(projectOpen):
            self.CTR = ProjectController(self, self.Log)
            self.Controler = self.CTR
            result, _err = self.CTR.LoadProject(projectOpen, buildpath)
            if not result:
                self.LibraryPanel.SetController(self.Controler)
                self.ProjectTree.Enable(True)
                self.PouInstanceVariablesPanel.SetController(self.Controler)
                self.RefreshConfigRecentProjects(os.path.abspath(projectOpen))
                self.RefreshAfterLoad()
            else:
                self.ResetView()
                self.ShowErrorMessage(result)
        else:
            self.CTR = ctr
            self.Controler = ctr
            if ctr is not None:
                ctr.SetAppFrame(self, self.Log)
                self.LibraryPanel.SetController(self.Controler)
                self.ProjectTree.Enable(True)
                self.PouInstanceVariablesPanel.SetController(self.Controler)
                self.RefreshAfterLoad()
        if self.EnableDebug:
            self.DebugVariablePanel.SetDataProducer(self.CTR)

        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
        self.RefreshAll()
        self.LogConsole.SetFocus()
예제 #21
0
    def _init_ctrls(self, prnt):
        IDEFrame._init_ctrls(self, prnt)

        self.EditMenuSize = self.EditMenu.GetMenuItemCount()

        inspectorID = wx.NewId()
        self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID)
        accels = [
            wx.AcceleratorEntry(wx.ACCEL_CTRL | wx.ACCEL_ALT, ord('I'),
                                inspectorID)
        ]

        for method, shortcut in [("Stop", wx.WXK_F4), ("Run", wx.WXK_F5),
                                 ("Transfer", wx.WXK_F6),
                                 ("Connect", wx.WXK_F7),
                                 ("Build", wx.WXK_F11)]:

            def OnMethodGen(obj, meth):
                def OnMethod(evt):
                    if obj.CTR is not None:
                        obj.CTR.CallMethod('_' + meth)
                    wx.CallAfter(self.RefreshStatusToolBar)

                return OnMethod

            newid = wx.NewId()
            self.Bind(wx.EVT_MENU, OnMethodGen(self, method), id=newid)
            accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut, newid)]

        self.SetAcceleratorTable(wx.AcceleratorTable(accels))

        self.LogConsole = CustomStyledTextCtrl(name='LogConsole',
                                               parent=self.BottomNoteBook,
                                               pos=wx.Point(0, 0),
                                               size=wx.Size(0, 0))
        self.LogConsole.Bind(wx.EVT_SET_FOCUS, self.OnLogConsoleFocusChanged)
        self.LogConsole.Bind(wx.EVT_KILL_FOCUS, self.OnLogConsoleFocusChanged)
        self.LogConsole.Bind(wx.stc.EVT_STC_UPDATEUI,
                             self.OnLogConsoleUpdateUI)
        self.LogConsole.SetReadOnly(True)
        self.LogConsole.SetWrapMode(wx.stc.STC_WRAP_CHAR)

        # Define Log Console styles
        self.LogConsole.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT,
                                     "face:%(mono)s,size:%(size)d" % faces)
        self.LogConsole.StyleClearAll()
        self.LogConsole.StyleSetSpec(
            1, "face:%(mono)s,fore:#FF0000,size:%(size)d" % faces)
        self.LogConsole.StyleSetSpec(
            2, "face:%(mono)s,fore:#FF0000,back:#FFFF00,size:%(size)d" % faces)

        # Define Log Console markers
        self.LogConsole.SetMarginSensitive(1, True)
        self.LogConsole.SetMarginType(1, wx.stc.STC_MARGIN_SYMBOL)
        self.LogConsole.MarkerDefine(0, wx.stc.STC_MARK_CIRCLE, "BLACK", "RED")

        self.LogConsole.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT)

        self.LogConsole.Bind(wx.stc.EVT_STC_MARGINCLICK,
                             self.OnLogConsoleMarginClick)
        self.LogConsole.Bind(wx.stc.EVT_STC_MODIFIED,
                             self.OnLogConsoleModified)

        self.MainTabs["LogConsole"] = (self.LogConsole, _("Console"))
        self.BottomNoteBook.AddPage(*self.MainTabs["LogConsole"])
        # self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogConsole), wx.RIGHT)

        self.LogViewer = LogViewer(self.BottomNoteBook, self)
        self.MainTabs["LogViewer"] = (self.LogViewer, _("PLC Log"))
        self.BottomNoteBook.AddPage(*self.MainTabs["LogViewer"])
        # self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogViewer), wx.RIGHT)

        StatusToolBar = wx.ToolBar(self, -1, wx.DefaultPosition,
                                   wx.DefaultSize,
                                   wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
        StatusToolBar.SetToolBitmapSize(wx.Size(25, 25))
        StatusToolBar.Realize()
        self.Panes["StatusToolBar"] = StatusToolBar
        self.AUIManager.AddPane(
            StatusToolBar,
            wx.aui.AuiPaneInfo().Name("StatusToolBar").Caption(
                _("Status ToolBar")).ToolbarPane().Top().Position(
                    1).LeftDockable(False).RightDockable(False))

        self.AUIManager.Update()

        self.ConnectionStatusBar = esb.EnhancedStatusBar(self,
                                                         style=wx.ST_SIZEGRIP)
        self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar)
        self.ProgressStatusBar = wx.Gauge(self.ConnectionStatusBar,
                                          -1,
                                          range=100)
        self.ConnectionStatusBar.AddWidget(self.ProgressStatusBar,
                                           esb.ESB_EXACT_FIT,
                                           esb.ESB_EXACT_FIT, 2)
        self.ProgressStatusBar.Hide()
        self.SetStatusBar(self.ConnectionStatusBar)
예제 #22
0
 def _init_coll_AddMenu_Items(self, parent):
     IDEFrame._init_coll_AddMenu_Items(self, parent, False)
     self._RecursiveAddMenuItems(parent, GetAddMenuItems())
예제 #23
0
    def _init_utils(self):
        self.ConfNodeMenu = wx.Menu(title='')
        self.RecentProjectsMenu = wx.Menu(title='')

        IDEFrame._init_utils(self)
예제 #24
0
    def _init_ctrls(self, prnt):
        IDEFrame._init_ctrls(self, prnt)

        self.EditMenuSize = self.EditMenu.GetMenuItemCount()

        inspectorID = wx.NewId()
        self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID)
        accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL | wx.ACCEL_ALT, ord("I"), inspectorID)]
        for method, shortcut in [
            ("Stop", wx.WXK_F4),
            ("Run", wx.WXK_F5),
            ("Transfer", wx.WXK_F6),
            ("Connect", wx.WXK_F7),
            ("Build", wx.WXK_F11),
        ]:

            def OnMethodGen(obj, meth):
                def OnMethod(evt):
                    if obj.CTR is not None:
                        obj.CTR.CallMethod("_" + meth)
                    wx.CallAfter(self.RefreshStatusToolBar)

                return OnMethod

            newid = wx.NewId()
            self.Bind(wx.EVT_MENU, OnMethodGen(self, method), id=newid)
            accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut, newid)]

        self.SetAcceleratorTable(wx.AcceleratorTable(accels))

        self.LogConsole = CustomStyledTextCtrl(
            name="LogConsole", parent=self.BottomNoteBook, pos=wx.Point(0, 0), size=wx.Size(0, 0)
        )
        self.LogConsole.Bind(wx.EVT_SET_FOCUS, self.OnLogConsoleFocusChanged)
        self.LogConsole.Bind(wx.EVT_KILL_FOCUS, self.OnLogConsoleFocusChanged)
        self.LogConsole.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnLogConsoleUpdateUI)
        self.LogConsole.SetReadOnly(True)
        self.LogConsole.SetWrapMode(wx.stc.STC_WRAP_CHAR)

        # Define Log Console styles
        self.LogConsole.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d" % faces)
        self.LogConsole.StyleClearAll()
        self.LogConsole.StyleSetSpec(1, "face:%(mono)s,fore:#FF0000,size:%(size)d" % faces)
        self.LogConsole.StyleSetSpec(2, "face:%(mono)s,fore:#FF0000,back:#FFFF00,size:%(size)d" % faces)

        # Define Log Console markers
        self.LogConsole.SetMarginSensitive(1, True)
        self.LogConsole.SetMarginType(1, wx.stc.STC_MARGIN_SYMBOL)
        self.LogConsole.MarkerDefine(0, wx.stc.STC_MARK_CIRCLE, "BLACK", "RED")

        self.LogConsole.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT)

        self.LogConsole.Bind(wx.stc.EVT_STC_MARGINCLICK, self.OnLogConsoleMarginClick)
        self.LogConsole.Bind(wx.stc.EVT_STC_MODIFIED, self.OnLogConsoleModified)

        self.MainTabs["LogConsole"] = (self.LogConsole, _("Console"))
        self.BottomNoteBook.AddPage(*self.MainTabs["LogConsole"])
        # self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogConsole), wx.RIGHT)

        self.LogViewer = LogViewer(self.BottomNoteBook, self)
        self.MainTabs["LogViewer"] = (self.LogViewer, _("PLC Log"))
        self.BottomNoteBook.AddPage(*self.MainTabs["LogViewer"])
        # self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogViewer), wx.RIGHT)

        StatusToolBar = wx.ToolBar(
            self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER
        )
        StatusToolBar.SetToolBitmapSize(wx.Size(25, 25))
        StatusToolBar.Realize()
        self.Panes["StatusToolBar"] = StatusToolBar
        self.AUIManager.AddPane(
            StatusToolBar,
            wx.aui.AuiPaneInfo()
            .Name("StatusToolBar")
            .Caption(_("Status ToolBar"))
            .ToolbarPane()
            .Top()
            .Position(1)
            .LeftDockable(False)
            .RightDockable(False),
        )

        self.AUIManager.Update()

        self.ConnectionStatusBar = wx.StatusBar(self, style=wx.ST_SIZEGRIP)
        self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar)
        self.SetStatusBar(self.ConnectionStatusBar)
예제 #25
0
    def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True):
        IDEFrame.__init__(self, parent, debug)
        self.Log = LogPseudoFile(self.LogConsole, self.SelectTab)

        self.local_runtime = None
        self.runtime_port = None
        self.local_runtime_tmpdir = None

        self.LastPanelSelected = None

        # Define Tree item icon list
        self.LocationImageList = wx.ImageList(16, 16)
        self.LocationImageDict = {}

        # Icons for location items
        for imgname, itemtype in [
            ("CONFIGURATION", LOCATION_CONFNODE),
            ("RESOURCE", LOCATION_MODULE),
            ("PROGRAM", LOCATION_GROUP),
            ("VAR_INPUT", LOCATION_VAR_INPUT),
            ("VAR_OUTPUT", LOCATION_VAR_OUTPUT),
            ("VAR_LOCAL", LOCATION_VAR_MEMORY),
        ]:
            self.LocationImageDict[itemtype] = self.LocationImageList.Add(GetBitmap(imgname))

        # Icons for other items
        for imgname, itemtype in [("Extension", ITEM_CONFNODE)]:
            self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))

        # Add beremiz's icon in top left corner of the frame
        self.SetIcon(wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO))

        if projectOpen is not None:
            projectOpen = DecodeFileSystemPath(projectOpen, False)

        if projectOpen is not None and os.path.isdir(projectOpen):
            self.CTR = ProjectController(self, self.Log)
            self.Controler = self.CTR
            result = self.CTR.LoadProject(projectOpen, buildpath)
            if not result:
                self.LibraryPanel.SetController(self.Controler)
                self.ProjectTree.Enable(True)
                self.PouInstanceVariablesPanel.SetController(self.Controler)
                self.RefreshConfigRecentProjects(os.path.abspath(projectOpen))
                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
            else:
                self.ResetView()
                self.ShowErrorMessage(result)
        else:
            self.CTR = ctr
            self.Controler = ctr
            if ctr is not None:
                self.LibraryPanel.SetController(self.Controler)
                self.ProjectTree.Enable(True)
                self.PouInstanceVariablesPanel.SetController(self.Controler)
                self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
        if self.EnableDebug:
            self.DebugVariablePanel.SetDataProducer(self.CTR)

        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
        self.RefreshAll()
        self.LogConsole.SetFocus()
예제 #26
0
 def OnProjectTreeItemBeginEdit(self, event):
     selected = event.GetItem()
     if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFNODE:
         event.Veto()
     else:
         IDEFrame.OnProjectTreeItemBeginEdit(self, event)