我到处找,想看看能不能帮上忙,但一直没找到 我的程序是一个简单的tkinter菜单,设置为屏幕左上角的默认位置,但是当我按下X按钮时,它会在屏幕中央加载消息框。在
如何使其将消息框捕捉到角落?在
root = Tk()
root.geometry('%dx%d+%d+%d' % (300, 224, 0, 0))
root.resizable(0,0)
def exitroot():
if tkMessageBox.askokcancel("Quit", "Are you sure you want to quit?"):
with open(settings, 'wb') as csvfile:
writedata = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
writedata.writerow([setpass])
writedata.writerow([opcolour] + [bkcolour])
writedata.writerow([menu_background_status] + [menu_internet_status])
root.destroy()
root.protocol("WM_DELETE_WINDOW", exitroot)`
如果需要额外的代码,请让我知道,并提前感谢。在
您需要构建一个自定义的
Toplevel()
窗口,然后告诉它重新定位到根窗口的一角。我们可以用Toplevel()
类和winfo()
方法来实现这一点。在结果:
就我个人而言,我会构建继承自
^{pr2}$Tk()
的多功能类,使按钮与ttk按钮相同,并使用标签引用位于::tk::icons::question
的内置问题图像,如下所示:结果:
相关问题 更多 >
编程相关推荐