我在尝试在主窗口顶部显示默认的tkinter askyesno对话框时遇到问题,该窗口没有边框(我正在使用overrideredirect(1)
)。在我的情况下,拥有无边框窗口是必须的。
对话框始终在主窗口后面打开。创建一个自定义对话框,也无边框似乎工作,但如果有一种方法可以使默认的askYesNo对话框出现在无边框窗口的顶部,我就会徘徊。我在Raspbian(Debian的一个版本)上运行代码。
python代码附在下面:
from Tkinter import *
from tkMessageBox import *
def imageLabelPressed():
print("Call button pressed")
selected = lb.get(whichSelected())
if (askyesno("Call", "Do you want to call %s?" % (selected) )):
print("Call started")
else:
print("Cancel call")
win = Tk()
win.geometry('800x480')
backgroundImg = PhotoImage(file = "background.png")
backgroundLabel = Label(win, image = backgroundImg)
backgroundLabel.place(x=0, y=0, relwidth=1, relheight=1)
lb=Listbox(win, height=9)
lb.pack(side = LEFT, fill = BOTH, expand = 1)
callImage = PhotoImage(file = "callButton.png")
dButt = Label(win, text = "Some text", relief = FLAT, highlightthickness = 0, border = 0, image = callImage)
dButt.bind("<Button-1>", imageLabelPressed)
dButt.pack()
win.overrideredirect(1)
mainloop()
谢谢!