Sqetbox
(Sqetbox)
April 30, 2014, 8:51am
1
Hi There …
I’m looking for some code
how to make UI floating windows/panels for some buttons ? (such as: “blender user reference” panel)
as I know blender can make UI List, menu and panel (but the panel joined with other panels)
is it possible in blender , any idea or an example ?
Atom
(Atom)
April 30, 2014, 9:28am
2
You can make a popup but it does not float. You can not reposition or drag it around the screen.
Sqetbox
(Sqetbox)
April 30, 2014, 10:03am
3
Hi Atom, thanks for your replies
a popup … is it same with UI Menu ?
mm … I just want floating window can drag it around the screen
because every buttons for global function, not for specific category.
about popup… how to call a popup, is it with keyboard shortcut key ?
how to create shortcut by script ? any idea ?
CoDEmanX
(CoDEmanX)
April 30, 2014, 12:14pm
4
The user preferences work like this: a new blender window is opened with a single area, and that is set to type user prefs.
You can do this in script like:
import bpy
area = bpy.context.area
t = area.type
area.type = 'VIEW_3D'
bpy.ops.screen.area_dupli('INVOKE_DEFAULT')
area.type = t
This is a popup:
import bpy
def main(context):
for ob in context.scene.objects:
print(ob)
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
bl_options = {'REGISTER', 'UNDO'}
my_string = bpy.props.StringProperty("My String")
my_int = bpy.props.IntProperty("My Int")
@classmethod
def poll(cls, context):
return context.active_object is not None
def invoke(self, context, event):
return context.window_manager.invoke_props_popup(self, event)
def execute(self, context):
main(context)
return {'FINISHED'}
def register():
bpy.utils.register_class(SimpleOperator)
def unregister():
bpy.utils.unregister_class(SimpleOperator)
if __name__ == "__main__":
register()
# test call
bpy.ops.object.simple_operator('INVOKE_DEFAULT')
Sqetbox
(Sqetbox)
April 30, 2014, 6:16pm
5
thanks CoDEmanX
that’s cool, but I still confused…
where I can find the result of second script ?
I am experienced with 3dsMAXScript,
example like this:
so if Blender can make “UI menu” then I need code to create a keyboard shortcut to open UI menu.
how to create/link it to a keyboard shortcut by script ? (ie: CTRL+SHIFT+Y)
YHOYO
(YHOYO)
April 30, 2014, 6:48pm
6
Sqetbox
(Sqetbox)
April 30, 2014, 8:35pm
7
Hi YHOYO, thanks
that’s nice …
but it’s can make untidy the UI blender if I do something wrong… LOL
it’s ok, I thinking of that too
regard
Budi
CoDEmanX
(CoDEmanX)
May 1, 2014, 12:30pm
8
where I can find the result of second script ?
Run it in the text editor and it will invoke automatically, showing a props popup.
how to create/link it to a keyboard shortcut by script ? (ie: CTRL+SHIFT+Y)
http://www.blender.org/documentation/blender_python_api_2_70_4/info_tutorial_addon.html#keymap
Replace
ObjectCursorArray.bl_idname by “wm.call_menu”
and kmi.properties.total = 4 by
kmi.properties.name = “your_menu_bl_idname”
If you need an example of a menu class, see the text editor templates.
Sqetbox
(Sqetbox)
May 6, 2014, 4:02am
9
oops my fault… Im sorry, i’m not copy a whole scripts from you before
but now its works
ok great, I see your point
thank you very much
CoDEmanX