def folder_tb_PreviewMouseDoubleClick(self, sender, e): dialog = FolderBrowserDialog() if self.folder_tb: dialog.SelectedPath = self.folder_tb.Text else: dialog.SelectedPath = 'c:\\' if dialog.ShowDialog() == DialogResult.OK: self.folder_tb.Text = dialog.SelectedPath else: pass
def DirectoryOpenDialog(initialDirectory=None): dlg = FolderBrowserDialog() dlg.ShowNewFolderButton = True if initialDirectory: dlg.SelectedPath = initialDirectory #Path.GetFileName(initialFile) if dlg.ShowDialog() != DialogResult.Cancel: return dlg.SelectedPath
def win_dialog_thread(arg): print(f"dialog_thread started") folder_dialog = FolderBrowserDialog() file_dialog = OpenFileDialog() title = arg.Dequeue() initial_folder = arg.Dequeue() print(f"title: {title}, initial_folder: {initial_folder}") folder_dialog.Description = title folder_dialog.SelectedPath = initial_folder folder_dialog_result = folder_dialog.ShowDialog() file_dialog_result = file_dialog.ShowDialog() selected_folder = folder_dialog.SelectedPath selected_file = file_dialog.FileName win_dialog_result = selected_folder, selected_file arg.Enqueue(win_dialog_result) print(f"win_dialog_thread completed, {win_dialog_result}")
def win_dialog_thread(arg): print(f"dialog_thread started") folder_dialog = FolderBrowserDialog() file_dialog = OpenFileDialog() title = arg.Dequeue() initial_folder = arg.Dequeue() print(f"title: {title}, initial_folder: {initial_folder}") folder_dialog.Description = title folder_dialog.SelectedPath = initial_folder folder_dialog_result = folder_dialog.ShowDialog() file_dialog_result = file_dialog.ShowDialog() selected_folder = folder_dialog.SelectedPath selected_file = file_dialog.FileName win_dialog_result = selected_folder, selected_file arg.Enqueue(win_dialog_result) print(f"win_dialog_thread completed, {win_dialog_result}")
def browse(self, sender, event): dialog = FolderBrowserDialog() dialog.SelectedPath = os.environ["USERPROFILE"] + "\\" if (dialog.ShowDialog(self) == DialogResult.OK): self.KeyPath.Text = dialog.SelectedPath
'C:/Program Files/AnsysEM/AnsysEM19.4/Win64/common/IronPython/DLLs') sys.path.append( 'C:/Program Files/AnsysEM/AnsysEM19.5/Win64/common/IronPython/DLLs') sys.path.append( 'C:/Program Files/AnsysEM/AnsysEM20.1/Win64/common/IronPython/DLLs') sys.path.append( 'C:/Program Files/AnsysEM/AnsysEM20.2/Win64/common/IronPython/DLLs') clr.AddReference('IronPython.Wpf') from System.Windows.Forms import FolderBrowserDialog, DialogResult import ScriptEnv ScriptEnv.Initialize("Ansoft.ElectronicsDesktop") oDesktop.RestoreWindow() oProject = oDesktop.GetActiveProject() oDesign = oProject.GetActiveDesign() oModule = oDesign.GetModule("ReportSetup") dialog = FolderBrowserDialog() project_folder = os.path.dirname(oProject.GetPath()).replace('/', '\\') dialog.SelectedPath = project_folder if dialog.ShowDialog() == DialogResult.OK: path = dialog.SelectedPath for report in oModule.GetAllReportNames(): AddWarningMessage("Export {}.jpg".format(report)) oModule.ExportImageToFile(report, "{}/{}.jpg".format(path, report), 8000, 4000) else: pass
# ---------------------------------------------- # Script Recorded by ANSYS Electronics Desktop Version 2020.1.0 # 20:37:40 Jun 11, 2020 # ---------------------------------------------- import clr, sys sys.path.append('C:/Program Files/AnsysEM/AnsysEM19.5/Win64/common/IronPython/DLLs') sys.path.append('C:/Program Files/AnsysEM/AnsysEM20.1/Win64/common/IronPython/DLLs') clr.AddReference('IronPython.Wpf') from System.Windows.Forms import FolderBrowserDialog, DialogResult dialog = FolderBrowserDialog() dialog.SelectedPath = 'c:\\' if dialog.ShowDialog() == DialogResult.OK: selected_folder = dialog.SelectedPath AddWarningMessage(selected_folder) else: pass