Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photom_GUI #156

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions copylot/gui/_qt/custom_widgets/qt_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import textwrap

from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (
QPlainTextEdit,
QGroupBox,
QVBoxLayout,
QScrollArea,
QWidget,
QApplication,
)

import logging


class QtLogger(logging.Handler):
def __init__(self, widget):
super().__init__()
self.widget = widget
self.widget.setMinimumHeight(200)

def emit(self, record):
msg = self.format(record)
self.widget.log_txt.appendPlainText(msg)


class QtLogBox(QGroupBox):
def __init__(self, title: str):
super().__init__()
self.setTitle(title)

# self.setStyleSheet('QGroupBox::title {subcontrol-origin: margin; background: transparent;}')
self.setStyleSheet('QGroupBox {font-size: 12pt;}')
# self.setMaximumHeight(200)
# Add a log_txt to display text.
self.log_txt = QPlainTextEdit()
self.log_txt.setMinimumSize(QSize(200, 200))
self.log_txt.setLineWidth(1)
# self.log_txt.setAlignment(Qt.AlignTop)
self.log_txt.setLineWrapMode(QPlainTextEdit.WidgetWidth)
self.log_txt.setReadOnly(True)

# Define a scroll area
self.scroll = QScrollArea()
self.scroll.setWidget(self.log_txt)
self.scroll.setWidgetResizable(True)

# Configure layout
layout = QVBoxLayout(self)
layout.setContentsMargins(0, 10, 0, 0)
layout.addWidget(self.scroll)
self.setLayout(layout)
Loading