我一直在努力创建一个在VisualStudio2019中使用IronPython加载文件的按钮。控制台窗口弹出1秒后消失
import wpf
clr.AddReference('IronPython.Wpf') #Add a reference for the ' System.Windows.Forms' namespace and etc..
clr.AddReference('System.IO')
clr.AddReference('Systemm.Drawing')
clr.AddReference('System.Reflection')
clr.AddReference('System.Threading')
clr.AddReference('System.Windows.Forms')
class MyWindow(Window):
def __init__(self):
wpf.LoadComponent(self, 'WpfApplication1.xaml')
def Button_Click(self, sender, e):
#Folder path of variables
FOLDER_PATH = r'C:\\Users\\Desktop\\waveform1' #Back slash will be treated as escape character
# Define a funhction to print out the file name
# Input parameter will be dir
def listDir(dir):
fileNames = os.listdir(dir)
for fileName in fileNames:
print('File Name: ' +fileName)
print('Folder Path: ' + os.path.abspath(os.path.join(dir,fileName)))
if __name__ == '__main__':
Application().Run(MyWindow())
只需在课堂外使用
if __name__ == '__main__':
我举一些例子
相关问题 更多 >
编程相关推荐