-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqwer_prefs.py
50 lines (36 loc) · 1.41 KB
/
qwer_prefs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import bpy
from bpy.types import Operator, AddonPreferences
from bpy.props import BoolProperty
class QWERAddonPreferences(AddonPreferences):
# this must match the add-on name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __name__
panel_bool: BoolProperty(
name="Enable Panel",
default=False,
)
def draw(self, context):
layout = self.layout
layout.label(text="The QWER Addon Panel is convenient for assigning shortcuts")
layout.prop(self, "boolean")
row.operator('object.qwer_prefs_update', text="Update")
class OBJECT_OT_qwer_prefs_update(Operator):
"""Update QWER preferences"""
bl_idname = "object.qwer_prefs_update"
bl_label = "QWER Preferences Update"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
preferences = context.preferences
addon_prefs = preferences.addons[__name__].preferences
info = ("Boolean %r" %
(addon_prefs.panel_bool))
self.report({'INFO'}, info)
print(info)
return {'FINISHED'}
# Registration
def register():
bpy.utils.register_class(OBJECT_OT_qwer_prefs_update)
bpy.utils.register_class(QWERAddonPreferences)
def unregister():
bpy.utils.unregister_class(OBJECT_OT_qwer_prefs_update)
bpy.utils.unregister_class(QWERAddonPreferences)