由於在CentOS AEDT開啟檔案之後,視窗無效又無法關閉,因此加上最後兩行代碼來關閉視窗。
import sys
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import DialogResult, OpenFileDialog
dialog = OpenFileDialog()
dialog.Filter = "text files (*.txt)|*.txt"
if dialog.ShowDialog() == DialogResult.OK:
txt_path = dialog.FileName
AddWarningMessage(txt_path)
else:
pass
dialog = OpenFileDialog()
dialog.Dispose()
(圖一) Linux環境開啟OpenFileDialog視窗 |
沒有留言:
張貼留言