【发布时间】:2017-01-20 12:10:41
【问题描述】:
这部分代码显示了已知在 tkinter 中使用的按钮
up = Radiobutton(frame1, text="up", variable=rows, value=1,indicatoron=0)#button for movingup
up.grid( row=2,column=0 )
down = Radiobutton(frame1, text="down", variable=rows, value=2,indicatoron=0)#button for moving down
down.grid( row=3,column=0 )
left = Radiobutton(frame1, text="left", variable=cols, value=3,indicatoron=0)#button for moving left
left.grid( row=2,column=4 )
right = Radiobutton(frame1, text="right", variable=cols, value=4,indicatoron=0)#button for moving #right
right.grid( row=3,column=4 )
vertical=Entry(frame1,bd=2,width=10)
vertical.grid(row=4,column=0)
horizontal=Entry(frame1,bd=2,width=10)
horizontal.grid(row=4,column=4)
enter=Button(main,text='Enter',command=move) #displays the move on grid once button is pressed
enter.pack()
label = Label(main)
label.pack()
【问题讨论】:
-
欢迎来到stackoverflow,请查看stackoverflow.com/help/how-to-ask 提出好的问题,另外,请在问题(stackoverflow.com/help/mcve)中放置一个最小、完整且可验证的示例,以便更容易看到有什么问题
-
请不要链接到其他网站上的代码。
-
您希望在按下键盘键时按下按钮,还是只想使用键盘快捷键调用按钮命令?如果是后者,请参阅infohost.nmt.edu/tcc/help/pubs/tkinter/web/events.html 关于事件和绑定。
-
键盘快捷键
标签: user-interface button tkinter