Skip to content
Snippets Groups Projects
Commit ca210f50 authored by Andreas Bolin's avatar Andreas Bolin
Browse files

workspace dump

parent 560e32e9
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72583 passed
"""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()
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
"""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
File moved
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment