optimamodel / optima-tb

Optima TB-UCL model
GNU Lesser General Public License v3.0
2 stars 0 forks source link

Unable to generate Project via GUI #90

Closed critcortex closed 7 years ago

critcortex commented 7 years ago

Unable to generate a new project via GUI - problem seems to be in the Qt choosing the cascade file location correctly.

Running from redesign branch on a Mac OSX (no anaconda)

Steps to reproduce:

  1. Run gui_south_africa.py in corresponding folder in tb-ucl-analyses
  2. GUI home screen correctly appears listing options ('Manual calibration', 'Parameter Scenario', 'Budget Scenario')
  3. Selected 'Manual Calibration' and go into new pane
  4. From menu, select Project --> 'Create Project'
  5. After asked to choose a cascade file, from the file chooser, choose the correct file
  6. Error - with freezing of GUI

See screenshot to see resulting error message at the bottom of the pane:

screen shot 2017-06-22 at 16 44 53

Also, I went into gui.py to see what file was selected by the file chooser (thinking that it could be a file path problem).

for line 142 in createProject(), I added a print statement, i.e.

            cascade_path = qtw.QFileDialog.getOpenFileName(self, 'Select Cascade File')[0]
            print cascade_path, "<------- cascade path"

which gave the output of:

/ <------- cascade path
critcortex commented 7 years ago

@hussainazfar , do you also encounter this? I'm trying to work out whether it's an anaconda thing or an os thing, or a qt thing ...

critcortex commented 7 years ago

Bah ... it looks like it's a Qt thing. Kedz, you detail which Python version and Qt version is on your system pls?

For me,

$ qmake --version
Using Qt version 5.6.0 in /Users/sjarvis/programs/anaconda2/lib
$ python --version
Python 2.7.12 :: Anaconda 4.2.0 (x86_64)
davidkedz commented 7 years ago

@critcortex: Ah. This seems familiar. Cliff struggled to get the GUI working on his end for the same reason. For info, I'm running with: AnaPython 2.7.13 | Anaconda 4.3.1 (64-bit) As well as: QMake version 3.0 | Using Qt version 5.6.2 in C:/ProgramData/Anaconda2/Library/lib But yes, whenever I use qtw.QFileDialog.getOpenFileName(), it returns a tuple like: (u'D:/Projects - Work/Optima/tb-ucl-analyses/belarus/Cascade Spreadsheets/cascade-belarus.xlsx', u'') This is why I extract the zeroth index to get cascade_path (et al.) On your system (and Cliff's) the return may be something different. Perhaps just a string? In Cliff's case, I assumed it was because he was trying to get the GUI working with PyQt4, but your output seems to suggest you're using PyQt5...

davidkedz commented 7 years ago

@critcortex: To extend that comment, I found this on the internets: "If you read the differences between PyQt4 and PyQt5, you will see that getOpenFileName is now the new name for getOpenFileNameAndFilter, which returns a tuple (filename, selected filter). Thus to get the filename, you need the first element of the tuple." I have thus made a commit with try/except clauses that should hopefully work for either v4 or v5. It continues to work on my system, but I'm happy for another system to test it too (although @cliffckerr will probably do that anyway as he's wedded to PyQt4). However, as a side note, your Python interpreter must not be registering PyQt5 somehow if you're crashing with that issue. It could be a linking issue or something odd with Cliff's importPyQt function on your end.

critcortex commented 7 years ago

But yes, whenever I use qtw.QFileDialog.getOpenFileName(), it returns a tuple like: (u'D:/Projects - Work/Optima/tb-ucl-analyses/belarus/Cascade Spreadsheets/cascade-belarus.xlsx', u'') This is why I extract the zeroth index to get cascade_path (et al.) On your system (and Cliff's) the return may be something different. Perhaps just a string?

Aye, as per my edit to gui.py in the above comment, it returns / i.e. an empty path.

I'll try updating to match your Qt version and see where that gets me ...

critcortex commented 7 years ago

This was fixed with Qt version wrangling