1
- Callback function documentation
1
+ 回調函數 文件
2
2
----
3
3
4
4
在 AutoControl 裡,Callback function 是由 Callback Executor 提供支援,
5
5
以下是簡易的使用 Callback Executor 的範例,
6
6
7
7
.. code-block :: python
8
+
8
9
from je_auto_control import callback_executor
9
10
# trigger_function will first to execute, but return value need to wait everything done
10
11
# so this test will first print("test") then print(size_function_return_value)
@@ -20,8 +21,6 @@ Callback function documentation
20
21
* ( 注意!,如果 callback_executor event_dict 裡面包含的 name: function 需與 executor 一樣,不一樣則是 Bug)
21
22
* (當然跟 executor 一樣可以藉由添加外部 function 來擴充,請看下面例子)
22
23
23
- -----
24
-
25
24
在這個範例裡,我們使用 callback_executor 執行定義在 AutoControl 的 size function,
26
25
然後執行完 size function 後,會去執行傳遞給 callback_function 的 function,
27
26
可以由 callback_param_method 參數來決定要使用的傳遞方法,
@@ -31,25 +30,19 @@ Callback function documentation
31
30
實際上 size -> print 順序沒錯,但此例會先看到 print 之後才是 print(size_function_return_value),
32
31
因為 size function 只有回傳值本身沒有 print 的動作。
33
32
34
- -----
35
-
36
33
如果我們想要在 callback_executor 裡面添加 function,可以使用如下:
37
34
這段程式碼會把所有 time module 的 builtin, function, method, class
38
35
載入到 callback executor,然後要使用被載入的 function 需要使用 package_function 名稱,
39
36
例如 time.sleep 會變成 time_sleep
40
37
41
- ----
42
-
43
38
.. code-block :: python
39
+
44
40
from je_auto_control import package_manager
45
41
package_manager.add_package_to_callback_executor(" time" )
46
42
47
- ----
48
-
49
43
如果你需要查看被更新的 event_dict 可以使用
50
44
51
- ----
52
-
53
45
.. code-block :: python
46
+
54
47
from je_auto_control import callback_executor
55
48
print (callback_executor.event_dict)
0 commit comments