Hi Everone,
I am relatively new to wxPython, and whilst I have had some experience with it before, I have not before tried to implement it into a real application, which is what I am currently trying to do.
I am using a combination of wxGlade and manual editing to create the GUI that I want, and so far it looks great! Though I am having problems with one of the event handlers. Firstly, I will explain how I am working with things, and then explain the problems that I have run into.
I have my command line application, which is in one python file, lets say application.py. Then I have my wxPython GUI, which I have in gui.py. From gui.py, I have imported both wx (obviously) and application. With the event handler of one of the buttons within the applcation, the event that it calls (say self.OnButtonClick()) does a few things, and then send a whole lot of information (collected from user input fields in the GUI) to application.MyFunction(). This function then does what it needs to do.
Now, the application I am writing a GUI for is an application that downloads many images from a website (based on the information given by the user), and it works fine via the command line. As it is downloading, it does take some time, and with this there is a period where the application is unresponsive and appears frozen (the button that triggers the event also appears pressed down until all the downloading has stopped). Now, this does have the potential to need to download 100’s of images (depends on the user, I have only been testing it with about 10), and the user could easily force quit the application and give up if it appears frozen. My first question is how do I stop it from appearing frozen? I was looking at page 77 of wxPython in action, and it mentions Dispatch(), though I cannot work out how to use that.
My second question is, as I want to keep my GUI seperate from the rest of the program, I am importing the application.py file that contains all the functions that make up the program. These functions can be called by the GUI, but I am wondering how I would get information from application.py to gui.py. The thing I would like to do next would be to have a window popup with a progress bar. I know that I can make a progress bar with wx.Gauge (page 210 of wxpython in action), and that should not be a problem, but how do I get information from application.py to gui.py such as how many images there are, and what image it is up to? The main problem I am having is been able to communicate not from gui.py to application.py, but from application.py to gui.py, which could contain some information that is getting updated regually.
Also, am I implementing the GUI correctly? For the command line application, I basically had main.py import application.py, and that did all the user interaction with the command line, and I had no problems printing the progress to the command line, but when implementing any GUI it seems to get a bit more difficult.
Thanks, Josh.
···
–
Joshua Henderson
+61 449 128 074
joshhendo@gmail.com