Hi,
I'm new to Monkey Studio and I decided to try it because it has a very nice GUI designer for PyQT. However, I'm struggling a bit because I know Python but I don't know much about Python packages and project organization. After reading several blog posts and advices by experienced Python developers, I decided to use this project structure:
ProjectName
|- mainPackage
|- gui
|- otherpackage
|- anotherpackage
|- bin
|- docs
main.py
That's pretty much it. mainPackage and each sub-package have a __init__.py file inside it. The main.py file is there for now, but I am planning to refactor its logic inside the bin directory later.
So far so good, but I had difficulties to start the GUI. I got an error on this line in mainPackage/gui/mainWindow.py:
( Ui_MainWindow, QMainWindow ) = uic.loadUiType( 'mainwindow.ui' )
In fact, if called from the main.py file, the working directory is different and the loading fails. What I did to get it working is to put this inside the __init__.py file of the GUI folder:
import os
# Hack the path to run the GUI
os.chdir(os.path.dirname(__file__))
Now, I think this solution is awful. Unfortunately, this is what I was able to accomplish.
I was wondering if you could suggest a better way to handle this, or a built-in MkS feature which allows to put GUI elements in sub-folders and get them to work without problems. Do you have any suggestion on this matter?
Finally, is there a way so that MkS can automatically refresh project files (e.g. if I add a file to bin, it will automatically show up as a project file in MkS)?
Thank you very much for your attention.
Best regards
Andrea Lazzarotto