Hi,
I’m trying to reset a grid table to its initial state after some modifications made on it (some texts added and background changed). My first thought was to do a ForceRefresh() but it didn’t seem to work. After that, I thought that I just have to set background to white and SetCellValue to blank in order to simulate a refresh but it didn’t work too.
When I use:
self.SetCellBackgroundColour(0, 16, "#ffffff")
``
I got this error:
AttributeError: 'TestFrame' object has no attribute 'SetCellBackgroundColour'
``
My main problem is how to modify something in my Grid from a Frame class. I’m sure that I’m not doing it right hence my question here.
I would appreciate if someone can help me solve my problem.
Here is the part of my code that is problematic (see the last def):
import wx
import wx.grid as gridlib
class SimpleGrid(gridlib.Grid): ##, mixins.GridAutoEditMixin):
def __init__(self, parent, log):
gridlib.Grid.__init__(self, parent, -1)
[... Some Code to Create the grid]
class TestFrame(wx.Frame):
def __init__(self, parent, log):
wx.Frame.__init__(self, parent, 0, "Native Ads Reports V1.0", size=(1400,800))
self.grid = SimpleGrid(self, log)
# Create a status-Bar
status = self.CreateStatusBar()
# Create menu & Items
menubar = wx.MenuBar()
first = wx.Menu()
applyItem = first.Append(wx.ID_ANY, "Apply Changes", "This apply all changes to the campaigns" )
resetItem = first.Append(wx.ID_ANY, "Reset Changes", "This Reset all changes to the campaigns" )
menubar.Append(first, "Action")
self.SetMenuBar(menubar)
# Associate a handler function with the EVT_MENU
self.Bind(wx.EVT_MENU, self.OnApply, applyItem)
self.Bind(wx.EVT_MENU, self.OnReset, resetItem)
def OnApply(self, event):
"""Apply all changes"""
dlg = wx.MessageDialog(None, "Do you want to apply changes?",'Updater',wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal()
if result == wx.ID_YES:
self.count()
from changeBid import changeBid
changeBidTbBulk()
#My problem is situated here. If the user clicks "Yes" in the dialog box the table should reset and all modifications should be deleted
def OnReset(self, event):
"""Apply all changes"""
dlg = wx.MessageDialog(None, "Do you want to reset all changes?",'Updater',wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal()
if result == wx.ID_YES:
db_conn.execute("DELETE FROM SandboxTB")
db_conn.execute("DELETE FROM SandboxOB")
db_conn.commit()
# Here I tried to change background
self.SetCellBackgroundColour(0, 16, "#ffffff")
#and here the refresh
self.ForceRefresh()
``
Thank you,