I'm new to Python (and, indeed, new to PC development) and would like to know how I should properly solve a problem I have using FileDialog in a Windows application I am writing...
Here is the relevant part of my code so far...
def SelectLogs(self, event):
dir = os.getcwd()
paths = []
open_dlg = wx.FileDialog(self, message='Select log file',
defaultDir=dir, style=wx.OPEN | wx.CHANGE_DIR | wx.MULTIPLE)
self.splitter.Refresh(True)
if open_dlg.ShowModal() == wx.ID_OK:
paths = open_dlg.GetPaths()
open_dlg.Destroy()
self.splitter.Refresh()
self.RetrieveLogData(paths)
def RetrieveLogData(self, paths):
count = 0
loglines = []
self.tc2.WriteText('Loading selected logs...')
paths.sort()
for log in paths:
read_data = []
f = open(log, 'r')
self.tc2.WriteText('\r\n ' + log)
read_data = f.readlines()
f.close()
count = count + 1
for line in read_data:
loglines.append(line)
self.tc1.WriteText(line)
self.tc2.WriteText('\r\nCompleted loading ' + str(count) + ' log(s)')
My problem is that even though I call open_dlg.Destroy() and self.splitter.Refresh() I still have remnants of the FileDialog showing over the lower one of my wx.TextCtrl (tc2) objects (tc1 is in the top half of the splitter and tc2 in the bottom half).
Once the file(s) are fully loaded and contents displayed in tc1 then tc2 refreshes and displays as I would expect.
I have tried calling the refresh methods on tc1 and tc2 instead of on the splitter but this doesn't seem to have any effect.
Any useful suggestions will be welcome. Thanks.