Commit 1ee7f9ec authored by Bruno Laurencich's avatar Bruno Laurencich

panel redraw working

parent 9d13b1aa
*.sublime*
*.blend[0-9]
__pycache__
\ No newline at end of file
......@@ -32,7 +32,10 @@ class Chord_Get_Ip(bpy.types.Operator):
bl_label = "Chordata: get notochord ip"
bl_options = {'REGISTER'}
# ----------- MODAL -----------
# ----------- PROPS -----------
# ----------- MODAL -----------
def modal(self, context, event):
if event.type in {'RIGHTMOUSE', 'ESC'}:
......@@ -40,33 +43,25 @@ class Chord_Get_Ip(bpy.types.Operator):
return {'CANCELLED'}
if event.type == 'TIMER':
context.object.rotation_euler.y += 0.2
context.window_manager.some_number += 1
if context.window_manager.some_number%3 == 0:
context.window_manager.chordata.state = "Disconnected"
elif context.window_manager.some_number%3 == 1:
context.window_manager.chordata.state = "Searching.."
elif context.window_manager.some_number%3 == 2:
context.window_manager.chordata.state = "Connected"
context.area.tag_redraw()
if self.query_thread.is_alive():
print("ip query ongoing..")
# context.window_manager.chordata.state = possible_states()[1][0]
self.chord_global.state = possible_states()[1][0]
else:
# context.window_manager.chordata.state = possible_states()[2][0]
with self.query_lock:
if self.found_ip:
self.chord_global.state = possible_states()[2][0]
else:
self.chord_global.state = possible_states()[0][0]
print("IP found :", self.found_ip)
self.cancel(context)
return {'FINISHED'}
return {'PASS_THROUGH'}
# ----------- DO QUERY (thread handler) -----------
# ----------- DO QUERY (thread handler) -----------
def do_query(self):
print("query thread running")
......@@ -85,16 +80,16 @@ class Chord_Get_Ip(bpy.types.Operator):
print("*** Thread terminating..")
return
# ----------- EXECUTE -----------
# ----------- EXECUTE -----------
def execute(self, context):
context.window_manager.chordata.state = possible_states()[0][0]
self.chord_global = context.window_manager.chordata
self.chord_global.state = possible_states()[0][0]
wm = context.window_manager
self._timer = wm.event_timer_add(0.5, context.window)
wm.modal_handler_add(self)
print(mdns.myRes)
self.query_lock = threading.Lock()
self.found_ip = False
self.query_thread = threading.Thread(target=self.do_query,
......@@ -103,7 +98,7 @@ class Chord_Get_Ip(bpy.types.Operator):
return {'RUNNING_MODAL'}
# ----------- CANCEL -----------
# ----------- CANCEL -----------
def cancel(self, context):
wm = context.window_manager
......@@ -125,18 +120,12 @@ def possible_states():
[(identifier, name, description, icon, number), ...]
complete doc in:
https://docs.blender.org/api/blender_python_api_2_77_0/bpy.props.html#bpy.props.EnumProperty """
return [
("Disconnected", "no-conn", "", "COLOR_RED", 1),
("Searching..", "search", "", "INLINK", 2),
("Connected", "conn", "", "COLOR_GREEN", 3)
]
("Disconnected", "no-conn", "", "COLOR_RED", 1),
("Searching..", "search", "", "INLINK", 2),
("Connected", "conn", "", "COLOR_GREEN", 3)
]
def get_state(self):
# print("GETTER")
# print(self)
# print(self.state)
return bpy.types.Chord_Properties.bl_rna.properties['state'].enum_items[self.state].value
# Create a collection to hold all the chordata properies
class Chord_Properties(bpy.types.PropertyGroup):
......@@ -150,16 +139,9 @@ def register():
bpy.utils.register_class(Chord_Properties)
WindowManager.chordata = \
bpy.props.PointerProperty(type=Chord_Properties)
WindowManager.some_number = \
bpy.props.IntProperty()
bpy.utils.register_module(__name__)
def unregister():
# bpy.utils.unregister_class(Chord_Get_Ip)
bpy.utils.unregister_module(__name__)
......
......@@ -21,8 +21,7 @@ class Chord_tools_panel(bpy.types.Panel):
layout = self.layout
layout.operator("chordata.get_ip", "Connect")
layout.prop(context.window_manager, "some_number")
layout.prop(context.window_manager.chordata, "state", expand=True)
# layout.prop(context.window_manager.chordata, "state", expand=True)
layout.label(context.window_manager.chordata.state,\
icon= get_conn_state_attr(context, "icon"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment