+ toolbar WIP

This commit is contained in:
oleting
2020-12-28 23:42:31 +01:00
parent ec6c5860cd
commit cbd964d3e3

View File

@@ -9,7 +9,9 @@ import secrets
import logging import logging
import time import time
#new popup # new popup
class layout_popup: class layout_popup:
def __init__(self): def __init__(self):
text_column = [ text_column = [
@@ -26,12 +28,13 @@ class layout_popup:
] ]
] ]
self.layout = [ self.layout = [
[ [
sg.Column(text_column), sg.Column(text_column),
sg.Column(choices), sg.Column(choices),
] ]
] ]
class Gui: class Gui:
def __init__(self, theme: str, debug_mode: bool): def __init__(self, theme: str, debug_mode: bool):
@@ -51,6 +54,16 @@ class Gui:
sg.theme(theme) sg.theme(theme)
logging.debug(('Theme = ' + theme)) logging.debug(('Theme = ' + theme))
toolbar = [
[
#sg.ButtonMenu('', menu_def),
sg.Button('TEST')
]
]
input_column = [ input_column = [
[ [
sg.Text('Java File'), sg.Text('Java File'),
@@ -85,7 +98,9 @@ class Gui:
file_list_column = [ file_list_column = [
[ [
sg.Text('Output folder') sg.Text('Output folder'),
sg.Button(button_text='Refresh', key='-REFRESH-')
], ],
[ [
sg.Listbox( sg.Listbox(
@@ -120,12 +135,21 @@ class Gui:
] ]
] ]
layout_with_toolbar = [
[
sg.Column(toolbar)
],
[
sg.HSeparator(),
],
[
sg.Column(layout)
]
]
logging.debug('init layout GUI') logging.debug('init layout GUI')
window = sg.Window('Nassi Viewer', layout, resizable=True) window = sg.Window('Nassi Viewer', layout_with_toolbar, resizable=True)
return window return window
@@ -161,7 +185,8 @@ class Gui:
('Try create Image with values = ' + str(values))) ('Try create Image with values = ' + str(values)))
layout_p = layout_popup() layout_p = layout_popup()
popup_3_choice = sg.Window(title='',no_titlebar=True, layout=layout_p.layout, resizable=False) popup_3_choice = sg.Window(
title='', no_titlebar=True, layout=layout_p.layout, resizable=False)
event_popup, values_popup = popup_3_choice.read() event_popup, values_popup = popup_3_choice.read()
while event_popup != '-OVERWRITE-' or event_popup != '-EXPICIT-' or event_popup != '-SKIP-': while event_popup != '-OVERWRITE-' or event_popup != '-EXPICIT-' or event_popup != '-SKIP-':
@@ -183,15 +208,16 @@ class Gui:
) )
output_path = values['-OUTPUT FOLDER-'] output_path = values['-OUTPUT FOLDER-']
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(
output_name = secrets.token_hex(16) 'You didn\'t set a name for the image, it will be named randomly.')
output_name = secrets.token_hex(16)
nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self, nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self,
font_filepath=font_filepath, behaviour=exists_choice) font_filepath=font_filepath, behaviour=exists_choice)
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:
@@ -255,6 +281,9 @@ class Gui:
) )
window["-TOUT-"].update(filename) window["-TOUT-"].update(filename)
window["-IMAGE-"].update(filename=filename) window["-IMAGE-"].update(filename=filename)
except FileNotFoundError:
sg.popup_error('FileNotFoundError',
title='FileNotFoundError',)
except: except:
pass pass
@@ -276,6 +305,12 @@ 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-']
# output view
if event == '-REFRESH-':
fnames = output(values)
window['-OUTPUT FILE LIST-'].update(fnames)
window.close() window.close()
if exists_choice: if exists_choice:
popup_3_choice.close() popup_3_choice.close()