From 589497c086d3c4a79f3ef1e928f33093a6503b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mr=C3=A1zek?= Date: Tue, 12 Nov 2019 19:37:07 +0100 Subject: [PATCH] Add the suffix to a file if it does not have one --- elegooMarsUtility/xyCompensateGui.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/elegooMarsUtility/xyCompensateGui.py b/elegooMarsUtility/xyCompensateGui.py index 1fd38eb..7435301 100755 --- a/elegooMarsUtility/xyCompensateGui.py +++ b/elegooMarsUtility/xyCompensateGui.py @@ -6,19 +6,19 @@ import emUtility layout = [ - [sg.Text('Please enter your calibration data, input and output file')], - [sg.Text('First layer compensation:', size=(23, 1)), sg.InputText('6', size=(32, 1))], - [sg.Text('Normal layer compensation:', size=(23, 1)), sg.InputText('0', size=(32, 1))], - [sg.Text('Input file:', size=(10, 1)), sg.InputText(size=(30, 1)), sg.FileBrowse(size=(10, 1), file_types=(("CBDDLP Files", "*.cbddlp"),))], - [sg.Text('Output file:', size=(10, 1)), sg.InputText(size=(30, 1)), sg.FileSaveAs(size=(10, 1), file_types=(("CBDDLP Files", "*.cbddlp"),))], - [sg.Submit(button_text='Run', size=(25, 1)), sg.Cancel(button_text='Exit', size=(25, 1))] + [sg.Text("Please enter your calibration data, input and output file")], + [sg.Text("First layer compensation:", size=(23, 1)), sg.InputText("6", size=(32, 1))], + [sg.Text("Normal layer compensation:", size=(23, 1)), sg.InputText("0", size=(32, 1))], + [sg.Text("Input file:", size=(10, 1)), sg.InputText(size=(30, 1)), sg.FileBrowse(size=(10, 1), file_types=(("CBDDLP Files", "*.cbddlp"),))], + [sg.Text("Output file:", size=(10, 1)), sg.InputText(size=(30, 1)), sg.FileSaveAs(size=(10, 1), file_types=(("CBDDLP Files", "*.cbddlp"),))], + [sg.Submit(button_text="Run", size=(25, 1)), sg.Cancel(button_text="Exit", size=(25, 1))] ] -window = sg.Window('Elegoo Mars utility').Layout(layout) +window = sg.Window("Elegoo Mars utility").Layout(layout) while True: button, values = window.Read() - if button == 'Exit': + if button == "Exit": sys.exit(0) try: @@ -42,16 +42,18 @@ sg.Popup("Error: you have to select output file") continue outputFilename = values[3] + if not outputFilename.endswith(".cbddlp"): + outputFilename += ".cbddlp" break window.Close() -layout = [ [sg.Text('Applying the compensation')], - [sg.ProgressBar(1, orientation='h', size=(20, 20), key='progress')], +layout = [ [sg.Text("Applying the compensation")], + [sg.ProgressBar(1, orientation="h", size=(20, 20), key="progress")], ] -window = sg.Window('Window Title', layout).Finalize() -progress_bar = window.FindElement('progress') +window = sg.Window("Elegoo Mars utility", layout).Finalize() +progress_bar = window.FindElement("progress") emUtility.xyCompensate(inputFilename, normalCompensation, firstCompensation, outputFilename, lambda x, y: progress_bar.UpdateBar(x, y)) window.Close()