@@ -51,6 +51,7 @@ def __init__(
51
51
keyboard_type : Keyboard ,
52
52
close_keyboard_on_send : bool ,
53
53
caption_mode : CaptionMode ,
54
+ replace : dict [str : str ] | None ,
54
55
control_position : ControlPosition | None
55
56
) -> None :
56
57
super ().__init__ (control_id , title , control_position , title_position )
@@ -62,6 +63,12 @@ def __init__(
62
63
self .cfg ["kbdType" ] = keyboard_type .value
63
64
self .cfg ["closeKbdOnSend" ] = close_keyboard_on_send
64
65
self .cfg ["captionMode" ] = caption_mode .value
66
+ if replace is not None :
67
+ for key , val in replace .items ():
68
+ for c in '\t \n ' :
69
+ if (c in key ) or (c in val ):
70
+ raise ValueError ("Bad characters '\t \n ' in replace dictionary." )
71
+ self .cfg ["replace" ] = replace
65
72
66
73
@classmethod
67
74
def from_dict (cls , cfg_dict : dict ):
@@ -88,6 +95,7 @@ def from_dict(cls, cfg_dict: dict):
88
95
_get_keyboard_type (cfg_dict ["kbdType" ]),
89
96
cfg_dict ["closeKbdOnSend" ],
90
97
_get_caption_mode (cfg_dict ["captionMode" ]),
98
+ cfg_dict ["replace" ],
91
99
ControlPosition (cfg_dict ["xPositionRatio" ], cfg_dict ["yPositionRatio" ], cfg_dict ["widthRatio" ], cfg_dict ["heightRatio" ])
92
100
)
93
101
tmp_cls .parent_id = cfg_dict ["parentID" ]
@@ -111,6 +119,7 @@ def __init__(
111
119
keyboard_type = Keyboard .ALL ,
112
120
close_keyboard_on_send = True ,
113
121
caption_mode = CaptionMode .MSG ,
122
+ replace = None ,
114
123
control_position = None ,
115
124
column_no = 1
116
125
):
@@ -143,6 +152,8 @@ def __init__(
143
152
caption_mode: CaptionMode, optional default MSG
144
153
CaptionMode.MSG is for when the caption receives messages to be displayed.
145
154
CaptionMode.SENT is when the caption shows the last message the user has entered.
155
+ replace: { str: str }
156
+ Dictionary of replacement text key value replacements to be performed by the Text box in the App.
146
157
column_no : int, optional default is 1. Must be 1..3
147
158
The Dash App reports its screen size in columns. column_no allows you to specify which column no to load into.
148
159
Each control can store three configs that define how the device looks for Dash apps installed on single column
@@ -162,6 +173,7 @@ def __init__(
162
173
keyboard_type ,
163
174
close_keyboard_on_send ,
164
175
caption_mode ,
176
+ replace ,
165
177
control_position
166
178
)
167
179
)
@@ -198,6 +210,7 @@ def from_cfg_dict(cls, cfg_dict: dict, column_no=1):
198
210
_get_keyboard_type (cfg_dict ["kbdType" ]),
199
211
cfg_dict ["closeKbdOnSend" ],
200
212
_get_caption_mode (cfg_dict ["captionMode" ]),
213
+ cfg_dict .get ("replace" ),
201
214
ControlPosition (cfg_dict ["xPositionRatio" ], cfg_dict ["yPositionRatio" ], cfg_dict ["widthRatio" ], cfg_dict ["heightRatio" ]),
202
215
column_no
203
216
)
0 commit comments