Page 1 of 1

Blender Addon with own qt gui

Posted: Tue May 17, 2011 11:45 pm
by philiplb
Hi,
currently, I'm trying to write a Blender with it's own native gui.
For this, I've written an Python extension in C++ which offers a function to show the qt gui until it's closed.
I know, I should use Blenders own UI, but for this case, it's more or less needed to have our own gui. :)
It works fine so far, the gui is just one form with an edit and a button, asking for a name. After the button is clicked, the gui closes and the python extension function returns the entered string. This string is displayed like then. All in all, all Python code so far is this:

Code: Select all

    def execute(self, context):
        self.report({'WARNING'}, "Hello " + hellopython.foo() + "!")
        return {'FINISHED'}
But now the interesting part (for me, as I'm not yet that familar with blenders API): Assume I want a slider in the qt gui which controls the rotation of the selected blender object and I want to update blenders view in realtime (rotating the object as soon as I move the qt slider), how could I do this in Python and what callback could I use? Is there a function like draw in bpy.types.Operator to override for example in which I always ask the qt gui about the slider state and rotate the model according to it?

Posted: Wed May 18, 2011 5:41 pm
by stiv
The general problem with schemes like this is there are two event loops - Blender's and your own GUI's. As long as just one of them is running at a time, (open a window, click on something, window closes) life is good. Getting both loops to run together in an interactive way is....challenging. But possibly easier with the 2.5x architecture.

Posted: Wed May 18, 2011 6:38 pm
by philiplb
Yep, this is what I guess, too. :)
Is there a Python call which lets Blender process his loop one step?
Something like
bpy.continue()
If so, I could call it from the C++ Extension regulary.

Posted: Thu Jun 16, 2011 10:54 pm
by jesterKing
I'd make a modal operator that is triggered on a timer event (addable through python as well), and then read out input from a pipe.

See the text editor script templates for the timer example.

/Nathan