1515import time
1616import threading
1717
18- from PyQt5 .QtWidgets import (
18+ from PySide6 .QtWidgets import (
1919 QApplication , QMainWindow , QWidget , QLabel , QFrame ,
2020 QHBoxLayout , QVBoxLayout , QSizePolicy , QScrollArea
2121)
22- from PyQt5 .QtCore import Qt , QTimer , QRectF , QPointF , pyqtSignal , QObject
23- from PyQt5 .QtGui import (
22+ from PySide6 .QtCore import Qt , QTimer , QRectF , QPointF , Signal , QObject
23+ from PySide6 .QtGui import (
2424 QPainter , QColor , QPen , QBrush , QFont , QConicalGradient , QPainterPath ,
2525 QPixmap , QIcon
2626)
@@ -84,22 +84,22 @@ def set_value(self, v: float):
8484
8585 def paintEvent (self , event ):
8686 p = QPainter (self )
87- p .setRenderHint (QPainter .Antialiasing )
87+ p .setRenderHint (QPainter .RenderHint . Antialiasing )
8888
8989 side = min (self .width (), self .height ()) - 10
9090 rect = QRectF ((self .width () - side ) / 2 ,
9191 (self .height () - side ) / 2 ,
9292 side , side )
9393
9494 # ── Background track ──────────────────────────────────────
95- pen_bg = QPen (QColor ("#1A2A40" ), 8 , Qt .SolidLine , Qt .FlatCap )
95+ pen_bg = QPen (QColor ("#1A2A40" ), 8 , Qt .PenStyle . SolidLine , Qt . PenCapStyle .FlatCap )
9696 p .setPen (pen_bg )
9797 p .drawArc (rect , 225 * 16 , - 270 * 16 ) # 270° arc, starts at 225°
9898
9999 # ── Foreground arc (value / 360 × 270°) ───────────────────
100100 span = int ((self ._value / 360.0 ) * 270 * 16 )
101101 grad_color = self .color
102- pen_fg = QPen (grad_color , 8 , Qt .SolidLine , Qt .FlatCap )
102+ pen_fg = QPen (grad_color , 8 , Qt .PenStyle . SolidLine , Qt . PenCapStyle .FlatCap )
103103 p .setPen (pen_fg )
104104 p .drawArc (rect , 225 * 16 , - span )
105105
@@ -117,16 +117,16 @@ def paintEvent(self, event):
117117 back_x = cx - hub_r * _math .cos (angle_rad )
118118 back_y = cy + hub_r * _math .sin (angle_rad )
119119 # Draw shadow
120- pen_shadow = QPen (QColor ("#000000" ), 4 , Qt .SolidLine , Qt .RoundCap )
120+ pen_shadow = QPen (QColor ("#000000" ), 4 , Qt .PenStyle . SolidLine , Qt . PenCapStyle .RoundCap )
121121 p .setPen (pen_shadow )
122122 p .drawLine (QPointF (back_x + 1 , back_y + 1 ), QPointF (tip_x + 1 , tip_y + 1 ))
123123 # Draw needle
124- pen_needle = QPen (grad_color , 2.5 , Qt .SolidLine , Qt .RoundCap )
124+ pen_needle = QPen (grad_color , 2.5 , Qt .PenStyle . SolidLine , Qt . PenCapStyle .RoundCap )
125125 p .setPen (pen_needle )
126126 p .drawLine (QPointF (back_x , back_y ), QPointF (tip_x , tip_y ))
127127
128128 # ── Centre dot ────────────────────────────────────────────
129- p .setPen (Qt .NoPen )
129+ p .setPen (Qt .PenStyle . NoPen )
130130 p .setBrush (QBrush (grad_color ))
131131 p .drawEllipse (QPointF (cx , cy ), 4 , 4 )
132132
@@ -168,7 +168,7 @@ def __init__(self, motor: SurgicalRobot.Motors, parent=None):
168168 self .name = JOINT_NAMES [motor ]
169169 self ._angle = 180.0
170170
171- self .setFrameShape (QFrame .Box )
171+ self .setFrameShape (QFrame .Shape . Box )
172172 self .setStyleSheet (f"""
173173 JointRow {{
174174 background-color: { BG_PANEL } ;
@@ -198,9 +198,9 @@ def _build_ui(self):
198198 gauge_col .setSpacing (2 )
199199 self .gauge = ArcGauge (self .color )
200200 self .gauge .set_value (180.0 )
201- gauge_col .addWidget (self .gauge , alignment = Qt .AlignHCenter )
201+ gauge_col .addWidget (self .gauge , alignment = Qt .AlignmentFlag . AlignHCenter )
202202 self .angle_lbl = QLabel ("180.0°" )
203- self .angle_lbl .setAlignment (Qt .AlignCenter )
203+ self .angle_lbl .setAlignment (Qt .AlignmentFlag . AlignCenter )
204204 self .angle_lbl .setStyleSheet (
205205 f"color: { self .color } ; font-size: 20px; font-weight: bold; "
206206 f"background: transparent;"
@@ -254,7 +254,7 @@ def __init__(self, parent=None):
254254 super ().__init__ (parent )
255255 self ._angles : dict = {m : 180.0 for m in _MOTORS_ORDERED }
256256 self .setMinimumWidth (260 )
257- self .setSizePolicy (QSizePolicy .Expanding , QSizePolicy .Expanding )
257+ self .setSizePolicy (QSizePolicy .Policy . Expanding , QSizePolicy . Policy .Expanding )
258258 self .setStyleSheet (f"background-color: { BG_PANEL } ;" )
259259
260260 def update_angles (self , angles : dict ):
@@ -266,14 +266,14 @@ def update_angles(self, angles: dict):
266266 def paintEvent (self , event ):
267267 w , h = self .width (), self .height ()
268268 p = QPainter (self )
269- p .setRenderHint (QPainter .Antialiasing )
269+ p .setRenderHint (QPainter .RenderHint . Antialiasing )
270270
271271 # Background
272272 p .fillRect (self .rect (), QColor (BG_PANEL ))
273273
274274 # Title
275275 p .setPen (QPen (QColor ("#445566" )))
276- p .setFont (QFont ("Courier New" , 11 , QFont .Bold ))
276+ p .setFont (QFont ("Courier New" , 11 , QFont .Weight . Bold ))
277277 p .drawText (12 , 22 , "ARM VISUALIZATION" )
278278
279279 # Scale segment length so the full arm (5 links) fills ~90 % of the
@@ -319,7 +319,7 @@ def paintEvent(self, event):
319319 color = QColor (JOINT_COLORS [motor ])
320320 x0 , y0 = points [i ]
321321 x1 , y1 = points [i + 1 ]
322- pen = QPen (color , link_pen_width , Qt .SolidLine , Qt .RoundCap )
322+ pen = QPen (color , link_pen_width , Qt .PenStyle . SolidLine , Qt . PenCapStyle .RoundCap )
323323 p .setPen (pen )
324324 p .drawLine (QPointF (x0 , y0 ), QPointF (x1 , y1 ))
325325
@@ -351,7 +351,7 @@ def paintEvent(self, event):
351351 # joint name label (abbreviated, 3 chars)
352352 name = JOINT_NAMES [motor ][:3 ]
353353 p .setPen (QPen (color ))
354- p .setFont (QFont ("Courier New" , 16 , QFont .Bold ))
354+ p .setFont (QFont ("Courier New" , 16 , QFont .Weight . Bold ))
355355 label_x = cx + jr + 8
356356 label_y = cy + 6
357357 p .drawText (QPointF (label_x , label_y ), name )
@@ -402,7 +402,7 @@ def _build_ui(self):
402402 if not _logo_px .isNull ():
403403 logo_lbl = QLabel ()
404404 logo_lbl .setStyleSheet ("background: transparent;" )
405- logo_lbl .setPixmap (_logo_px .scaled (56 , 56 , Qt .KeepAspectRatio , Qt .SmoothTransformation ))
405+ logo_lbl .setPixmap (_logo_px .scaled (56 , 56 , Qt .AspectRatioMode . KeepAspectRatio , Qt . TransformationMode .SmoothTransformation ))
406406 h_layout .addWidget (logo_lbl )
407407
408408 rti_lbl = QLabel ("RTI Connext" )
@@ -593,7 +593,7 @@ def run(self):
593593 self .window .show ()
594594 print ("Started Arm" )
595595
596- app .exec_ ()
596+ app .exec ()
597597
598598 print ("Shutting down Arm" )
599599 self .arm_status .status = Common .DeviceStatuses .OFF
0 commit comments