+ fix gui (WIP)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ debug.py
|
|||||||
build/
|
build/
|
||||||
run.spec
|
run.spec
|
||||||
dist/
|
dist/
|
||||||
|
.vscode/launch.json
|
||||||
|
|||||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -8,7 +8,7 @@
|
|||||||
"name": "Python: Aktuelle Datei",
|
"name": "Python: Aktuelle Datei",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "debug.py",
|
"program": "run.py",
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
43
gui/gui.py
43
gui/gui.py
@@ -1,6 +1,7 @@
|
|||||||
from gui.utils import nassi, output, file_there
|
from gui.utils import nassi, output, file_there
|
||||||
from interpreter.interpret_source import JavaSyntaxError, ScopeNotFoundException, InterpreterException
|
from interpreter.interpret_source import JavaSyntaxError, ScopeNotFoundException, InterpreterException
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import os.path
|
import os.path
|
||||||
import random
|
import random
|
||||||
@@ -102,22 +103,22 @@ class Gui:
|
|||||||
|
|
||||||
text_column = [
|
text_column = [
|
||||||
[
|
[
|
||||||
sg.Text()
|
sg.Text('What should the program do if a file already exists?')
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
choices = [
|
choices = [
|
||||||
[
|
[
|
||||||
sg.Button(button_text='Skip'),
|
sg.Button(button_text='skip', key='-SKIP-'),
|
||||||
sg.Button(button_text='Overwrite'),
|
sg.Button(button_text='overwrite', key='-OVERWRITE-'),
|
||||||
sg.Button(),
|
sg.Button(button_text='create expicit name', key='-EXPICIT-'),
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
layout_popup = [
|
layout_popup = [
|
||||||
[
|
[
|
||||||
sg.Column(text_column),
|
sg.Column(text_column),
|
||||||
|
sg.Column(choices),
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -130,6 +131,11 @@ class Gui:
|
|||||||
|
|
||||||
def show_gui(self, window: sg.Window, popup_3_choice: sg.Window):
|
def show_gui(self, window: sg.Window, popup_3_choice: sg.Window):
|
||||||
|
|
||||||
|
class Overwrite_behaviour(IntEnum):
|
||||||
|
SKIP = 0
|
||||||
|
OVERWWRITE = 1
|
||||||
|
RANDOM_NAME = 2
|
||||||
|
|
||||||
font_filepath = None
|
font_filepath = None
|
||||||
output_name = None
|
output_name = None
|
||||||
|
|
||||||
@@ -146,7 +152,15 @@ class Gui:
|
|||||||
|
|
||||||
# execute Column
|
# execute Column
|
||||||
if event == '-CREATE-':
|
if event == '-CREATE-':
|
||||||
popup_3_choice.read()
|
event_popup, values_popup = popup_3_choice.read()
|
||||||
|
while event_popup != '-OVERWRITE-' or event_popup != '-EXPICIT-' or event_popup != '-SKIP-':
|
||||||
|
if event_popup is '-OVERWRITE-':
|
||||||
|
exists_choice = Overwrite_behaviour(1)
|
||||||
|
if event_popup is '-EXPICIT-':
|
||||||
|
exists_choice = Overwrite_behaviour(2)
|
||||||
|
if event_popup is '-SKIP-':
|
||||||
|
exists_choice = Overwrite_behaviour(0)
|
||||||
|
break
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
'values = ' + str(values)))
|
'values = ' + str(values)))
|
||||||
try:
|
try:
|
||||||
@@ -161,18 +175,15 @@ class Gui:
|
|||||||
if output_name is None:
|
if output_name is None:
|
||||||
sg.popup_auto_close('You didn\'t set a name for the image, it will be named randomly.')
|
sg.popup_auto_close('You didn\'t set a name for the image, it will be named randomly.')
|
||||||
output_name = secrets.token_hex(16)
|
output_name = secrets.token_hex(16)
|
||||||
if file_there((output_path + '/')) is True:
|
#if file_there((output_path + '/')) is True:
|
||||||
proceed = sg.popup_yes_no(
|
|
||||||
'''What should the program do if a file already exists?
|
nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self,
|
||||||
''')
|
font_filepath=font_filepath, behaviour=exists_choice)
|
||||||
popup_3_choice.read()
|
|
||||||
nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self,
|
|
||||||
font_filepath=font_filepath)
|
|
||||||
|
|
||||||
fnames = output(values)
|
fnames = output(values)
|
||||||
sg.popup_annoying('Successfully created!', title='Created',
|
sg.popup_annoying('Successfully created!', title='Created',
|
||||||
auto_close_duration=2, auto_close=True, text_color='green')
|
auto_close_duration=2, auto_close=True, text_color='green')
|
||||||
window['-OUTPUT FILE LIST-'].update(fnames)
|
window['-OUTPUT FILE LIST-'].update(fnames)
|
||||||
|
|
||||||
except JavaSyntaxError as JsE:
|
except JavaSyntaxError as JsE:
|
||||||
logging.error(
|
logging.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user