I'm using pyodbc to make a GUI for viewing table info from my SQL database, currently my code kills the frame and regenerates it with the updated info. Here's an example of what it does when performing a search:
def nctDialog(self):
global nct, frame, table
dlg = wx.TextEntryDialog(
self, 'Enter NCT # here:',
'NCT Search', 'NCT #')
if dlg.ShowModal() == wx.ID_OK:
nct = ""
if(str(dlg.GetValue()) != ""):
nct = int(dlg.GetValue())
frame.Destroy()
frame = TestFrame(None, sys.stdout)
frame.Show(True)
dlg.Destroy()
It works but it's mildly annoying to me to see the window reappear in a new place on the screen. What I really want to achieve is an update of the table info without killing the frame.
Is there a way to update a table in a frame without killing and remaking the frame in wxPython?
TestFrame is mostly uninsteresting ,it sets up the frame and calls CustTableGrid() which I will show after...
class TestFrame(wx.Frame):
def __init__(self, parent, log):
....
grid = CustTableGrid(p, log)
....
CustTableGrid() creates a grid and calls:
class CustTableGrid(gridlib.Grid):
def __init__(self, parent, log):
gridlib.Grid.__init__(self, parent, -1)
table = CustomDataTable(log)
....
CustomDataTable:
class CustomDataTable(gridlib.PyGridTableBase):
def __init__(self, log):
global nct, toDate, fromDate, isn
gridlib.PyGridTableBase.__init__(self)
self.log = log
self.colLabels = [ 'Model', 'ISN', 'NCT', 'FW', 'Date', 'WWN']
self.dataTypes = [ gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING,gridlib.GRID_VALUE_STRING]
self.data = []
cursor.execute("select ISN, WWN, Date, FW, Model, NCT, isCurrent, Date from [General Drive Info] order by [General Drive Info].Date desc")
rows = cursor.fetchall()
count = 0
if(fromDate != None and toDate != None):
...