From eefb4de6ce6d4e7a1ecd7074a7594272503179f1 Mon Sep 17 00:00:00 2001 From: aedh carrick Date: Sun, 18 Dec 2022 18:19:41 -0600 Subject: [PATCH] squashed bug in canvas(flet ui) --- webui/flet/scripts/flet_canvas.py | 15 ++++++++------- webui/flet/webui_flet.py | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/webui/flet/scripts/flet_canvas.py b/webui/flet/scripts/flet_canvas.py index 2c9459c..d295980 100644 --- a/webui/flet/scripts/flet_canvas.py +++ b/webui/flet/scripts/flet_canvas.py @@ -40,6 +40,7 @@ class Canvas(ft.Container): def add_layer_image(self, image): self.image_stack.add_layer_image(image) + self.update() def center_canvas(self, e): width, height = self.page.get_viewport_size() @@ -51,18 +52,18 @@ class Canvas(ft.Container): def align_canvas(self, e): width, height = self.page.get_viewport_size() - self.image_stack.left = (width * 0.5) - (self.image_stack.scaled_width * 0.5) + self.image_stack.offset_x - self.image_stack.top = (height * 0.5) - (self.image_stack.scaled_height * 0.5) + self.image_stack.offset_y + self.image_stack.left = (width * 0.5) - (self.image_stack.width * 0.5) + self.image_stack.offset_x + self.image_stack.top = (height * 0.5) - (self.image_stack.height * 0.5) + self.image_stack.offset_y self.update() def pan_canvas(self, e: ft.DragUpdateEvent): self.image_stack.offset_x += e.delta_x self.image_stack.offset_y += e.delta_y width, height = self.page.get_viewport_size() - self.image_stack.offset_x = max(self.image_stack.offset_x, (width - self.image_stack.scaled_width) * 0.5) - self.image_stack.offset_y = max(self.image_stack.offset_y, (height - self.image_stack.scaled_height) * 0.5) - self.image_stack.offset_x = min(self.image_stack.offset_x, (self.image_stack.scaled_width - width) * 0.5) - self.image_stack.offset_y = min(self.image_stack.offset_y, (self.image_stack.scaled_height - height) * 0.5) + self.image_stack.offset_x = max(self.image_stack.offset_x, (width - self.image_stack.width) * 0.5) + self.image_stack.offset_y = max(self.image_stack.offset_y, (height - self.image_stack.height) * 0.5) + self.image_stack.offset_x = min(self.image_stack.offset_x, (self.image_stack.width - width) * 0.5) + self.image_stack.offset_y = min(self.image_stack.offset_y, (self.image_stack.height - height) * 0.5) self.align_canvas(e) def zoom_in(self, e): @@ -110,7 +111,7 @@ class ImageStack(ft.Container): width = image.width, height = image.height, content = ft.Image( - src_base64 = flet_utils.convert_image_to_base64(image), + src = f'assets/uploads/{image.filename}', width = image.width, height = image.height, gapless_playback = True, diff --git a/webui/flet/webui_flet.py b/webui/flet/webui_flet.py index c59d3ae..ed066a8 100644 --- a/webui/flet/webui_flet.py +++ b/webui/flet/webui_flet.py @@ -2,11 +2,12 @@ import flet as ft # other imports +import os from math import pi from typing import Optional from loguru import logger import logging -#logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.DEBUG) # utils imports from scripts import flet_utils @@ -23,6 +24,8 @@ from scripts.flet_property_manager import property_manager # for debugging from pprint import pprint +os.environ["FLET_WS_MAX_MESSAGE_SIZE"] = "8000000" + # main ############################################################### @logger.catch(reraise=True)