Page Menu
Home
Search
Configure Global Search
Log In
Files
F13498627
test_activate_init.py
David Friedli (hlorus)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
David Friedli (hlorus)
Sep 16 2022, 10:16 AM
Size
1 KB
Subscribers
None
test_activate_init.py
View Options
import
bpy
from
bpy.types
import
Panel
class
MyPanel
(
Panel
):
bl_space_type
=
'TOPBAR'
# dummy
bl_region_type
=
'HEADER'
bl_label
=
"Rename Active Item"
bl_ui_units_x
=
14
def
draw
(
self
,
context
):
layout
=
self
.
layout
row
=
layout
.
row
()
row
.
activate_init
=
True
ob
=
context
.
active_object
# Works
#row.prop(ob, "name")
# Doesn't work
row
.
prop
(
ob
,
"pass_index"
)
class
SimpleOperator
(
bpy
.
types
.
Operator
):
"""Tooltip"""
bl_idname
=
"object.simple_operator"
bl_label
=
"Simple Object Operator"
@classmethod
def
poll
(
cls
,
context
):
return
context
.
active_object
is
not
None
def
execute
(
self
,
context
):
from
bl_ui.space_topbar
import
TOPBAR_PT_name
bpy
.
ops
.
wm
.
call_panel
(
name
=
"MyPanel"
)
return
{
'FINISHED'
}
def
menu_func
(
self
,
context
):
self
.
layout
.
operator
(
SimpleOperator
.
bl_idname
,
text
=
SimpleOperator
.
bl_label
)
def
register
():
bpy
.
utils
.
register_class
(
MyPanel
)
bpy
.
utils
.
register_class
(
SimpleOperator
)
bpy
.
types
.
VIEW3D_MT_object
.
append
(
menu_func
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
SimpleOperator
)
bpy
.
types
.
VIEW3D_MT_object
.
remove
(
menu_func
)
bpy
.
utils
.
unregister_class
(
MyPanel
)
if
__name__
==
"__main__"
:
register
()
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bf/af/9631eb9820769b9eaab4accf559a
Attached To
T101113: UI: activate_init doesn't work with Int and Float type properties
Event Timeline
Log In to Comment