import tkinter as tk
def show_dialog():
choices = ['采集出库信息', '设计单位表格处理', '施工单位表格处理']
selected_values = []
def on_confirm_click():
for idx, var in enumerate(vars):
if var.get() == 1:
selected_values.append(choices[idx])
root.destroy()
def on_cancel_click():
root.destroy()
def on_close():
root.destroy()
root = tk.Tk()
root.title("请选择功能(可多选)")
root.iconbitmap('tb.ico')
window_width = 300
window_height = 200
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width - window_width) // 2
y = (screen_height - window_height) // 2
root.geometry(f"{window_width}x{window_height}+{x}+{y}")
vars = []
frame = tk.Frame(root)
frame.pack(pady=20)
for choice in choices:
var = tk.IntVar()
vars.append(var)
checkbox = tk.Checkbutton(frame, text=" " + choice, variable=var)
checkbox.pack(anchor=tk.W)
confirm_button = tk.Button(root, text="确认", command=on_confirm_click)
confirm_button.place(relx=0.5, rely=0.9, anchor=tk.CENTER, x=-50)
cancel_button = tk.Button(root, text="取消", command=on_cancel_click)
cancel_button.place(relx=0.5, rely=0.9, anchor=tk.CENTER, x=50)
root.protocol("WM_DELETE_WINDOW", on_close)
root.mainloop()
if selected_values:
return selected_values
else:
selected_values=False
return selected_values
result = show_dialog()
print(result)
插件命为:ais.py
库放置在流程的extend/python/ais.lib文件夹下。
运行import ais时报错:module 'tkinter' has no attribute 'Tk'。是我放错了还是这个Uibot不支持这个库。
这个python库是内置在python中的,但在Uibot根目录的lib/site-packages下没有这个库。
想知道是我自己存放的方法不对,还是Uibot不支持这个python库