name 'QtGui' is not defined - but it is!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 2
- Joined: Fri Jan 06, 2017 2:21 pm
name 'QtGui' is not defined - but it is!
Running the latest git version, I'm getting "name 'QtGui' not defined" when trying to open the OpenSCAD workbench. Fine, one might assume something about pyside...except it's installed, and defined, as shown in the console (I ran the console command /prior/ to attempting to open the OpenSCAD workbench).
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: name 'QtGui' is not defined - but it is!
I can confirm. I can't activate OpenSCAD workbench too.
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9422 (Git)
Build type: Debug
Branch: (HEAD detached at FC/master)
Hash: 6378f611582b47840d771cdc23324a66c67d0e22
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
In contrast, here it works fine:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8361 (Git)
Build type: Release
Branch: DeepSOIC10
Hash: 4ac7673e543274bcae856872033a114c7b60481b
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9422 (Git)
Build type: Debug
Branch: (HEAD detached at FC/master)
Hash: 6378f611582b47840d771cdc23324a66c67d0e22
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
In contrast, here it works fine:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8361 (Git)
Build type: Release
Branch: DeepSOIC10
Hash: 4ac7673e543274bcae856872033a114c7b60481b
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Re: name 'QtGui' is not defined - but it is!
No problem here. Can you run this Python command in the console, please?
When it fails it should show the call stack which nay give some more hints about the reason.
Code: Select all
Gui.activateWorkbench("OpenSCADWorkbench")
-
- Posts: 2
- Joined: Fri Jan 06, 2017 2:21 pm
Re: name 'QtGui' is not defined - but it is!
I ran it, but didn't get a backtrace. Is there a debug mode or somesuch?
Re: name 'QtGui' is not defined - but it is!
I get only these warnings:wmayer wrote:No problem here. Can you run this Python command in the console, please?When it fails it should show the call stack which nay give some more hints about the reason.Code: Select all
Gui.activateWorkbench("OpenSCADWorkbench")
Code: Select all
Cannot find icon: python
Cannot find icon: python
viewtopic.php?f=3&t=19613&start=10#p151845
Re: name 'QtGui' is not defined - but it is!
When deleting my user config file then I can confirm the issue. And yes there is no stack trace but pops up the error dialog even when typing the command into the Python console.AleksClark wrote:I ran it, but didn't get a backtrace. Is there a debug mode or somesuch?
Re: name 'QtGui' is not defined - but it is!
OK, I found it: git commit bf5dcbd
Re: name 'QtGui' is not defined - but it is!
it is fine in FC 9546, but I still miss two iconswmayer wrote:OK, I found it: git commit bf5dcbd
Code: Select all
Cannot find icon: python
Cannot find icon: python
thx
Maurice
Re: name 'QtGui' is not defined - but it is!
A similar pattern is used all over the place and I'm sure it is correct, or what the correct pattern /should/ look like. As an example I use the code from SplitFeatures.py because it currently breaks running the Path unit tests from the command line:wmayer wrote:OK, I found it: git commit bf5dcbd
Code: Select all
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
#-------------------------- translation-related code ----------------------------------------
#(see forum thread "A new Part tool is being born... JoinFeatures!"
#http://forum.freecadweb.org/viewtopic.php?f=22&t=11112&start=30#p90239 )
try:
_fromUtf8 = QtCore.QString.fromUtf8
except Exception:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
Question: How should this pattern properly be implemented so it works for translation in all cases including running code from the command line?
Second question: Would it make sense to implement "translate(...)" in FreeCAD proper so every python script can just use it instead of having to duplicate the same code everywhere?
Re: name 'QtGui' is not defined - but it is!
Actually I don't see any need to implement a translate() function. It would suffice to directly use QCoreApplication.translate where the third and fourth parameter is omitted to be source compatible with Qt5.Second question: Would it make sense to implement "translate(...)" in FreeCAD proper so every python script can just use it instead of having to duplicate the same code everywhere?