diff --git a/b_asic/schedule-gui/diagram.py b/b_asic/schedule-gui/diagram.py deleted file mode 100644 index 38e41b053cf58b562efe22f873bdcc8643dd21e6..0000000000000000000000000000000000000000 --- a/b_asic/schedule-gui/diagram.py +++ /dev/null @@ -1,41 +0,0 @@ -"""B-ASIC Schedule-gui Diagram Module. - -Contains the Diagram class for painting an schedule. -""" -# This Python file uses the following encoding: utf-8 - -from qtpy import QtCore -from qtpy import QtWidgets -from qtpy.QtGui import ( - QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, - QLinearGradient) -from qtpy.QtWidgets import QCanvasView - -# QPaintEvent is a class -class Diagram(QtWidgets.QWidget): - - _antialiasing: bool = False - - def __init__(self, parent): - pass - - def add_component(self): - pass - - def paintEvent(self, event): - # Create a few pen colors - self.black = '#000000' - self.blue = '#2041F1' - self.green = '#12A708' - self.purple = '#6512F0' - self.red = '#E00C0C' - self.orange = '#FF930A' - - painter = QPainter(self) - #painter.Antialiasing(self._antialiasing) - - painter.begin(self) - painter.drawLine(10, 10, 100, 100) - - painter.end() - diff --git a/b_asic/schedule-gui/schedule-demo.py b/b_asic/schedule-gui/schedule-demo.py new file mode 100644 index 0000000000000000000000000000000000000000..bbc2cc6f33510a9997f65c6b05d8ca232dc73f7a --- /dev/null +++ b/b_asic/schedule-gui/schedule-demo.py @@ -0,0 +1,8 @@ +from qtpy import QtCore, QtGui, QtWidgets +from schedule import Schedule + + +app = QtWidgets.QApplication([]) +schedule = Schedule() +schedule.show() +app.exec_() \ No newline at end of file diff --git a/b_asic/schedule-gui/schedule.py b/b_asic/schedule-gui/schedule.py new file mode 100644 index 0000000000000000000000000000000000000000..9b02e59f70e2d7fc482431bfbda5ba9e748ecffb --- /dev/null +++ b/b_asic/schedule-gui/schedule.py @@ -0,0 +1,61 @@ +"""B-ASIC Schedule-gui Schedule Module. + +Contains the Schedule class for painting an schedule. +""" +# This Python file uses the following encoding: utf-8 + +from qtpy import QtCore +#from qtpy import QtGui +from qtpy import QtWidgets +from qtpy.QtCore import Qt +from qtpy.QtGui import ( + QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, + QLinearGradient) + + + + +class _Component(QtWidgets.QWidget): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.setSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, + QtWidgets.QSizePolicy.MinimumExpanding + ) + + def sizeHint(self) -> QtCore.QSize: + return QtCore.QSize(40,120) + + def paintEvent(self, e) -> None: + painter = QPainter(self) + pen = QPen() + pen.setColor(Qt.green) + pen.setWidth(1000) + #brush.setStyle(Qt.SolidPattern) + #rect = QtCore.QRect(0, 0, painter.device().width(), painter.device().height()) + #painter.fillRect(rect, brush) + painter.drawRect(0, 0, painter.device().width(), painter.device().height()) + +# QPaintEvent is a class +class Schedule(QtWidgets.QWidget): + + _antialiasing: bool = False + _component: _Component = [] + + def __init__(self, *args, **kwargs): + super(Schedule, self).__init__(*args, **kwargs) + + layout = QtWidgets.QVBoxLayout() + self._component.append(_Component()) + self._component.append(_Component()) + layout.addWidget(self._component[0]) + layout.addWidget(self._component[1]) + + self.setLayout(layout) + + + def add_component(self) -> None: + pass + + diff --git a/b_asic/schedule-gui/diagram2.py b/b_asic/schedule-gui/schedule2.py similarity index 100% rename from b_asic/schedule-gui/diagram2.py rename to b_asic/schedule-gui/schedule2.py diff --git a/b_asic/schedule-gui/tests/demo.py b/b_asic/schedule-gui/tests/demo.py new file mode 100644 index 0000000000000000000000000000000000000000..485d688ffd849d5dca7bc331a565e55a799572e2 --- /dev/null +++ b/b_asic/schedule-gui/tests/demo.py @@ -0,0 +1,8 @@ +from qtpy import QtCore, QtGui, QtWidgets +from power_bar import PowerBar + + +app = QtWidgets.QApplication([]) +volume = PowerBar() +volume.show() +app.exec_() \ No newline at end of file diff --git a/b_asic/schedule-gui/tests/power_bar.py b/b_asic/schedule-gui/tests/power_bar.py new file mode 100644 index 0000000000000000000000000000000000000000..e6a8ebe825e139890ab737e168c9f1f130fdbaa7 --- /dev/null +++ b/b_asic/schedule-gui/tests/power_bar.py @@ -0,0 +1,41 @@ +from qtpy import QtCore, QtGui, QtWidgets +from qtpy.QtCore import Qt + + +class _Bar(QtWidgets.QWidget): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + self.setSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, + QtWidgets.QSizePolicy.MinimumExpanding + ) + + def sizeHint(self): + return QtCore.QSize(40,120) + + def paintEvent(self, e): + painter = QtGui.QPainter(self) + brush = QtGui.QBrush() + brush.setColor(QtGui.QColor('black')) + brush.setStyle(Qt.SolidPattern) + rect = QtCore.QRect(0, 0, painter.device().width(), painter.device().height()) + painter.fillRect(rect, brush) + +class PowerBar(QtWidgets.QWidget): + """ + Custom Qt Widget to show a power bar and dial. + Demonstrating compound and custom-drawn widget. + """ + + def __init__(self, steps=5, *args, **kwargs): + super(PowerBar, self).__init__(*args, **kwargs) + + layout = QtWidgets.QVBoxLayout() + self._bar = _Bar() + layout.addWidget(self._bar) + + self._dial = QtWidgets.QDial() + layout.addWidget(self._dial) + + self.setLayout(layout) \ No newline at end of file