Blender Addon with own qt gui

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
philiplb
Posts: 5
Joined: Tue May 17, 2011 11:38 pm

Blender Addon with own qt gui

Post by philiplb » Tue May 17, 2011 11:45 pm

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?

stiv
Posts: 3645
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv » Wed May 18, 2011 5:41 pm

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.

philiplb
Posts: 5
Joined: Tue May 17, 2011 11:38 pm

Post by philiplb » Wed May 18, 2011 6:38 pm

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.

jesterKing
Site Admin
Posts: 1848
Joined: Fri Oct 18, 2002 12:48 pm
Location: Finland

Post by jesterKing » Thu Jun 16, 2011 10:54 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest