diff --git a/extra/editor/texture_selector_ng.py b/extra/editor/texture_selector_ng.py index 8696d52..bd5d2ae 100644 --- a/extra/editor/texture_selector_ng.py +++ b/extra/editor/texture_selector_ng.py @@ -2,6 +2,8 @@ import os from nicegui import ui from nicegui import app +from nicegui.events import ValueChangeEventArguments +from PIL import Image #This is the raltive directory to the base of the SagoSprite dir #I am launching from extra/editor so I need to go two levels up @@ -9,6 +11,7 @@ BASEDIR = '../..' app.add_static_files('/textures', BASEDIR+'/data/textures') + def addFolderToList(theFolder, theList, filter2 = None): textures_filenames = os.listdir(BASEDIR+"/data/textures/"+theFolder) for x in textures_filenames: @@ -29,13 +32,29 @@ def populateTree(filter2 = None): @ui.page('/texture_select') async def texture_select(): img = ui.image('/textures/fallback.png') + img.style('fit: "scale-down"') + def show(event: ValueChangeEventArguments): + print(event['args']['value']) + filename = '/textures'+event['args']['value'] + img.set_source(filename) + imgFile = Image.open(BASEDIR+"/data"+filename) + img.style('height: {}px; width: {}px'.format(imgFile.height, imgFile.width)) + print("Width:", imgFile.width) with ui.header(elevated=True).style('background-color: #3874c8').classes('items-center justify-between'): ui.label('HEADER') ui.button(on_click=lambda: right_drawer.toggle()).props('flat color=white icon=menu') with ui.left_drawer(top_corner=True, bottom_corner=True).style('background-color: #d7e3f4'): ui.label('Texture list') + textures = [] for texture in populateTree(""): - ui.label(texture) + textures.append({'texture': texture}) + table = ui.table({ + 'columnDefs': [ + {'headerName': 'Texture', 'field': 'texture'}, + ], + 'rowData': textures, + }) + table.on('cellClicked', show) with ui.right_drawer(fixed=False).style('background-color: #ebf1fa').props('bordered') as right_drawer: ui.label('RIGHT DRAWER') with ui.footer().style('background-color: #3874c8'):