我正在使用Visual Studio代码作为Python 3的IDE。使用tkinter时,如何在Visual Studio代码之上显示任何新创建的窗口?下面是我正在使用的代码。
from tkinter import *
from tkinter.filedialog import *
def OpenFile():
ftypes=[('sqlite files','*.sqlite'),('ALL files','*')]
return askopenfilename(filetypes=ftypes)
def Main():
OpenFile()
假设您的GUI窗口变量是root,那么您以以下方式启动tkinter
root = Tk()
默认情况下,文件对话框是根窗口的子级。因此,如果将根窗口设置为系统上最顶层的窗口,则文件对话框也将出现在屏幕上所有其他窗口的上方。去做这个:
root.wm_attributes('topmost', True)
然后打电话 OpenFile()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句