wxGrid issue in Lua help requested

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
In need of some credit
In need of some credit
Posts: 1
Joined: Thu Jun 28, 2018 1:46 pm

wxGrid issue in Lua help requested

Postby rmcdermith » Thu Jun 28, 2018 1:58 pm

I have been trying to use wxGrid to create an editor for CAN DBC messages. This has worked fine up to the point that I have two remaining problems that I hope someone can explain. First problem is cell editing, for some reason I just can't figure out, when editing a cell value or after inserting a new row, the editor will not accept the input of the lower case "x". Second issue is again after edit of a cell , the new value is displayed , but when I retrieve the cell values using GetCewllValue(self,row,col) , which should contain the edited values, I get back the original values not the edited "new" values. What am I missing? Help Please. attached is my grid code there is more code but it's just helper functions.

Code: Select all

local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "HBM(HBK) Lua Based DBC Editor",
                         wx.wxPoint(25, 25), wx.wxSize(900, 700))

local fileMenu = wx.wxMenu("", wx.wxMENU_TEAROFF)
fileMenu:Append(wx.wxID_EXIT, "E&xit\tCtrl-X", "Quit the program")
fileMenu:Append(wx.wxID_OPEN, "O&pen\tCtrl-x", "Open New DBC File")
fileMenu:Append(wx.wxID_SAVEAS, "Save &as...\tAlt+S", "Save DBC File As")

local editMenu=wx.wxMenu("",wx.wxMENU_TEAROFF)
editMenu:Append(wx.wxID_ADD, "A&dd ROW\tCtrl-x", "Add New Row")
editMenu:Append(wx.wxID_DELETE, "D&elete Row\tCtr-l-x","Delete Selected Row")

local helpMenu = wx.wxMenu("", wx.wxMENU_TEAROFF)
helpMenu:Append(wx.wxID_ABOUT, "&About\tCtrl-A", "About the Application")

local menuBar = wx.wxMenuBar()
menuBar:Append(fileMenu, "&File")
menuBar:Append(editMenu, "&Edit")
menuBar:Append(helpMenu, "&Help")


frame:SetStatusText("Welcome to HBM(HBK) DBC Editor. This editor does not work for CCP/XCP or CAN FD!!!")

frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED,
    function (event)
    end )

frame:Connect(wx.wxID_OPEN, wx.wxEVT_COMMAND_MENU_SELECTED,

       fileDialog = wx.wxFileDialog(frame,"Open Vector DBC file","","","Vector files(*.dbc)|*.dbc|All files(*)|*",wx.wxFD_OPEN + wx.wxFD_FILE_MUST_EXIST)

    if fileDialog:ShowModal() == wx.wxID_OK then
        fileNameOpen = fileDialog:GetPath()
      rawdata=readdbc(fileNameOpen)  --todo get outp[ut from file dialog "C:\\Users\\McDermith\\Desktop\\Current\\AU_CAN\\old\\AU_CX23R_CAN.dbc"
      grid = wx.wxGrid(frame, wx.wxID_ANY)
      grid:CreateGrid(n, 11)
      grid:SetColLabelValue(1,"Signal Name")
      grid:SetColLabelValue(2,"Start Bit")
      grid:SetColLabelValue(3,"Bit Length")

      for k,v in pairs(messages) do
         for s,d in pairs(v) do

    return fileNameOpen

      local fileDialog = wx.wxFileDialog(frame,"Save Vector DBC file","","","Vector DBC files(*.dbc)|*.dbc|All files(*)|*",wx.wxFD_SAVE + wx.wxFD_OVERWRITE_PROMPT)
      local result = false
      if fileDialog:ShowModal() == wx.wxID_OK then
         fileNameSave = fileDialog:GetPath()
         result = savefileas()
         if result then
            frame:SetStatusText("Vector DBC - " .. fileName .. "Saved!")
      return fileNameSave


frame:Connect(wx.wxID_ADD, wx.wxEVT_COMMAND_MENU_SELECTED,

   --get selected row(s) number(s) remember zero based here in wxGrid

   if grid.IsSelection(grid)==true then
      for i=0,nmrs do
         if grid.IsInSelection(grid,i,1)==true then


frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED,
    function (event)
        wx.wxMessageBox('This is the "About" dialog of the Application.\n'..
                        wxlua.wxLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING,
                        "About DBCEditor",
                        wx.wxOK + wx.wxICON_INFORMATION,
                        frame )
    end )


Last edited by catalin on Thu Jun 28, 2018 2:24 pm, edited 1 time in total.
Reason: [code] tags

Return to “General Development”

Who is online

Users browsing this forum: No registered users and 5 guests