techartorg / bqt

A Blender add-on to support & manage Qt Widgets in Blender (PySide2)
https://github.com/techartorg/bqt/wiki
Mozilla Public License 2.0
172 stars 25 forks source link

Getting Icon fails on windows when blender is executed from command line #5

Closed cmcpasserby closed 4 years ago

cmcpasserby commented 4 years ago

when i execute blender via the CLI the call to find the blender icons fails

blender.exe --debug --python bqt.py

Traceback (most recent call last):
  File "E:\projects\rsg\bqt\bqt.py", line 318, in execute
    self.__qapp = instantiate_application()
  File "E:\projects\rsg\bqt\bqt.py", line 342, in instantiate_application
    app = BlenderApplication(sys.argv)
  File "E:\projects\rsg\bqt\bqt.py", line 93, in __init__
    icon = self._get_application_icon_windows()
  File "E:\projects\rsg\bqt\bqt.py", line 253, in _get_application_icon_windows
    hdc.DrawIcon((0, 0), large[0])
IndexError: list index out of range
bob-white commented 4 years ago

So bqt.py is designed to be run as a startup script. Not sure how the execution model differs when run directly like that.

I also get an error, but related to operators registration not the icon code:

found bundled python: e:\Blender\2.80\python
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "e:\Blender\bqt.py", line 408, in <module>
    unregister()
  File "e:\Blender\bqt.py", line 381, in unregister
    bpy.utils.unregister_class(QOperator)
RuntimeError: unregister_class(...):, missing bl_rna attribute from 'RNAMeta' instance (may not be registered)
cmcpasserby commented 4 years ago

@bob-white well the block that calls unregister only runs if you execute the script from the cli to start blender, so i feel it is just running too early

bob-white commented 4 years ago

You are correct, if I remove that block I no longer get the error. Also, I still don't get the error that you are. I tried this both in an admin console, and a non-elevated console so I don't believe this is a permissions issue.

JeffHanna commented 4 years ago

I don't get the IndexError. But the Blender frame is without an icon.

bob-white commented 4 years ago

So poking around with this, it appears loading the bytes from GetBitmapBits into a QImage or QPixmap just doesn't work. It will work with a PIL.Image though. So its probably some kind of formatting thing.

cmcpasserby commented 4 years ago

likely just something simple like needing to go into a QByteArray first instead of a python list. though i think we can kill off the code for finding the process. since bpy.app.binary_path will just give you the blender exe directly

JeffHanna commented 4 years ago

The latest commit uses bpy.app.binary_path to get the path to the blender.exe. The code to step through running Windows processes to find the blender.exe has been removed.

JeffHanna commented 4 years ago

With my latest change I successfully get an application icon when starting Blender from a command prompt using the "blender.exe --debug --python bqt.exe" command posted above.

Closing.