-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWheelImage.py
62 lines (49 loc) · 2.09 KB
/
WheelImage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
from PySide6.QtWidgets import QApplication, QWidget, QGraphicsView, QGraphicsScene, QVBoxLayout
from PySide6.QtGui import QPixmap
from PySide6.QtCore import Qt
from NetworkTableManager import NetworkTableManager
class wheelImage(QWidget):
def __init__(self):
super().__init__()
# Set up the widget layout
layout = QVBoxLayout()
# Create a QGraphicsView and QGraphicsScene
self.view = QGraphicsView(self)
scene = QGraphicsScene(self)
# Load an image into a QPixmap
pixmap = QPixmap('wheeldir.png')
# Create an item with the pixmap and add it to the scene
self.pixmap_item = scene.addPixmap(pixmap)
self.pixmap_item.setTransformOriginPoint(self.pixmap_item.boundingRect().center())
# Set the scene for the view
self.view.setScene(scene)
# Add the view to the layout
layout.addWidget(self.view)
# Set the layout for the window
self.setLayout(layout)
self.networkStuff("defaultParameter","networkTable","networkTableEntry")
def networkStuff(self,parameterName,tableName,entryName):
self.parameterName = parameterName
self.tableName = tableName
self.entryName = entryName
self.NTManager = NetworkTableManager(
tableName=tableName, entryName=entryName
)
self.NTManager.new_value_available.connect(self.updateFromNT)
if self.NTManager.getValue() is not None:
self.updateFromNT(self.NTManager.getValue())
def updateFromNT(self, message):
if (isinstance(message, tuple)):
self.pixmap_item.setRotation((message[1]%1)*360)
#self.pixmap_item.setRotation(float(message[1]))
#self.setText(self.parameterName + str(message))
#pass
def rotate_image(self, angle):
"""
Rotates the image by 90 degrees.
"""
#current_angle = self.pixmap_item.rotation()
new_angle = angle # Rotate by 90 degrees each time
self.pixmap_item.setRotation(new_angle) # Apply the new rotation
print("hi")