Reputation: 109
I'm hoping someone can help me. I'm not sure where to look. I'm creating a GUI application with wxPython. I would simple window with a listctlr and a button. When you click on the button I need to run a process. This process has a loop that opens a browser with selenium, does some processing. For each iteration I would like to append that result to the listctrl. As of now the list does not update until the process is complete. I would like it to update the list after each loop iteration. Can you please help or point me in the right direction?
import sys
import wx
from collections import defaultdict
from selenium import common
from selenium import webdriver
from selenium.webdriver.support.ui import Select
class MainWindow(wx.Frame):
def __init__(self, parent, title):
super(MainWindow, self).__init__(parent, title=title)
def process_applications(event):
my_cursor = wx.Cursor(wx.CURSOR_WAIT)
self.panel.SetCursor(my_cursor)
for x, y in app.items():
index = self.list.InsertItem(sys.maxsize, student_application['FirstName'] + " " + student_application['LastName'])
.... Process selenium and data....
self.list.SetItem(index, 1, 'Success')
self.list.SetItem(index, 2, '12452134234')
self.list.SetItemBackgroundColour(index, wx.GREEN)
my_cursor = wx.Cursor(wx.CURSOR_DEFAULT)
self.panel.SetCursor(my_cursor)
self.panel = wx.Panel(self)
box = wx.BoxSizer(wx.VERTICAL)
icon = wx.Icon()
icon.CopyFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ANY))
self.SetIcon(icon)
self.button = wx.Button(self.panel, wx.ID_ANY, 'Process Applications', size=(200, 50))
self.button.Bind(wx.EVT_BUTTON, process_applications)
self.list = wx.ListCtrl(self.panel, -1, style=wx.LC_REPORT)
self.list.InsertColumn(0, "Student's Name", width=150)
self.list.InsertColumn(1, 'Status', wx.LIST_FORMAT_CENTER, 100)
self.list.InsertColumn(2, 'Confirmation #', wx.LIST_FORMAT_RIGHT, 100)
box.Add(self.list, 1, wx.EXPAND)
box.AddSpacer(5)
box.Add(self.button, 1, wx.CENTER)
box.AddSpacer(5)
self.panel.SetSizer(box)
self.panel.Fit()
self.Centre()
self.Show(True)
if __name__ == '__main__':
ex = wx.App()
MainWindow(None, 'NCCCO Application Process')
ex.MainLoop()
Upvotes: 0
Views: 72