DataTypeEditor.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:beremiz 作者: nucleron 项目源码 文件源码
def OnStructureElementsGridEditorShown(self, event):
        row, col = event.GetRow(), event.GetCol()
        if self.StructureElementsTable.GetColLabelValue(col, False) == "Type":
            type_menu = wx.Menu(title='')

            base_menu = wx.Menu(title='')
            for base_type in self.Controler.GetBaseTypes():
                new_id = wx.NewId()
                AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), id=new_id)
            type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu)

            datatype_menu = wx.Menu(title='')
            for datatype in self.Controler.GetDataTypes(self.TagName, False):
                new_id = wx.NewId()
                AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), id=new_id)
            type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)

            new_id = wx.NewId()
            AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array"))
            self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, id=new_id)

#            functionblock_menu = wx.Menu(title='')
#            bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
#            pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
#            if classtype in ["Input","Output","InOut","External","Global"] or poutype != "function" and bodytype in ["ST", "IL"]:
#                for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName):
#                    new_id = wx.NewId()
#                    AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type)
#                    self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id)
#                type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu)

            rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col))
            self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize())
            type_menu.Destroy()
            event.Veto()
        else:
            event.Skip()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号