我主要在Spyder工作,构建需要弹出文件夹或文件浏览窗口的脚本.
下面的代码在spyder中完美运行.在Pycharm,askopenfilename运作良好,而askdirectory什么都不做(卡住).但是,如果在调试模式下运行 - 脚本运行良好.我试图从SAS jsl运行脚本 - 同样的问题.
任何想法我该怎么办?Python 3.6 Pycharm 2017.2
谢谢.
我使用的准则包括:
import clr #pythonnet 2.3.0
import os
import tkinter as tk
from tkinter.filedialog import (askdirectory,askopenfilename)
root = tk.Tk()
root.withdraw()
PPath=askdirectory(title="Please select your installation folder location", initialdir=r"C:\Program Files\\")
t="Please select jdk file"
if os.path.exists(os.path.expanduser('~\Documents')):
FFile = askopenfilename(filetypes=(("jdk file", "*.jdk"),("All Files", "*.*")),title=t, initialdir=os.path.expanduser('~\Documents'))
else:
FFile= askopenfilename(filetypes=(("jdk file", "*.jdk"),("All Files", "*.*")),title=t)
sys.path.append(marsDllPath)
a = clr.AddReference('MatlabFunctions')
aObj = a.CreateInstance('Example.MatlabFunctions.MatLabFunctions')
Run Code Online (Sandbox Code Playgroud)
编辑:似乎与pythonnet"imoprt clr"相关的问题,但我确实在代码中需要它.