small changes -> layout
This commit is contained in:
43
gui/gui.py
43
gui/gui.py
@@ -14,17 +14,20 @@ import time
|
|||||||
class Gui:
|
class Gui:
|
||||||
|
|
||||||
def __init__(self, theme: str, debug_mode: bool):
|
def __init__(self, theme: str, debug_mode: bool):
|
||||||
|
# Constructor of the gui
|
||||||
self.debug_mode = debug_mode
|
self.debug_mode = debug_mode
|
||||||
window = self.init_gui(theme=theme)
|
window = self.init_gui(theme=theme)
|
||||||
self.show_gui(window=window)
|
self.gui_handler(window=window)
|
||||||
|
|
||||||
def get_debug_mode(self, mode: bool):
|
def get_debug_mode(self, mode: bool):
|
||||||
|
# init the Logging module
|
||||||
loging_level = logging.INFO
|
loging_level = logging.INFO
|
||||||
if mode:
|
if mode:
|
||||||
loging_level = logging.DEBUG
|
loging_level = logging.DEBUG
|
||||||
logging.basicConfig(level=loging_level)
|
logging.basicConfig(level=loging_level)
|
||||||
|
|
||||||
def init_gui(self, theme: str):
|
def init_gui(self, theme: str):
|
||||||
|
# init main window
|
||||||
self.get_debug_mode(self.debug_mode)
|
self.get_debug_mode(self.debug_mode)
|
||||||
|
|
||||||
sg.theme(theme)
|
sg.theme(theme)
|
||||||
@@ -35,7 +38,9 @@ class Gui:
|
|||||||
|
|
||||||
return window
|
return window
|
||||||
|
|
||||||
def show_gui(self, window: sg.Window):
|
def gui_handler(self, window: sg.Window):
|
||||||
|
# handler for the gui
|
||||||
|
|
||||||
|
|
||||||
font_filepath = None
|
font_filepath = None
|
||||||
output_name = None
|
output_name = None
|
||||||
@@ -60,7 +65,7 @@ class Gui:
|
|||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
'values = ' + str(values)))
|
'values = ' + str(values)))
|
||||||
try:
|
try:
|
||||||
if values['-JAVA FOLDER-'] and values['-OUTPUT FOLDER-']:
|
if values['-JAVA IN-'] and values['-OUTPUT FOLDER-']:
|
||||||
logging.debug(
|
logging.debug(
|
||||||
('Try create Image with values = ' + str(values)))
|
('Try create Image with values = ' + str(values)))
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ class Gui:
|
|||||||
popup_3_choice.close()
|
popup_3_choice.close()
|
||||||
try:
|
try:
|
||||||
file_path = os.path.join(
|
file_path = os.path.join(
|
||||||
values["-JAVA FOLDER-"],
|
values["-JAVA IN-"],
|
||||||
)
|
)
|
||||||
output_path = values['-OUTPUT FOLDER-']
|
output_path = values['-OUTPUT FOLDER-']
|
||||||
if output_name is None:
|
if output_name is None:
|
||||||
@@ -123,7 +128,7 @@ class Gui:
|
|||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
elif values['-JAVA FOLDER-']:
|
elif values['-JAVA IN-']:
|
||||||
sg.popup_annoying('No Output', title='Error',
|
sg.popup_annoying('No Output', title='Error',
|
||||||
auto_close_duration=5, auto_close=True)
|
auto_close_duration=5, auto_close=True)
|
||||||
elif values['-OUTPUT FOLDER-']:
|
elif values['-OUTPUT FOLDER-']:
|
||||||
@@ -135,10 +140,12 @@ class Gui:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# handle event credits
|
||||||
if event == '-CREDITS-':
|
if event == '-CREDITS-':
|
||||||
sg.popup(
|
sg.popup(
|
||||||
'This was made by plexx(Image generation), Weckyy702(Interpreter) and oleting(Frontend). Used Python 3.9.1, Libraries PySimpleGUI and Pillow.', title='Credits')
|
'This was made by plexx(Image generation), Weckyy702(Interpreter) and oleting(Frontend). Used Python 3.9.1, Libraries PySimpleGUI and Pillow.', title='Credits')
|
||||||
|
|
||||||
|
# handle fun feature
|
||||||
if event == '-DONATE-':
|
if event == '-DONATE-':
|
||||||
logging.debug(('event = ' + str(event)))
|
logging.debug(('event = ' + str(event)))
|
||||||
sg.popup_notify(
|
sg.popup_notify(
|
||||||
@@ -147,6 +154,7 @@ class Gui:
|
|||||||
|
|
||||||
# needed Input
|
# needed Input
|
||||||
|
|
||||||
|
# handle event select output folder
|
||||||
if event == '-OUTPUT FOLDER-':
|
if event == '-OUTPUT FOLDER-':
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
' value = ' + str(values['-OUTPUT FOLDER-'])))
|
' value = ' + str(values['-OUTPUT FOLDER-'])))
|
||||||
@@ -171,17 +179,20 @@ class Gui:
|
|||||||
logging.error('Try to open a .png. Unknown error.')
|
logging.error('Try to open a .png. Unknown error.')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if event == '-JAVA FOLDER-':
|
# handle event select Java File
|
||||||
|
if event == '-JAVA IN-':
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
' value = ' + str(values['-JAVA FOLDER-'])))
|
' value = ' + str(values['-JAVA IN-'])))
|
||||||
folder = values['-JAVA FOLDER-']
|
folder = values['-JAVA IN-']
|
||||||
window['-JAVA FOLDER-'].update(values['-JAVA FILE-'])
|
window['-JAVA IN-'].update(values['-JAVA FILE-'])
|
||||||
|
|
||||||
# optional Input
|
# optional Input
|
||||||
|
|
||||||
|
# handle event custom folder name
|
||||||
if event == '-OUTPUT NAME-':
|
if event == '-OUTPUT NAME-':
|
||||||
output_name = values['-OUTPUT NAME-']
|
output_name = values['-OUTPUT NAME-']
|
||||||
|
|
||||||
|
# handle event own font
|
||||||
if event == '-TTF FOLDER-':
|
if event == '-TTF FOLDER-':
|
||||||
logging.debug(('event = ' + str(event) +
|
logging.debug(('event = ' + str(event) +
|
||||||
' value = ' + str(values['-TTF FOLDER-'])))
|
' value = ' + str(values['-TTF FOLDER-'])))
|
||||||
@@ -189,8 +200,8 @@ class Gui:
|
|||||||
window['-TTF FOLDER-'].update(values['-TTF FILE-'])
|
window['-TTF FOLDER-'].update(values['-TTF FILE-'])
|
||||||
font_filepath = values['-TTF FILE-']
|
font_filepath = values['-TTF FILE-']
|
||||||
|
|
||||||
|
# handle event add a keyword with categorie types
|
||||||
if event == '-TYPES-':
|
if event == '-TYPES-':
|
||||||
#
|
|
||||||
raw_types = sg.popup_get_text('Enter customn keywords (int, double, ...): ', default_text=types)
|
raw_types = sg.popup_get_text('Enter customn keywords (int, double, ...): ', default_text=types)
|
||||||
try:
|
try:
|
||||||
raw_types = raw_types.replace(' ', '')
|
raw_types = raw_types.replace(' ', '')
|
||||||
@@ -198,6 +209,7 @@ class Gui:
|
|||||||
except:
|
except:
|
||||||
sg.popup('You do not hit "Enter"')
|
sg.popup('You do not hit "Enter"')
|
||||||
|
|
||||||
|
# handle event add a keyword with categorie modifier
|
||||||
if event == '-MODIFIER-':
|
if event == '-MODIFIER-':
|
||||||
raw_modifier = sg.popup_get_text('Enter customn modifier (public, private, ...): ', default_text=modifier)
|
raw_modifier = sg.popup_get_text('Enter customn modifier (public, private, ...): ', default_text=modifier)
|
||||||
try:
|
try:
|
||||||
@@ -206,15 +218,20 @@ class Gui:
|
|||||||
except:
|
except:
|
||||||
sg.popup('You do not hit "Enter"')
|
sg.popup('You do not hit "Enter"')
|
||||||
|
|
||||||
|
# handle event add a keyword with categorie comment
|
||||||
if event == '-COMMENTS-':
|
if event == '-COMMENTS-':
|
||||||
raw_comments = sg.popup_get_text('Enter customn comments (//, #, ...): ', default_text=comments)
|
raw_comments = sg.popup_get_text('Enter customn comments (//, #, ...): ', default_text=comments)
|
||||||
try:
|
try:
|
||||||
raw_comments = raw_comments.replace(' ', '')
|
if raw_comments == None:
|
||||||
comments = raw_comments.split(',')
|
pass
|
||||||
|
else:
|
||||||
|
raw_comments = raw_comments.replace(' ', '')
|
||||||
|
comments = raw_comments.split(',')
|
||||||
except:
|
except:
|
||||||
sg.popup('You do not hit "Enter"')
|
sg.popup('You do not hit "Enter"')
|
||||||
# output view
|
# output view
|
||||||
|
|
||||||
|
# handle event REFRESH
|
||||||
if event == '-REFRESH-':
|
if event == '-REFRESH-':
|
||||||
try:
|
try:
|
||||||
fnames = output(values['-OUTPUT FOLDER-'])
|
fnames = output(values['-OUTPUT FOLDER-'])
|
||||||
@@ -226,5 +243,7 @@ class Gui:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
window.close()
|
window.close()
|
||||||
|
|
||||||
|
# if the own popwp is there close it
|
||||||
if exists_choice:
|
if exists_choice:
|
||||||
popup_3_choice.close()
|
popup_3_choice.close()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Layout_std:
|
|||||||
input_column = [
|
input_column = [
|
||||||
[
|
[
|
||||||
sg.Text('Java File'),
|
sg.Text('Java File'),
|
||||||
sg.In(size=(25, 1), enable_events=True, key="-JAVA FOLDER-"),
|
sg.In(size=(25, 1), enable_events=True, key="-JAVA IN-"),
|
||||||
sg.FileBrowse(file_types=(('Java-File', '*.java'), ('ALL Files',
|
sg.FileBrowse(file_types=(('Java-File', '*.java'), ('ALL Files',
|
||||||
'*.*')), key='-JAVA FILE-'),
|
'*.*')), key='-JAVA FILE-'),
|
||||||
],
|
],
|
||||||
@@ -37,7 +37,13 @@ class Layout_std:
|
|||||||
sg.HSeparator(),
|
sg.HSeparator(),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Text('Optional: choose custom font.'),
|
sg.Text('Optional: '),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
sg.HSeparator(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
sg.Text('choose custom font'),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Text('TTF File'),
|
sg.Text('TTF File'),
|
||||||
@@ -51,7 +57,6 @@ class Layout_std:
|
|||||||
[
|
[
|
||||||
# modifier
|
# modifier
|
||||||
sg.Button(button_text='Add costum modifier', key='-MODIFIER-')
|
sg.Button(button_text='Add costum modifier', key='-MODIFIER-')
|
||||||
# comments
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
sg.Button(button_text='Add costum comments', key='-COMMENTS-')
|
sg.Button(button_text='Add costum comments', key='-COMMENTS-')
|
||||||
|
|||||||
Reference in New Issue
Block a user