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
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))
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)
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))