[taskcard] move TaskCard to own module
This commit is contained in:
parent
f366d6b8ff
commit
cdfc2069c8
@ -1,49 +1,13 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PySide6.QtWidgets import QWidget, QStackedLayout, QSizePolicy, QHBoxLayout, QFrame, QLabel, QVBoxLayout, QGridLayout, QSpacerItem
|
from PySide6.QtWidgets import QWidget, QStackedLayout, QSizePolicy, QVBoxLayout, QGridLayout, QSpacerItem
|
||||||
from PySide6.QtCore import Qt, QSize, Signal
|
from PySide6.QtCore import Qt
|
||||||
from PySide6.QtGui import QIcon, QFont, QImage, QPixmap
|
|
||||||
|
|
||||||
from fixtracks.widgets.tracks import FixTracks
|
from fixtracks.widgets.tracks import FixTracks
|
||||||
from fixtracks.widgets.detectionmerge import MergeDetections
|
from fixtracks.widgets.detectionmerge import MergeDetections
|
||||||
from fixtracks.widgets.taskwidget import TasksWidget, Task
|
from fixtracks.widgets.taskwidget import TasksWidget, Task
|
||||||
from fixtracks.widgets.converter import Json2PandasConverter
|
from fixtracks.widgets.converter import Json2PandasConverter
|
||||||
|
from fixtracks.widgets.taskcard import TaskCard
|
||||||
class TaskCard(QFrame):
|
|
||||||
clicked = Signal()
|
|
||||||
|
|
||||||
def __init__(self, name, icon, description, parent=None):
|
|
||||||
super().__init__(parent)
|
|
||||||
self.setMaximumSize(300, 200)
|
|
||||||
self.setFrameShape(QFrame.Shape.Box)
|
|
||||||
# self.setStyleSheet("border: 2px solid gray; border-radius: 15px; border-color: white;background-color: green;")
|
|
||||||
font = QFont()
|
|
||||||
font.setBold(True)
|
|
||||||
font.setPointSize(18)
|
|
||||||
|
|
||||||
name_label = QLabel(name)
|
|
||||||
name_label.setFont(font)
|
|
||||||
description_label = QLabel(description)
|
|
||||||
description_label.setLineWidth(150)
|
|
||||||
description_label.setWordWrap(True)
|
|
||||||
icon_label = QLabel()
|
|
||||||
icon_label.setFixedSize(150, 150)
|
|
||||||
pixmap = QPixmap.fromImage(QImage(icon))
|
|
||||||
scaled_pixmap = pixmap.scaled(icon_label.size(), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
|
|
||||||
icon_label.setPixmap(scaled_pixmap)
|
|
||||||
|
|
||||||
hbox = QHBoxLayout()
|
|
||||||
hbox.addWidget(icon_label)
|
|
||||||
hbox.addWidget(description_label)
|
|
||||||
self.mousePressEvent = self._on_click
|
|
||||||
|
|
||||||
lyt = QVBoxLayout()
|
|
||||||
lyt.addWidget(name_label)
|
|
||||||
lyt.addLayout(hbox)
|
|
||||||
self.setLayout(lyt)
|
|
||||||
|
|
||||||
def _on_click(self, event):
|
|
||||||
self.clicked.emit()
|
|
||||||
|
|
||||||
|
|
||||||
class CentralWidget(QWidget):
|
class CentralWidget(QWidget):
|
||||||
|
40
fixtracks/widgets/taskcard.py
Normal file
40
fixtracks/widgets/taskcard.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
from PySide6.QtWidgets import QHBoxLayout, QFrame, QLabel, QVBoxLayout
|
||||||
|
from PySide6.QtCore import Qt, Signal
|
||||||
|
from PySide6.QtGui import QFont, QImage, QPixmap
|
||||||
|
|
||||||
|
|
||||||
|
class TaskCard(QFrame):
|
||||||
|
clicked = Signal()
|
||||||
|
|
||||||
|
def __init__(self, name, icon, description, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setMaximumSize(300, 200)
|
||||||
|
self.setFrameShape(QFrame.Shape.Box)
|
||||||
|
# self.setStyleSheet("border: 2px solid gray; border-radius: 15px; border-color: white;background-color: green;")
|
||||||
|
font = QFont()
|
||||||
|
font.setBold(True)
|
||||||
|
font.setPointSize(18)
|
||||||
|
|
||||||
|
name_label = QLabel(name)
|
||||||
|
name_label.setFont(font)
|
||||||
|
description_label = QLabel(description)
|
||||||
|
description_label.setLineWidth(150)
|
||||||
|
description_label.setWordWrap(True)
|
||||||
|
icon_label = QLabel()
|
||||||
|
icon_label.setFixedSize(150, 150)
|
||||||
|
pixmap = QPixmap.fromImage(QImage(icon))
|
||||||
|
scaled_pixmap = pixmap.scaled(icon_label.size(), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
|
||||||
|
icon_label.setPixmap(scaled_pixmap)
|
||||||
|
|
||||||
|
hbox = QHBoxLayout()
|
||||||
|
hbox.addWidget(icon_label)
|
||||||
|
hbox.addWidget(description_label)
|
||||||
|
self.mousePressEvent = self._on_click
|
||||||
|
|
||||||
|
lyt = QVBoxLayout()
|
||||||
|
lyt.addWidget(name_label)
|
||||||
|
lyt.addLayout(hbox)
|
||||||
|
self.setLayout(lyt)
|
||||||
|
|
||||||
|
def _on_click(self, event):
|
||||||
|
self.clicked.emit()
|
@ -5,6 +5,8 @@ from PySide6.QtWidgets import QWidget, QPushButton, QFileDialog, QSizePolicy, QV
|
|||||||
from PySide6.QtCore import Signal, Qt
|
from PySide6.QtCore import Signal, Qt
|
||||||
from PySide6.QtGui import QIcon, QAction
|
from PySide6.QtGui import QIcon, QAction
|
||||||
|
|
||||||
|
from fixtracks.widgets.taskcard import TaskCard
|
||||||
|
|
||||||
|
|
||||||
class Task(enum.Enum):
|
class Task(enum.Enum):
|
||||||
CONVERT = "Convert"
|
CONVERT = "Convert"
|
||||||
@ -56,22 +58,12 @@ class TasksWidget(QWidget):
|
|||||||
self._toolbarActions = [self._convertAction, self._mergeAction, self._tracksAction]
|
self._toolbarActions = [self._convertAction, self._mergeAction, self._tracksAction]
|
||||||
|
|
||||||
def createLayout(self):
|
def createLayout(self):
|
||||||
def buttonfromaction(action: QAction):
|
opentask = TaskCard("Open folder", ":icons/open" + self._iconsuffix, "Open data folder")
|
||||||
btn = QPushButton(action.icon(), "")
|
opentask.clicked.connect(self._on_open)
|
||||||
btn.setStatusTip(action.toolTip())
|
|
||||||
btn.setToolTip(action.text())
|
|
||||||
btn.clicked.connect(action.trigger)
|
|
||||||
return btn
|
|
||||||
|
|
||||||
openBtn = buttonfromaction(self._openAction)
|
|
||||||
openBtn.setEnabled(True)
|
|
||||||
openBtn.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
|
||||||
openBtn.setMaximumSize(300, 300)
|
|
||||||
openBtn.setIconSize(0.95 * openBtn.size())
|
|
||||||
|
|
||||||
l = QVBoxLayout()
|
l = QVBoxLayout()
|
||||||
l.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
l.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
l.addWidget(openBtn, Qt.AlignmentFlag.AlignCenter)
|
l.addWidget(opentask, Qt.AlignmentFlag.AlignCenter)
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user