|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是一个单选自动阅卷系统,部分代码如下
- def create_answer_window():
- if messagebox.askokcancel("须知", "我已阅读考试相关说明"):
- answer_root = Toplevel()
- answer_root.title("正在答题...")
- answer_root.geometry("400x100")
- answer_root.resizable(FALSE,FALSE)
- Label(answer_root, text="请输入答题数目>>", font=('heiti', 14)).place(x=20,y=10)
- question_num = StringVar()
- Entry(answer_root,textvariable=question_num,width=10).place(x=180,y=12)
- [color=Red] num = question_num.get()[/color]
- def answer_qusetion():
- if num != None:
- # answer_root.destroy()
- print(num)
- aq_root = Toplevel()
- aq_root.title("正在答题...")
- aq_root.iconbitmap('./img.ico')
- aq_root.geometry("400x400")
- aq_root.resizable(FALSE, FALSE)
- Label(aq_root, text="题目>>", font=('heiti', 14)).place(x=20, y=10)
- print(num)
- else:
- messagebox.showerror("Error", "Not null")
- # 获取excle中最大行,通过random(1,max_row)随机选择试题
- # workbook = openpyxl.load_workbook('./题库.xlsx')
- # worksheet = workbook.active
- # max = worksheet.max_row
- button_4 = Button(answer_root, text='Start',bg="gray",width=20, command=answer_qusetion).place(x=200,y=50)
- else:
- messagebox.showerror("Error","请阅读相关考试说明")
复制代码
问题是这样的通过num = question_num.get()获取用户输入后,想判断是否为空,不为空则销毁这个窗口,进入答题界面,现在这个num变量传不到answer_qusetion():这个函数里,请问有什么办法吗?
- btn_close=Button(window_close,text="关闭案例",font=("ArialBold",30),bg="red",command=lambda:Closewindows(window_close,a))#command事件的传参
复制代码
command传参用这样的形式试试看,command=lambda:函数(参数)
|
|