Esempio n. 1
0
File: dial.py Progetto: ara710/TMMT
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        # 윈도우 설정
        self.setGeometry(200, 100, 300, 300)  # x, y, w, h
        self.setWindowTitle('삼인성호')

        # QSliter  추가
        self.dial = QDial(self)
        self.dial.move(10, 10)
        self.dial.setFixedSize(100, 100)
        self.dial.setRange(0, 100)
        self.dial.setMinimum(1)
        self.dial.setMaximum(24)
        self.dial.setNotchesVisible(True)
        self.dial.valueChanged.connect(self.value_changed)

        # QSlider 데이터를 표시할 라벨
        self.label = QLabel(self)
        self.label.setGeometry(10, 120, 200, 100)
        self.label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.label.setStyleSheet("border-radius: 5px;"
                                 "border: 1px solid gray;"
                                 "background-color: #ffffff")

    # 슬라이드 시그널 valueChanged 연결 함수
    def value_changed(self, value):
        self.label.setText(str(value) + "시")
        self.label.setFont(QtGui.QFont("Malgun Gothic", 40))  #폰트,크기 조절
Esempio n. 2
0
    def initUI(self):
        self.combo = QComboBox(self)
        self.combo.move(10, 10)
        self.combo.activated[str].connect(self.onActivated)

        refresh = QPushButton('Refresh', self)
        refresh.move(10, 40)
        refresh.clicked.connect(self.refreshClicked)

        # sld = QSlider(Qt.Horizontal, self)
        # sld.setFocusPolicy(Qt.NoFocus)
        # sld.setGeometry(30, 40, 150, 30)

        sld = QDial(self)
        sld.setRange(0, 360)
        sld.move(10, 70)
        sld.valueChanged[int].connect(self.changeValue)

        self.motorAngle = QLabel("Angle: 000", self)
        self.motorAngle.move(120, 110)

        self.status = QLabel("Select a COM", self)
        self.status.move(10, 180)

        self.setGeometry(200, 200, 200, 200)
        self.setWindowTitle('Motor Control')

        self.combo.addItem("Connect/Refresh")
        self.show()
        self.addPorts()

        self.positionGraph = AnalogPosition()
        self.positionGraph.show()
Esempio n. 3
0
    def initUI(self):
        self.combo = QComboBox(self)
        self.combo.move(10, 10)
        self.combo.activated[str].connect(self.onActivated)

        refresh = QPushButton("Refresh", self)
        refresh.move(10, 40)
        refresh.clicked.connect(self.refreshClicked)

        # sld = QSlider(Qt.Horizontal, self)
        # sld.setFocusPolicy(Qt.NoFocus)
        # sld.setGeometry(30, 40, 150, 30)

        sld = QDial(self)
        sld.setRange(0, 360)
        sld.move(10, 70)
        sld.valueChanged[int].connect(self.changeValue)

        self.motorAngle = QLabel("Angle: 000", self)
        self.motorAngle.move(120, 110)

        self.status = QLabel("Select a COM", self)
        self.status.move(10, 180)

        self.setGeometry(200, 200, 200, 200)
        self.setWindowTitle("Motor Control")

        self.combo.addItem("Connect/Refresh")
        self.show()
        self.addPorts()

        self.positionGraph = AnalogPosition()
        self.positionGraph.show()
Esempio n. 4
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
    
    def initUI(self):
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.move(30, 30) # 슬라이더 위치는 x축 30, y축 30 떨어진 곳에
        self.slider.setRange(0, 50) # 슬라이더 범위
        self.slider.setSingleStep(2) # 슬라이더는 하나로만 잡고(SingleStep) 2씩 증가!
        
        self.dial = QDial(self)
        self.dial.move(30, 50) # 슬라이더 보다 아래쪽에 위치 
        self.dial.setRange(0, 50) # 슬라이더와 동일한 범위

        btn = QPushButton('Default', self)
        btn.move(35, 160) 
        
        self.slider.valueChanged.connect(self.dial.setValue)
        # 슬라이더 쪽에 변화가 일어난 후, 다이얼값이 슬라이더와 동일하게 발생할 수 있도록!
        # => 슬라이더가 움직이면 다이얼도 움직이도록 하는 것!
        # valueChanged() : 슬라이더 값이 변할 때 발생!
        self.dial.valueChanged.connect(self.slider.setValue)
        btn.clicked.connect(self.button_clicked)
        
        self.setWindowTitle('QSlider and QDial')
        self.setGeometry(300, 300, 400, 200)
        self.show()
        
    def button_clicked(self):
        self.slider.setValue(0)
        self.dial.setValue(0) #버튼 누르면 초기화 시키려고 값을 0으로 줌!
Esempio n. 5
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.slider = QSlider(Qt.Horizontal, self)
        #수평 슬라이더 생성, 생성시킬때 수평, 수직 설정. 상수는 Qt가 갖고있으니 임포트 해옴
        self.slider.move(30, 30)
        self.slider.setRange(0, 50)
        self.slider.setSingleStep(2)
        # 싱글스탭 으로 하고 간격은 2

        self.dial = QDial(self)  #다이얼 객체 생성
        self.dial.move(30, 50)
        self.dial.setRange(0, 50)  #다이얼 범위 지적

        btn = QPushButton('Default', self)
        btn.move(35, 160)

        self.slider.valueChanged.connect(
            self.dial.setValue)  #슬라이더 값 변화 일어난 후 다이얼 값도 동일하게(내장함수임)
        self.dial.valueChanged.connect(
            self.slider.setValue)  #다이얼의 값 변화가 일어난 후 슬라이더값도 동일하게(내장함수, 직접설정)
        btn.clicked.connect(self.button_clicked)

        self.setWindowTitle('QSlider and QDial')
        self.setGeometry(300, 300, 400, 200)
        self.show()

    def button_clicked(self):
        self.slider.setValue(0)
        self.dial.setValue(0)
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
        pass

    def initUI(self):
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.move(30, 30)
        self.slider.setRange(0, 50)
        self.slider.setSingleStep(2)

        self.dial = QDial(self)
        self.dial.move(30, 50)
        self.dial.setRange(0, 50)

        button = QPushButton('Default', self)
        button.move(35, 160)

        self.slider.valueChanged.connect(self.dial.setValue)
        self.dial.valueChanged.connect(self.slider.setValue)
        button.clicked.connect(self.button_clicked)

        self.setWindowTitle('QSlider and QDial')
        self.setGeometry(300, 300, 400, 200)
        self.show()
        pass

    def button_clicked(self):
        self.slider.setValue(0)
        self.dial.setValue(0)
        pass

    pass
Esempio n. 7
0
class MyWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.uiInit()

    def uiInit(self):
        self.value = 0

        self.dial = QDial(self)
        self.dial.move(0, 100)
        self.dial.setRange(0, 9999)
        self.dial.setNotchesVisible(True)
        self.lcd = QLCDNumber(self)

        self.setGeometry(300, 300, 300, 300)
        self.setWindowTitle('来来来')

        # self.dial.valueChanged.connect(self.lcd.display)

        self.show()

    def mousePressEvent(self, e):
        self.value += 1
        print(self.value)
        self.lcd.display(self.value)
Esempio n. 8
0
    def dial(self, func=None, X=200, Y=200, radius=50, wrap=False):
        knob = QDial(self)
        knob.move(X, Y)
        knob.resize(radius, radius)
        knob.setWrapping(wrap)

        if func is not None:
            func
        # TODO:something something show number in a box nearby

        return knob
Esempio n. 9
0
class MouseTracker(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()
        self.setMouseTracking(True)

    def initUI(self):
        self.setGeometry(300, 300, 700, 700)
        self.setWindowTitle('Mouse Tracker')
        self.label = QLabel(self)
        self.label.resize(200, 40)
        self.label.move(100, 40)

        self.laabel = QLabel(self)
        self.laabel.resize(200, 40)
        self.laabel.move(200, 300)

        self.laabel1 = QLabel(self)
        self.laabel1.resize(200, 40)
        self.laabel1.move(300, 100)

        self.dial = QDial(self)
        self.dial.move(xmove - 50, ymove - 50)
        self.dial.setValue(30)
        self.dial.resize(100, 100)
        self.dial.setWrapping(True)
        self.dial.setMinimum(0)
        self.dial.setMaximum(360)
        self.show()

    def mouseMoveEvent(self, event):
        x = event.x()
        y = event.y()
        if x < xmove and y < ymove: q = 1
        elif x > xmove and y < ymove: q = 2
        elif x > xmove and y > ymove: q = 3
        elif x < xmove and y > ymove: q = 4
        self.label.setText('Mouse coords: ( %d : %d )' % (x, y))
        if y != ymove and x != xmove:
            a = math.degrees(
                math.atan((ymove - event.y()) / (xmove - event.x())))
            if q == 1: a = a
            elif q == 2: a = 180 + a
            elif q == 3: a = 180 + a
            elif q == 4: a = a
        else:
            if x < xmove and y == ymove: a = 0
            elif x == xmove and y < ymove: a = 90
            elif x > xmove and y == ymove: a = 180
            elif x == xmove and y > ymove: a = 270

        self.dial.setValue(int(a) + 90)
        self.laabel1.setText(str(a))
Esempio n. 10
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.slider = QSlider(Qt.Horizontal, self)
        # QSlider 위젯을 하나 만들었습니다. Qt.Horizontal 또는
        # Qt.Vertical을 입력해줌으로써 수평 또는 수직 방향을 설정합니다.
        self.slider.move(30, 30)
        self.slider.setRange(0, 50)
        # setRange() 메서드로 값의 범위를 0에서 50까지로 설정합니다.
        # setSingleStep() 메서드는 조절 가능하는 최소 단위를 설정합니다
        self.slider.setSingleStep(2)

        self.dial = QDial(self)
        # QDial 위젯을 하나 만들었습니다.
        self.dial.move(30, 50)
        self.dial.setRange(0, 50)
        # 슬라이더와 마찬가지로 setRange() 메서드로 범위를 정해줍니다.

        btn = QPushButton('Default', self)
        btn.move(35, 160)

        self.slider.valueChanged.connect(self.dial.setValue)
        self.dial.valueChanged.connect(self.slider.setValue)
        # 슬라이더와 다이얼의 값이 변할 때 발생하는 시그널을 각각 다이얼과
        # 슬라이더의 값을 조절해주는 메서드 (setValue)에 서로 연결함으로써
        # 두 위젯의 값이 언제나 일치하도록 해줍니다.
        btn.clicked.connect(self.button_clicked)
        # 'Default' 푸시 버튼을 클릭하면 발생하는 시그널을 button_clicked 메서드에 연결합니다.

        self.setWindowTitle('QSlider and QDial')
        self.setGeometry(300, 300, 400, 200)
        self.show()

    def button_clicked(self):
        self.slider.setValue(0)
        self.dial.setValue(0)
Esempio n. 11
0
class 다이얼위젯(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.dial = QDial(self)
        self.dial.move(30, 20)

        self.dial2 = QDial(self)
        self.dial2.move(200, 20)
        self.dial2.setRange(0, 50)
        self.dial2.setNotchesVisible(True)

        self.label1 = QLabel('다이얼 1값', self)
        self.label1.move(40, 130)
        self.label2 = QLabel('다이얼 2값', self)
        self.label2.move(210, 130)

        btn = QPushButton('기본값으로 되돌리기', self)
        btn.move(150, 200)

        self.dial.valueChanged.connect(self.chageValue)
        self.dial2.valueChanged.connect(self.chageValue)

        btn.clicked.connect(self.btn_clicked)

        self.setGeometry(300, 300, 500, 400)
        self.setWindowTitle('QDial')
        self.show()

    def btn_clicked(self):
        self.dial.setValue(0)
        self.dial2.setValue(0)

    def chageValue(self):
        self.label1.setText(str(self.dial.value()))
        self.label2.setText(str(self.dial2.value()))
Esempio n. 12
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.slider = QSlider(
            Qt.Horizontal,
            self)  # 슬라이더 객체 생성(가로로 만들기), 수평으로 만들건지 수직으로 만들건지 내장 [상수]로 보내준다.
        # 상수는 대부분 Qt가 가지고 있기 때문에 값을 Qt에서 꺼내온다.(Qt.Horizontal / Qt.Vertical)
        self.slider.move(30, 30)  # 위치 설정
        self.slider.setRange(0, 50)  # 슬라이더의 min, max값 설정
        self.slider.setSingleStep(2)  # 한 번 이동시 이동할 틱 값 설정

        self.dial = QDial(self)  # 다이얼 객체 생성
        self.dial.move(30, 50)  # 다이얼 위치 설정
        self.dial.setRange(0, 50)  # 다이얼의 min, Max값 설정

        btn = QPushButton('Default', self)  # Default 라고 쓰여진 버튼 생성
        btn.move(35, 160)  # 버튼 위치 선정

        #slider 따로 dial 따로 하면 아래 3줄은 필요 없음
        self.slider.valueChanged.connect(
            self.dial.setValue)  # 슬라이더의 값에 변화가 일어나면 그 값을 dial.setValue로 보낸다.
        self.dial.valueChanged.connect(
            self.slider.setValue)  # 다이얼의 값이 변했을 때 그 값을 slider.setValue로 보낸다.
        btn.clicked.connect(
            self.button_clicked
        )  # 버튼이 클릭되었을 때 그 값을 button_clicked로 보내준다.(사용자가 만드는 함수)

        self.setWindowTitle('QSlider and QDial')
        self.setGeometry(300, 300, 400, 200)
        self.show()

    def button_clicked(self):
        self.slider.setValue(0)  # 슬라이더의 값을 0으로 설정
        self.dial.setValue(0)  # 다이얼의 값을 0으로 설정
Esempio n. 13
0
class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.title = 'Ex5.8_QSlider_Qdial'
        self.posXY = (1200, 50)
        self.windowSize = (370, 250)
        self.initUI()

    def initUI(self):
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.move(30, 30)
        self.slider.setRange(0, 50)
        self.slider.setSingleStep(2)

        self.dial = QDial(self)
        self.dial.move(30, 60)
        self.dial.setRange(0, 50)
        self.dial.setNotchesVisible(True)

        btn = QPushButton('RESET', self)
        btn.move(35, 190)

        self.slider.valueChanged.connect(self.dial.setValue)
        self.dial.valueChanged.connect(self.slider.setValue)
        btn.clicked.connect(self.button_clicked)

        self.show_basic()

    def button_clicked(self):
        self.slider.setValue(0)
        self.dial.setValue(0)


    def show_basic(self):
        self.setWindowTitle(self.title)
        self.setGeometry(*self.posXY, *self.windowSize)
        self.show()
Esempio n. 14
0
class Temperature_Page(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.NowTemperature = QLCDNumber(self)
        self.WantTemperature = QLCDNumber(self)
        self.SettingDial = QDial(self)
        self.lbNow = QLabel("현재 온도", self)
        self.lbWant = QLabel("희망 온도", self)
        self.NowFont = self.lbNow.font()
        self.NowFont.setPointSize(40)
        self.NowFont.setBold(True)

        self.lbNow.resize(300, 50)
        self.lbNow.move(50, 50)
        self.lbNow.setAlignment(Qt.AlignCenter)
        self.lbNow.setFont(self.NowFont)

        self.lbWant.resize(300, 50)
        self.lbWant.move(400, 50)
        self.lbWant.setAlignment(Qt.AlignCenter)
        self.lbWant.setFont(self.NowFont)

        self.NowTemperature.resize(300, 100)
        self.NowTemperature.move(50, 130)

        self.WantTemperature.resize(300, 100)
        self.WantTemperature.move(400, 130)

        self.SettingDial.resize(190, 190)
        self.SettingDial.setRange(-20, 20)
        self.SettingDial.setNotchesVisible(True)
        self.SettingDial.move(460, 250)
        self.NowTemperature.display(sensorValue)

        self.SettingDial.valueChanged.connect(self.WantTemperature.display)
Esempio n. 15
0
class Image(QWidget):
    def __init__(self, image_path):
        super().__init__()
        self.title = "Image Processing"
        self.left = 10
        self.top = 10
        self.width = 500
        self.height = 250
        self.thresh_type = "cv2.THRESH_BINARY"
        self.image_path = image_path
        self.image = cv2.imread(self.image_path)
        self.image_gray = cv2.cvtColor(self.image, cv2.COLOR_BGR2GRAY)
        self.dial1 = QDial(self)
        self.dial2 = QDial(self)
        self.im_label = QLabel(self)
        self.cb1 = QComboBox(self)
        self.cb2 = QComboBox(self)
        self.label1 = QLabel(self)
        self.label2 = QLabel(self)
        self.reset_button = QPushButton("Revert changes", self)

        self.updateImage(self.image_gray)
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.dial1.setMinimum(0)
        self.dial1.setMaximum(255)
        self.dial2.setMinimum(0)
        self.dial2.setMaximum(255)
        self.dial1.move(20, 130)
        self.dial2.move(120, 130)
        self.dial1.valueChanged.connect(self.dial1_changed)
        self.dial2.valueChanged.connect(self.dial2_changed)

        self.cb1.addItems(
            ["BINARY", "BINARY_INV", "TRUNC", "TOZERO", "TOZERO_INV"])
        self.cb1.activated[str].connect(self.combo1_selection)
        self.cb1.move(40, 50)
        self.cb2.move(280, 50)

        self.reset_button.move(280, 170)
        self.reset_button.clicked.connect(self.revert_button_pressed)

        self.label1.setText("000")
        self.label2.setText("000")
        self.label1.move(60, 120)
        self.label2.move(160, 120)

        self.show()

    def thresh(self):
        _, temp = cv2.threshold(self.image_gray, self.dial1.value(),
                                self.dial2.value(), eval(self.thresh_type))
        self.updateImage(temp)

    def updateImage(self, gray):
        cv2.imshow('image', gray)

    def dial1_changed(self):
        self.thresh()
        self.change_labels()

    def dial2_changed(self):
        self.thresh()
        self.change_labels()

    def combo1_selection(self, text):
        self.thresh_type = "cv2.THRESH_" + text
        self.thresh()

    def revert_button_pressed(self):
        cv2.imshow('image', self.image_gray)
        self.dial1.setValue(0)
        self.dial2.setValue(0)

    def change_labels(self):
        self.label1.setText(str(self.dial1.value()))
        self.label2.setText(str(self.dial2.value()))
Esempio n. 16
0
class UIControl(QFrame):
    def __init__(self, graphicUI):
        super().__init__()
        self.setAutoFillBackground(True)
        self.setFrameShape(QFrame.StyledPanel)
        self.graphicUI = graphicUI
        self.labelWidth = 130

        self.xmlControll = XS
        xmlPath = Path("temp/" + AO.getDate() + ".xml")
        if (xmlPath.exists()):
            self.xmlControll.loadLastData()

        # Label for Temperature-Text
        self.labelTempText = QLabel(self)
        self.labelTempText.setText("Temperature shower [K] : ")
        self.labelTempText.setFixedWidth(180)
        self.labelTempText.move(20, 30)

        # Label for Temperature
        self.labelTemp = QLabel(self)
        self.labelTemp.setText("290")
        self.labelTemp.move(200, 30)
        self.labelTemp.setFixedWidth(30)
        self.labelTemp.setStyleSheet("background-color: rgb(255, 255, 255)")

        # Dial-to regulate Temperature
        self.dial = QDial(self)
        self.dial.setMaximum(P.hotTankTemp)
        self.dial.setMinimum(P.coldTankTemp)
        self.dial.setNotchesVisible(True)
        self.dial.setFocusPolicy(Qt.StrongFocus)
        self.dial.move(100, 60)
        self.dial.valueChanged.connect(self.labelTemp.setNum)

        # Button to start shower
        self.startButton = QPushButton(self)
        self.startButton.setText("Start Shower")
        self.startButton.move(10, 200)
        self.startButton.clicked.connect(self.handleShowerButton)

        # Button to refill tanks
        self.refillButton = QPushButton(self)
        self.refillButton.setText("Refill Tanks")
        self.refillButton.move(140, 200)
        self.refillButton.clicked.connect(self.refillTanks)

        # Button to start collector
        self.startCollectorButton = QPushButton(self)
        self.startCollectorButton.setText("Start Collector")
        self.startCollectorButton.move(270, 200)
        self.startCollectorButton.clicked.connect(self.handleCollector)

        # Label for Time-Text
        self.labelTimeText = QLabel(self)
        self.labelTimeText.setText("Time (hh:mm): ")
        self.labelTimeText.setFixedWidth(180)
        self.labelTimeText.move(10, 270)

        # Label for Time
        self.labelTime = QLabel(self)
        t = AO.getTime()
        self.labelTime.setText(t)
        self.labelTime.move(220, 270)
        self.labelTime.setFixedWidth(self.labelWidth)
        self.labelTime.setStyleSheet("background-color: rgb(255, 255, 255)")

        # Label for Temperature-Outside-Text
        self.labelTempOutText = QLabel(self)
        self.labelTempOutText.setText("Ambient temperature [K]: ")
        self.labelTempOutText.setFixedWidth(180)
        self.labelTempOutText.move(10, 300)

        # Label for Temperature-Outside
        self.labelTempOut = QLabel(self)
        t = AO.getTemperature()
        self.labelTempOut.setText(str(t))
        self.labelTempOut.move(220, 300)
        self.labelTempOut.setFixedWidth(self.labelWidth)
        self.labelTempOut.setStyleSheet("background-color: rgb(255, 255, 255)")

        # Label for Temperature-hot-tank-Text
        self.labelTempTankHotText = QLabel(self)
        self.labelTempTankHotText.setText("Temperature hot tank [K]: ")
        self.labelTempTankHotText.setFixedWidth(180)
        self.labelTempTankHotText.move(10, 330)

        # Label for Temperature-tank-hot
        self.labelTempTankHot = QLabel(self)
        self.labelTempTankHot.setText(str(P.hotTankTemp))
        self.labelTempTankHot.move(220, 330)
        self.labelTempTankHot.setFixedWidth(self.labelWidth)
        self.labelTempTankHot.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Temperature-cold-tank-Text
        self.labelTempTankColdText = QLabel(self)
        self.labelTempTankColdText.setText("Temperature cold tank [K]: ")
        self.labelTempTankColdText.setFixedWidth(180)
        self.labelTempTankColdText.move(10, 360)

        # Label for Temperature-tank-cold
        self.labelTempTankCold = QLabel(self)
        self.labelTempTankCold.setText(str(P.coldTankTemp))
        self.labelTempTankCold.move(220, 360)
        self.labelTempTankCold.setFixedWidth(self.labelWidth)
        self.labelTempTankCold.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Temperature-Collector-Text
        self.labelTempCollectorText = QLabel(self)
        self.labelTempCollectorText.setText("Temperature collector [K]: ")
        self.labelTempCollectorText.setFixedWidth(180)
        self.labelTempCollectorText.move(10, 390)

        # Label for Temperature-Collector
        self.labelTempCollector = QLabel(self)
        self.labelTempCollector.setText("290")
        self.labelTempCollector.move(220, 390)
        self.labelTempCollector.setFixedWidth(self.labelWidth)
        self.labelTempCollector.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Collector-Mass-Of-Water-Text
        self.labelCollectorMassText = QLabel(self)
        self.labelCollectorMassText.setText("Collector mass [Kg]: ")
        self.labelCollectorMassText.setFixedWidth(180)
        self.labelCollectorMassText.move(10, 420)

        # Label for Collector-Mass-Of-Water
        self.labelCollectorMass = QLabel(self)
        self.labelCollectorMass.setText("20")
        self.labelCollectorMass.move(220, 420)
        self.labelCollectorMass.setFixedWidth(self.labelWidth)
        self.labelCollectorMass.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Tank-Mass-Of-Water-Text
        self.labelTankHotMassText = QLabel(self)
        self.labelTankHotMassText.setText("Tank hot mass [Kg]: ")
        self.labelTankHotMassText.setFixedWidth(180)
        self.labelTankHotMassText.move(10, 450)

        # Label for Tank-Mass-Of-Water
        self.labelTankHotMass = QLabel(self)
        self.labelTankHotMass.setText("300")
        self.labelTankHotMass.move(220, 450)
        self.labelTankHotMass.setFixedWidth(self.labelWidth)
        self.labelTankHotMass.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Tank-Mass-Of-Cold-Water-Text
        self.labelTankMassColdText = QLabel(self)
        self.labelTankMassColdText.setText("Tank cold mass [Kg]: ")
        self.labelTankMassColdText.setFixedWidth(180)
        self.labelTankMassColdText.move(10, 480)

        # Label for Tank-Mass-Of-Water
        self.labelTankMassCold = QLabel(self)
        self.labelTankMassCold.setText("300")
        self.labelTankMassCold.move(220, 480)
        self.labelTankMassCold.setFixedWidth(self.labelWidth)
        self.labelTankMassCold.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Solar-Irradiance-Text
        self.labelSolarIrradianceText = QLabel(self)
        self.labelSolarIrradianceText.setText("Solar irradiance [W/m²]: ")
        self.labelSolarIrradianceText.setFixedWidth(180)
        self.labelSolarIrradianceText.move(10, 510)

        # Label for Solar-Irradiance
        self.labelSolarIrradiance = QLabel(self)
        self.labelSolarIrradiance.setText(AO.getSolarIrradianceString())
        self.labelSolarIrradiance.move(220, 510)
        self.labelSolarIrradiance.setFixedWidth(self.labelWidth)
        self.labelSolarIrradiance.setStyleSheet(
            "background-color: rgb(255, 255, 255)")

        # Label for Solar-Irradiance-Text
        self.labelSolarIrradianceText = QLabel(self)
        self.labelSolarIrradianceText.setText("Statistics:")
        self.labelSolarIrradianceText.setFixedWidth(180)
        self.labelSolarIrradianceText.move(10, 570)

        # Button to show heatening-statistics
        self.diagrammButton = QPushButton(self)
        self.diagrammButton.setText("Heatening")
        self.diagrammButton.move(10, 600)
        self.diagrammButton.setFixedWidth(90)
        self.diagrammButton.setToolTip(
            'Show diagram of Runge-Kutta-Calculation for collector heating the hot tank'
        )
        self.diagrammButton.clicked.connect(self.showDiagrams)

        # Button to show temp - statistics
        self.statisticTempButton = QPushButton(self)
        self.statisticTempButton.setText("Temperature")
        self.statisticTempButton.move(10, 650)
        self.statisticTempButton.setFixedWidth(90)
        self.statisticTempButton.setToolTip(
            'Show temperature - statistics of the day')
        self.statisticTempButton.clicked.connect(self.showTempStatistic)

        # Button to show level - statistics
        self.statisticLevelButton = QPushButton(self)
        self.statisticLevelButton.setText("Fluid-level")
        self.statisticLevelButton.move(150, 600)
        self.statisticLevelButton.setFixedWidth(90)
        self.statisticLevelButton.setToolTip(
            'Show fluid - level - statistics of the day')
        self.statisticLevelButton.clicked.connect(self.showLevelStatistic)

        # Button to clear - statistics
        self.clearStatButton = QPushButton(self)
        self.clearStatButton.setText("Clear")
        self.clearStatButton.move(150, 650)
        self.clearStatButton.setFixedWidth(90)
        self.clearStatButton.setToolTip(
            'Clear the daily statistics and start a new round')
        self.clearStatButton.setStyleSheet(
            "background-color:rgb(220, 255, 255)")
        self.clearStatButton.clicked.connect(self.clearStatistic)

        # Label for Information
        self.labelInformation = QLabel(self)
        self.labelInformation.setFixedWidth(350)
        self.labelInformation.setFixedHeight(100)
        self.labelInformation.move(10, 700)

        self.setFrameShadow(QFrame.Sunken)
        self.setStyleSheet("background-color: rgb(240, 255, 255)")
        self.setFixedHeight(800)
        self.setFixedWidth(400)

        try:
            _thread.start_new_thread(self.updateLabelsAndValues, ())
            _thread.start_new_thread(BO.TempChanging, ())
        except:
            print("Error: unable to start thread")

    def handleShowerButton(self):
        if (P.showerOn):
            self.stopShower()
        else:
            self.startShower()

    def startShower(self):
        self.startButton.setText("Stop Shower")
        P.showerOn = True
        self.blockButtons()
        self.graphicUI.updateGraphics()
        Tshower = int(self.labelTemp.text())
        BO.flowRate(Tshower)
        self.labelInformation.setText("Shower startet, Hot/Cold [kg/s]: " +
                                      P.flowRateHC)
        self.xmlControll.save()

    def stopShower(self):
        self.labelInformation.setText("Shower stoped")
        self.startButton.setText("Start Shower")
        P.showerOn = False
        self.freeButtons()
        self.graphicUI.updateGraphics()
        self.xmlControll.save()

    def emptyTanks(self):
        if (not AO.getLevelColdTank()):
            self.labelInformation.setText("Cold Tank is empty")
        if (not AO.getLevelHotTank()):
            self.labelInformation.setText("Hot Tank is empty")

    def updateLabelsAndValues(self):
        while (True):
            self.labelTankHotMass.setText(str(P.fluidLevelHot))
            self.labelTankMassCold.setText(str(P.fluidLevelCold))
            self.labelTime.setText(AO.getTime())
            self.labelSolarIrradiance.setText(AO.getSolarIrradianceString())
            self.labelTempTankHot.setText(str(round(P.hotTankTemp, 4)))
            self.labelTempTankCold.setText(str(round(P.coldTankTemp, 4)))
            self.labelTempCollector.setText(str(round(P.collectorTemp, 4)))
            self.dial.setMaximum(P.hotTankTemp)
            self.dial.setMinimum(P.coldTankTemp)
            if (P.collectorIsOn):
                BO.startTimeCalculator()
                self.labelInformation.setText(
                    "Collector is running.\nCalculated Time ~" +
                    str(round(P.calcTimeForHeatUp)) + "sec")

            if (P.collectorIsOn and P.hotTankTemp >= 340):
                self.startCollectorButton.setText("Start Collector")
                self.labelInformation.setText(
                    "Collector stoped.\nHot Tank Temp = " +
                    str(round(P.hotTankTemp, 2)) + "K")
                self.freeButtons()
                P.collectorIsOn = False
            AO.setSolarIrradiance()
            AO.getTemperature()
            self.graphicUI.updateGraphics()
            self.emptyTanks()
            self.xmlControll.save()
            time.sleep(5)

    def refillTanks(self):
        self.labelInformation.setText("Tanks where refilled")
        BO.refill()
        self.graphicUI.updateGraphics()
        self.xmlControll.save()

    def blockButtons(self):
        self.clearStatButton.setEnabled(False)
        self.statisticLevelButton.setEnabled(False)
        self.statisticTempButton.setEnabled(False)
        self.diagrammButton.setEnabled(False)

    def freeButtons(self):
        self.clearStatButton.setEnabled(True)
        self.statisticLevelButton.setEnabled(True)
        self.statisticTempButton.setEnabled(True)
        self.diagrammButton.setEnabled(True)

    def handleCollector(self):
        if (not P.collectorIsOn):
            self.startCollector()
        else:
            self.stopCollector()

    def startCollector(self):
        if (P.currentSolarIrradiance != 0):
            self.startCollectorButton.setText("Stop Collector")
            self.labelInformation.setText("Collector started")
            P.collectorIsOn = True
            P.collectorFlowRate = 0.8
            self.blockButtons()
            self.graphicUI.updateGraphics()
        else:
            self.labelInformation.setText(
                "Collector is only working when\ncurrent solar irradiance is not zero."
            )

    def stopCollector(self):
        self.startCollectorButton.setText("Start Collector")
        self.labelInformation.setText("Collector stoped")
        P.collectorIsOn = False
        P.collectorFlowRate = 0
        self.freeButtons()
        self.graphicUI.updateGraphics()

    def showDiagrams(self):
        Stat.showCalculationStatistics()

    def showTempStatistic(self):
        xmlPath = str("temp/" + AO.getDate() + ".xml")
        if (os.path.exists(xmlPath)):
            Stat.showTempStatistics()

    def showLevelStatistic(self):
        xmlPath = str("temp/" + AO.getDate() + ".xml")
        if (os.path.exists(xmlPath)):
            Stat.showLevelStatistics()

    def clearStatistic(self):
        self.labelInformation.setText(
            "New round: Temperatures and fluid-levels at\ninitial (no statistics of both available)."
        )
        self.xmlControll.clearStatistics()
        P.fluidLevelCold = 300
        P.fluidLevelHot = 300
        P.hotTankTemp = 320
        P.coldTankTemp = 290
        P.collectorTemp = 300
        self.graphicUI.updateGraphics()
Esempio n. 17
0
class MouseTracker(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setGeometry(300, 300, 700, 700)
        self.setWindowTitle('Mouse Tracker')
        self.label = QLabel(self)
        self.label.resize(200, 40)
        self.label.move(100, 40)
        self.setMouseTracking(True)

        self.laabel = QLabel(self)
        self.laabel.resize(200, 40)
        self.laabel.move(200, 300)

        self.laabel1 = QLabel(self)
        self.laabel1.resize(200, 40)
        self.laabel1.move(300, 100)

        self.dial1 = QDial(self)
        self.dial1.move(X1, Y1)
        self.dial1.resize(100, 100)
        self.dial1.setWrapping(True)
        self.dial1.setMinimum(0)
        self.dial1.setMaximum(360)

        self.dial2 = QDial(self)
        self.dial2.move(X2, Y2)
        self.dial2.resize(100, 100)
        self.dial2.setWrapping(True)
        self.dial2.setMinimum(0)
        self.dial2.setMaximum(360)

        self.show()

    def mouseMoveEvent(self, event):
        x = event.x()
        y = event.y()
        if x < (X1 + xshift1) and y < (Y1 + yshift1): q = 1
        elif x > (X1 + xshift1) and y < (Y1 + yshift1): q = 2
        elif x > (X1 + xshift1) and y > (Y1 + yshift1): q = 3
        elif x < (X1 + xshift1) and y > (Y1 + yshift1): q = 4
        self.label.setText('Mouse coords: ( %d : %d )' % (x, y))
        if y != (Y1 + yshift1) and x != (X1 + xshift1):
            a = math.degrees(
                math.atan(((Y1 + yshift1) - y) / ((X1 + xshift1) - x)))
            if q == 1: a = a
            elif q == 2: a = 180 + a
            elif q == 3: a = 180 + a
            elif q == 4: a = a
        else:
            if x < (X1 + xshift1) and y == (Y1 + yshift1): a = 0
            elif x == (X1 + xshift1) and y < (Y1 + yshift1): a = 90
            elif x > (X1 + xshift1) and y == (Y1 + yshift1): a = 180
            elif x == (X1 + xshift1) and y > (Y1 + yshift1): a = 270

        x = event.x()
        y = event.x()
        q2 = 0
        b = 0
        if x < (X2 + xshift2) and y < (Y2 + yshift2): q2 = 1
        elif x > (X2 + xshift2) and y < (Y2 + yshift2): q2 = 2
        elif x > (X2 + xshift2) and y > (Y2 + yshift2): q2 = 3
        elif x < (X2 + xshift2) and y > (Y2 + yshift2): q2 = 4
        self.label.setText('Mouse coords: ( %d : %d )' % (x, y))
        if (y - 150) != (Y2 + yshift2) and (x - 150) != (X2 + xshift2):
            b = math.degrees(
                math.atan(((Y2 + yshift2) - (y - 150)) / ((X2 + xshift2) -
                                                          (x - 150))))
            if q2 == 1: b = b
            elif q2 == 2: b = 180 + b
            elif q2 == 3: b = 180 + b
            elif q2 == 4: b = b
        else:
            if x < (X2 + xshift2) and y == (Y2 + yshift2): b = 0
            elif x == (X2 + xshift2) and y < (Y2 + yshift2): b = 90
            elif x > (X2 + xshift2) and y == (Y2 + yshift2): b = 180
            elif x == (X2 + xshift2) and y > (Y2 + yshift2): b = 270

        self.dial1.setValue(int(a) + 90)
        self.dial2.setValue(int(b) + 90)
        self.laabel1.setText(str(a))
Esempio n. 18
0
 def Drehknopf(self):
     dial = QDial(self)
     dial.move(850, 10)
     dial.setValue(30)
Esempio n. 19
0
    def create_ui(self):
        # 1.文字标签
        # QLabel(显示的文字, 父标签/放到哪个窗口上)
        label1 = QLabel('用户名:', self)
        # 一般不常用的移动坐标
        label1.move(50, 10)

        # 2.按钮
        btn1 = QPushButton('登录', self)
        btn1.move(50, 50)
        # css语法:选择器{属性1:属性值1; 属性2:属性值2;..}
        # color - 字体颜色,对应的值:颜色单词, rbg(255, 0, 0)
        #
        btn1.setStyleSheet('QPushButton{}')
        btn2 = QRadioButton('男', self)
        btn2.move(50, 100)
        btn3 = QCheckBox('篮球', self)
        btn3.move(50, 150)
        btn4 = QCommandLinkButton('hello', 'hellowword', self)
        btn4.move(50, 200)

        b1 = QDialogButtonBox.StandardButton.Ok
        b2 = QDialogButtonBox.StandardButton.Cancel
        btn5 = QDialogButtonBox(b2, self)
        btn5.move(50, 300)

        # 3.输入框
        input1 = QLineEdit(self)
        input1.move(150, 10)
        input2 = QLineEdit('admin', self)
        input2.move(150, 50)
        input1.setText('张三')
        # 富文本
        input3 = QTextEdit('张三', self)
        input3.move(50, 300)
        # 设置成只读
        input3.setReadOnly(True)
        # 只能显示纯文本
        input4 = QPlainTextEdit(self)
        input4.move(300, 10)
        # 输入数值
        input5 = QSpinBox(self)
        input5.move(100, 100)
        input5.setMinimum(10)
        input5.setMaximum(20)
        input5.setValue(15)
        print(input5.value())  # 获取当前值
        # 输入小数
        input6 = QDoubleSpinBox(self)
        input6.move(100, 150)
        # 下拉菜单
        input7 = QComboBox(self)
        input7.addItems(['item1', 'item2'])
        input7.move(150, 200)
        print(input7.currentText())  # 获取当前选中的选项,适用input8
        input8 = QFontComboBox(self)
        input8.move(350, 300)
        input8.setCurrentIndex(2)
        print(input8.currentText())
        label1.setFont(input8.currentFont())
        # 日期选择
        input9 = QDateEdit(date.today(), self)
        input9.move(300, 400)
        # 选择颜色
        input10 = QColorDialog(self)
        input10.move(400, 400)
        # input10.show()

        input11 = QDial(self)
        input11.move(300, 200)

        input12 = QSlider(self)
        input12.move(430, 350)
        input12.setMaximum(100)
        input12.setMinimum(-100)
        input12.setValue(20)
        input12.setOrientation(Qt.Horizontal)  # 设置为水平方向