113
113
], className = "mt-2" ),
114
114
115
115
html .Div (children = [
116
- dbc .Alert ("primary!" , color = "primary" , id = "alert_memory " ),
117
- dbc .Alert ("secondary!" , color = "secondary" , id = "alert_local " ),
118
- dbc .Alert ("success!" , color = "success" , id = "alert_session " ),
116
+ dbc .Alert ("primary!" , color = "primary" , id = "alert-memory " ),
117
+ dbc .Alert ("secondary!" , color = "secondary" , id = "alert-local " ),
118
+ dbc .Alert ("success!" , color = "success" , id = "alert-session " ),
119
119
dbc .Alert ("info!" , color = "info" ),
120
120
dbc .Alert ("warning!" , color = "warning" ),
121
- dbc .Alert ("danger!" , color = "danger" ),
121
+ dbc .Alert ("danger!" , color = "danger" , id = "alert-danger" , is_open = True , fade = True ),
122
122
], className = "mt-2" ),
123
123
124
124
# 按钮类 ========================================================================================
125
125
html .Div (children = [
126
- dbc .Button ("primary" , color = "primary" , className = "mr-2" , id = "button_memory " ),
127
- dbc .Button ("secondary" , color = "secondary" , className = "mr-2" , id = "button_local " ),
128
- dbc .Button ("success" , color = "success" , className = "mr-2" , id = "button_session " ),
126
+ dbc .Button ("primary" , color = "primary" , className = "mr-2" , id = "button-memory " ),
127
+ dbc .Button ("secondary" , color = "secondary" , className = "mr-2" , id = "button-local " ),
128
+ dbc .Button ("success" , color = "success" , className = "mr-2" , id = "button-session " ),
129
129
dbc .Button ("info" , color = "info" , className = "mr-2" ),
130
130
dbc .Button ("warning" , color = "warning" , className = "mr-2" ),
131
- dbc .Button ("danger" , color = "danger" , className = "mr-2" ),
131
+ dbc .Button ("danger" , color = "danger" , className = "mr-2" , id = "button-danger" ),
132
132
dbc .Button ("primary" , color = "primary" , className = "mr-2" , size = "sm" , outline = True ),
133
133
dbc .Button ("secondary" , color = "secondary" , className = "mr-2" , size = "md" , outline = True ),
134
134
dbc .Button ("success" , color = "success" , className = "mr-2" , size = "lg" , outline = True ),
177
177
], className = "mt-2" ),
178
178
179
179
html .Div (children = dcc .ConfirmDialogProvider (
180
- id = "confirm" ,
180
+ # id="confirm",
181
181
children = dbc .Button ("ConfirmDialogProvider" , color = "primary" ),
182
182
message = "Danger danger! Are you sure you want to continue?"
183
183
), className = "mt-2" ),
319
319
# 创建回调函数:回调函数中不能出现全局变量
320
320
for store in ("memory" , "local" , "session" ):
321
321
@app .callback (Output (store , "data" ), [
322
- Input ("button_ %s" % store , "n_clicks" )
322
+ Input ("button- %s" % store , "n_clicks" )
323
323
], [
324
324
State (store , "data" ),
325
325
State (store , "modified_timestamp" ),
@@ -332,7 +332,7 @@ def toggle_store_button(n_clicks, data, ts):
332
332
data ["ts" ] = ts
333
333
return data
334
334
335
- @app .callback (Output ("alert_ %s" % store , "children" ), [
335
+ @app .callback (Output ("alert- %s" % store , "children" ), [
336
336
Input (store , "modified_timestamp" )
337
337
], [
338
338
State (store , "data" ),
@@ -345,13 +345,24 @@ def toggle_store_change(ts, data, name):
345
345
return "%s: %s, ts=%s" % (name , data ["clicks" ], data ["ts" ])
346
346
347
347
348
+ @app .callback (Output ("alert-danger" , "is_open" ), [
349
+ Input ("button-danger" , "n_clicks" )
350
+ ], [
351
+ State ("alert-danger" , "is_open" )
352
+ ])
353
+ def toggle_danger_button (n_clicks , is_open ):
354
+ if n_clicks :
355
+ return not is_open
356
+ return is_open
357
+
358
+
348
359
@app .callback (Output ("collapse" , "is_open" ), [
349
360
Input ("collapse-button" , "n_clicks" )
350
361
], [
351
362
State ("collapse" , "is_open" )
352
363
])
353
- def toggle_collapse (n , is_open ):
354
- if n :
364
+ def toggle_collapse (n_clicks , is_open ):
365
+ if n_clicks :
355
366
return not is_open
356
367
return is_open
357
368
@@ -389,4 +400,4 @@ def advance_progress(n):
389
400
Input ("progress" , "value" ),
390
401
])
391
402
def advance_text (value ):
392
- return "Processtext : %d" % value
403
+ return "Process-text : %d" % value
0 commit comments