Added log widget
This commit is contained in:
53
negstation/widgets/log_widget.py
Normal file
53
negstation/widgets/log_widget.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import dearpygui.dearpygui as dpg
|
||||||
|
import logging
|
||||||
|
from .base_widget import BaseWidget
|
||||||
|
|
||||||
|
|
||||||
|
class DPGLogHandler(logging.Handler):
|
||||||
|
def __init__(self, callback):
|
||||||
|
super().__init__()
|
||||||
|
self.callback = callback
|
||||||
|
|
||||||
|
def emit(self, record):
|
||||||
|
msg = self.format(record)
|
||||||
|
self.callback(msg)
|
||||||
|
|
||||||
|
|
||||||
|
class LogWindowWidget(BaseWidget):
|
||||||
|
name = "Log Window"
|
||||||
|
register = True
|
||||||
|
|
||||||
|
def __init__(self, manager, logger):
|
||||||
|
super().__init__(manager, logger)
|
||||||
|
self.initialized = False
|
||||||
|
self.log_tag = dpg.generate_uuid()
|
||||||
|
self.log_lines = []
|
||||||
|
|
||||||
|
# Create and attach handler
|
||||||
|
self.handler = DPGLogHandler(self._on_log)
|
||||||
|
self.handler.setFormatter(logging.Formatter(
|
||||||
|
'%(asctime)s [%(levelname)s] %(message)s'))
|
||||||
|
self.logger.addHandler(self.handler)
|
||||||
|
|
||||||
|
def create_content(self):
|
||||||
|
dpg.add_text("Live Log Output")
|
||||||
|
dpg.add_separator()
|
||||||
|
dpg.add_child_window(tag=self.log_tag, autosize_x=True,
|
||||||
|
autosize_y=True, horizontal_scrollbar=True)
|
||||||
|
self.initialized = True
|
||||||
|
|
||||||
|
def _on_log(self, msg: str):
|
||||||
|
self.log_lines.append(msg)
|
||||||
|
if self.initialized:
|
||||||
|
dpg.add_text(msg, parent=self.log_tag)
|
||||||
|
dpg.set_y_scroll(self.log_tag, dpg.get_y_scroll_max(self.log_tag))
|
||||||
|
|
||||||
|
def on_resize(self, width: int, height: int):
|
||||||
|
# Optional: could resize child window here if needed
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _on_window_close(self):
|
||||||
|
if self.initialized:
|
||||||
|
self.logger.removeHandler(self.handler)
|
||||||
|
self.handler = None
|
||||||
|
super()._on_window_close()
|
@ -39,6 +39,9 @@ class OpenRawWidget(PipelineStageWidget):
|
|||||||
"four_color_rgb": False,
|
"four_color_rgb": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_config(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
def create_pipeline_stage_content(self):
|
def create_pipeline_stage_content(self):
|
||||||
with dpg.file_dialog(
|
with dpg.file_dialog(
|
||||||
directory_selector=False,
|
directory_selector=False,
|
||||||
@ -140,7 +143,7 @@ class OpenRawWidget(PipelineStageWidget):
|
|||||||
"four_color_rgb", a)
|
"four_color_rgb", a)
|
||||||
)
|
)
|
||||||
|
|
||||||
with dpg.group(tag=self.busy_group):
|
with dpg.group(tag=self.busy_group, show=False):
|
||||||
dpg.add_text("Processing...")
|
dpg.add_text("Processing...")
|
||||||
|
|
||||||
def _on_open_file(self):
|
def _on_open_file(self):
|
||||||
|
@ -3,169 +3,129 @@ Pos=0,19
|
|||||||
Size=800,581
|
Size=800,581
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][###33]
|
||||||
|
Pos=301,400
|
||||||
|
Size=499,200
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
[Window][###39]
|
||||||
|
Pos=0,19
|
||||||
|
Size=299,86
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000007,0
|
||||||
|
|
||||||
|
[Window][###51]
|
||||||
|
Pos=0,19
|
||||||
|
Size=244,474
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000014,1
|
||||||
|
|
||||||
|
[Window][###59]
|
||||||
|
Pos=0,494
|
||||||
|
Size=299,106
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][###67]
|
||||||
|
Pos=0,107
|
||||||
|
Size=299,385
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=400,400
|
Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][###28]
|
[Window][###57]
|
||||||
Pos=0,19
|
Pos=0,120
|
||||||
Size=299,379
|
Size=196,373
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000003,0
|
|
||||||
|
|
||||||
[Window][###27]
|
|
||||||
Pos=0,19
|
|
||||||
Size=300,200
|
|
||||||
Collapsed=0
|
|
||||||
|
|
||||||
[Window][###34]
|
|
||||||
Pos=0,480
|
|
||||||
Size=250,120
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000010,0
|
|
||||||
|
|
||||||
[Window][###33]
|
|
||||||
Pos=0,445
|
|
||||||
Size=250,383
|
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000E,0
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
[Window][###37]
|
|
||||||
Pos=0,400
|
|
||||||
Size=299,200
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000004,0
|
|
||||||
|
|
||||||
[Window][###22]
|
|
||||||
Pos=0,19
|
|
||||||
Size=288,427
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000007,0
|
|
||||||
|
|
||||||
[Window][###31]
|
|
||||||
Pos=0,448
|
|
||||||
Size=288,152
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000008,0
|
|
||||||
|
|
||||||
[Window][###23]
|
[Window][###23]
|
||||||
Pos=0,19
|
Pos=0,19
|
||||||
Size=305,85
|
Size=244,474
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000021,0
|
DockId=0x00000014,0
|
||||||
|
|
||||||
[Window][###32]
|
[Window][###29]
|
||||||
Pos=0,376
|
Pos=0,19
|
||||||
Size=250,224
|
Size=244,423
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000012,0
|
||||||
|
|
||||||
|
[Window][###41]
|
||||||
|
Pos=198,19
|
||||||
|
Size=602,425
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000011,0
|
||||||
|
|
||||||
|
[Window][###49]
|
||||||
|
Pos=0,495
|
||||||
|
Size=196,105
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
[Window][###46]
|
|
||||||
Pos=252,19
|
|
||||||
Size=569,605
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][###39]
|
|
||||||
Pos=252,19
|
|
||||||
Size=663,581
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][###53]
|
|
||||||
Pos=252,19
|
|
||||||
Size=548,581
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][###41]
|
|
||||||
Pos=252,19
|
|
||||||
Size=857,809
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][###42]
|
[Window][###42]
|
||||||
Pos=252,19
|
Pos=246,19
|
||||||
Size=548,581
|
Size=554,379
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000011,0
|
||||||
|
|
||||||
[Window][###57]
|
[Window][###60]
|
||||||
Pos=0,400
|
Pos=0,19
|
||||||
Size=250,200
|
Size=244,423
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000018,0
|
DockId=0x00000012,1
|
||||||
|
|
||||||
[Window][###65]
|
[Window][###107]
|
||||||
Pos=0,400
|
Pos=246,400
|
||||||
Size=250,200
|
Size=554,200
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000016,0
|
DockId=0x00000016,0
|
||||||
|
|
||||||
[Window][###73]
|
[Window][###35]
|
||||||
Pos=237,120
|
Pos=246,19
|
||||||
Size=300,200
|
Size=554,425
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
DockId=0x00000011,0
|
||||||
|
|
||||||
[Window][###43]
|
[Window][###43]
|
||||||
Pos=307,19
|
Pos=0,495
|
||||||
Size=493,581
|
Size=244,105
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000015,0
|
||||||
|
|
||||||
[Window][###35]
|
[Window][###81]
|
||||||
Pos=0,500
|
Pos=246,446
|
||||||
Size=305,100
|
Size=554,154
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000001A,0
|
DockId=0x00000010,0
|
||||||
|
|
||||||
[Window][###60]
|
|
||||||
Pos=0,192
|
|
||||||
Size=250,306
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000020,0
|
|
||||||
|
|
||||||
[Window][###51]
|
|
||||||
Pos=0,106
|
|
||||||
Size=305,392
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000022,0
|
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x7C6B3D9B Window=0xA87D555D Pos=0,19 Size=800,581 Split=X
|
DockSpace ID=0x7C6B3D9B Window=0xA87D555D Pos=0,19 Size=800,581 Split=X
|
||||||
DockNode ID=0x00000009 Parent=0x7C6B3D9B SizeRef=305,581 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000009 Parent=0x7C6B3D9B SizeRef=244,581 Split=Y Selected=0x3BEDC6B0
|
||||||
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=147,355 Split=Y Selected=0xD36850C8
|
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=196,474 Split=Y Selected=0x3BEDC6B0
|
||||||
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=250,304 Split=Y Selected=0xD36850C8
|
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=196,99 Split=Y Selected=0x99D84869
|
||||||
DockNode ID=0x0000000F Parent=0x0000000D SizeRef=250,459 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000012 Parent=0x0000000D SizeRef=196,423 Selected=0x0F59680E
|
||||||
DockNode ID=0x00000011 Parent=0x0000000F SizeRef=250,379 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000013 Parent=0x0000000D SizeRef=196,156 Split=Y Selected=0xB4AD3310
|
||||||
DockNode ID=0x00000013 Parent=0x00000011 SizeRef=250,379 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000014 Parent=0x00000013 SizeRef=244,474 Selected=0xB4AD3310
|
||||||
DockNode ID=0x00000015 Parent=0x00000013 SizeRef=250,379 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000015 Parent=0x00000013 SizeRef=244,105 Selected=0x0531B3D5
|
||||||
DockNode ID=0x00000017 Parent=0x00000015 SizeRef=250,379 Split=Y Selected=0xD36850C8
|
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=196,373 Selected=0x3BEDC6B0
|
||||||
DockNode ID=0x00000019 Parent=0x00000017 SizeRef=250,479 Split=Y Selected=0xD36850C8
|
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=196,105 Selected=0x4F81AB74
|
||||||
DockNode ID=0x0000001B Parent=0x00000019 SizeRef=250,161 Split=Y Selected=0xD36850C8
|
DockNode ID=0x0000000A Parent=0x7C6B3D9B SizeRef=554,581 Split=X
|
||||||
DockNode ID=0x0000001D Parent=0x0000001B SizeRef=250,192 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000003 Parent=0x0000000A SizeRef=299,581 Split=Y Selected=0x52849BCC
|
||||||
DockNode ID=0x0000001F Parent=0x0000001D SizeRef=250,171 Split=Y Selected=0xD36850C8
|
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=299,473 Split=Y Selected=0x52849BCC
|
||||||
DockNode ID=0x00000021 Parent=0x0000001F SizeRef=250,85 Selected=0xD36850C8
|
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=299,86 Selected=0x52849BCC
|
||||||
DockNode ID=0x00000022 Parent=0x0000001F SizeRef=250,392 Selected=0xB4AD3310
|
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=299,385 Selected=0xBD79B41E
|
||||||
DockNode ID=0x00000020 Parent=0x0000001D SizeRef=250,306 Selected=0x0F59680E
|
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=299,106 Selected=0x84DD78D1
|
||||||
DockNode ID=0x0000001E Parent=0x0000001B SizeRef=250,285 Selected=0x0F59680E
|
DockNode ID=0x00000004 Parent=0x0000000A SizeRef=499,581 Split=Y
|
||||||
DockNode ID=0x0000001C Parent=0x00000019 SizeRef=250,316 Selected=0x0F59680E
|
DockNode ID=0x00000001 Parent=0x00000004 SizeRef=800,379 Split=Y Selected=0x7FF1E0B5
|
||||||
DockNode ID=0x0000001A Parent=0x00000017 SizeRef=250,100 Selected=0x977476CD
|
DockNode ID=0x0000000F Parent=0x00000001 SizeRef=602,425 Split=Y Selected=0x38519A65
|
||||||
DockNode ID=0x00000018 Parent=0x00000015 SizeRef=250,200 Selected=0x3BEDC6B0
|
DockNode ID=0x00000011 Parent=0x0000000F SizeRef=554,379 CentralNode=1 Selected=0x977476CD
|
||||||
DockNode ID=0x00000016 Parent=0x00000013 SizeRef=250,200 Selected=0xC7B9E77E
|
DockNode ID=0x00000016 Parent=0x0000000F SizeRef=554,200 Selected=0x3A881EEF
|
||||||
DockNode ID=0x00000014 Parent=0x00000011 SizeRef=250,200 Selected=0x3BEDC6B0
|
DockNode ID=0x00000010 Parent=0x00000001 SizeRef=602,154 Selected=0x083320CE
|
||||||
DockNode ID=0x00000012 Parent=0x0000000F SizeRef=250,200 Selected=0x83A5C17B
|
DockNode ID=0x00000002 Parent=0x00000004 SizeRef=800,200 Selected=0x1834836D
|
||||||
DockNode ID=0x00000010 Parent=0x0000000D SizeRef=250,120 Selected=0xAA145F7D
|
|
||||||
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=250,275 Selected=0x1834836D
|
|
||||||
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=147,224 Selected=0x2554AADD
|
|
||||||
DockNode ID=0x0000000A Parent=0x7C6B3D9B SizeRef=493,581 Split=X
|
|
||||||
DockNode ID=0x00000005 Parent=0x0000000A SizeRef=288,581 Split=Y Selected=0xEE087978
|
|
||||||
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=147,427 Selected=0xEE087978
|
|
||||||
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=147,152 Selected=0x62F4D00D
|
|
||||||
DockNode ID=0x00000006 Parent=0x0000000A SizeRef=510,581 Split=X
|
|
||||||
DockNode ID=0x00000001 Parent=0x00000006 SizeRef=299,581 Split=Y Selected=0xA4B861D9
|
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=299,379 Selected=0xA4B861D9
|
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=299,200 Selected=0xEDB425AD
|
|
||||||
DockNode ID=0x00000002 Parent=0x00000006 SizeRef=499,581 CentralNode=1 Selected=0x0531B3D5
|
|
||||||
|
|
||||||
|
@ -3,16 +3,20 @@
|
|||||||
"widget_type": "OpenImageWidget",
|
"widget_type": "OpenImageWidget",
|
||||||
"config": {}
|
"config": {}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"widget_type": "InvertStage",
|
|
||||||
"config": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"widget_type": "PipelineStageViewer",
|
"widget_type": "PipelineStageViewer",
|
||||||
"config": {}
|
"config": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"widget_type": "InvertStage",
|
||||||
|
"config": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"widget_type": "OpenRawWidget",
|
"widget_type": "OpenRawWidget",
|
||||||
"config": {}
|
"config": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_type": "LogWindowWidget",
|
||||||
|
"config": {}
|
||||||
}
|
}
|
||||||
]
|
]
|
Reference in New Issue
Block a user