예제 #1
0
def FileOpenDialog(initialFile=None,multiselect=False):
    dlg = OpenFileDialog()
    dlg.Multiselect = multiselect
    dlg.DefaultExt = ".txt"; # Default file extension
    dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
    if initialFile:
        dlg.InitialDirectory = System.IO.Path.GetDirectoryName(initialFile)
        dlg.FileName = System.IO.Path.GetFileName(initialFile)
        #Directory.GetParent(initialFile) #Path.GetFileName(initialFile)
    if dlg.ShowDialog() == True:
        return dlg.FileNames 
    def BtnBrowse_Click(self, sender, e):
        try:
            dlgOrg = OpenFileDialog()
            dlgOrg.Title = "Select orginal picture"
            dlgOrg.DefaultExt = ".jpg"
            dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif"

            dlgMask = OpenFileDialog()
            dlgMask.Title = "Select mask picture"
            dlgMask.DefaultExt = ".tif"
            dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif"

            if dlgOrg.ShowDialog(self):
                if dlgMask.ShowDialog(self):
                    print(dlgOrg.FileName)
                    print(dlgMask.FileName)
                    self.img.Source = BitmapImage(Uri(dlgOrg.FileName))
                    self.imgResult.Source = BitmapImage(Uri(dlgMask.FileName))
                    #import Test
        except e:
            print("Error: {}", e)
        return 0
예제 #3
0
    def OpenFileButton_Click(self, sender, e):
        dlg = OpenFileDialog()
        dlg.DefaultExt = ".txt"
        dlg.Filter = "Text Files (*.txt)|*.txt"
        dlg.Multiselect = True

        if dlg.ShowDialog() == True:
            self.file_names = dlg.FileNames
            self.combo_clear()
            self.log_clear()
            self.log_append(
                f'Successfully loaded {len(self.file_names)} stages:')

            for file_name in self.file_names:
                stem = Path.GetFileNameWithoutExtension(file_name)
                self.log_append(stem)
                self.FileComboBox.Items.Add(stem)

            self.SaveXMLButton.IsEnabled = True
            self.FileComboBox.IsEnabled = True