Python - Tkinter 单选按钮悬停时突出显示
Python - Tkinter Radiobuttons highlighting when hovering
我遇到的问题是 python 中的单选按钮选项的选择可以正常工作,但是如果您的光标在一定时间后(如果没有选择一个选项),这些选项会突出显示盘旋在他们身上。我不确定如何阻止这种情况发生。我在 python 2.7.
这是我的代码:
from Tkinter import *
class App:
def __init__(self,master):
frame = Frame(master)
frame.pack()
label1=Label(root, text="Choose one of the following options:")
label1.pack(padx=10)
v = IntVar()
frame3=Frame()
frame3.pack(pady=10)
self.option1=Radiobutton(frame3, text="One", variable=v, value=1).pack(side=LEFT,padx=5)
self.option2=Radiobutton(frame3, text="Two", variable=v, value=2).pack(side= LEFT,padx=5)
self.option2=Radiobutton(frame3, text="Three", variable=v, value=3).pack(side=LEFT,padx=5)
frame2=Frame()
self.submit = Button(frame2, anchor=S, text="Submit", command=self.submit_optn)
self.submit.pack(side=LEFT)
self.quitbutton = Button(frame2,anchor=S, text = "QUIT", fg="red", command=root.destroy)
self.quitbutton.pack(side=LEFT)
frame2.pack(side=BOTTOM,pady=5)
def submit_optn(self):
top=Toplevel()
top.title("submit")
label2=Label(top, text="Choice submitted")
label2.pack(padx=20,pady=10)
root = Tk()
root.geometry("300x100")
app = App(root)
root.mainloop()
谢谢:)
将 v
更改为 self.v
,同样将单选按钮中的 v
更改为 self.v
。
正在收集垃圾
我遇到的问题是 python 中的单选按钮选项的选择可以正常工作,但是如果您的光标在一定时间后(如果没有选择一个选项),这些选项会突出显示盘旋在他们身上。我不确定如何阻止这种情况发生。我在 python 2.7.
这是我的代码:
from Tkinter import *
class App:
def __init__(self,master):
frame = Frame(master)
frame.pack()
label1=Label(root, text="Choose one of the following options:")
label1.pack(padx=10)
v = IntVar()
frame3=Frame()
frame3.pack(pady=10)
self.option1=Radiobutton(frame3, text="One", variable=v, value=1).pack(side=LEFT,padx=5)
self.option2=Radiobutton(frame3, text="Two", variable=v, value=2).pack(side= LEFT,padx=5)
self.option2=Radiobutton(frame3, text="Three", variable=v, value=3).pack(side=LEFT,padx=5)
frame2=Frame()
self.submit = Button(frame2, anchor=S, text="Submit", command=self.submit_optn)
self.submit.pack(side=LEFT)
self.quitbutton = Button(frame2,anchor=S, text = "QUIT", fg="red", command=root.destroy)
self.quitbutton.pack(side=LEFT)
frame2.pack(side=BOTTOM,pady=5)
def submit_optn(self):
top=Toplevel()
top.title("submit")
label2=Label(top, text="Choice submitted")
label2.pack(padx=20,pady=10)
root = Tk()
root.geometry("300x100")
app = App(root)
root.mainloop()
谢谢:)
将 v
更改为 self.v
,同样将单选按钮中的 v
更改为 self.v
。
正在收集垃圾