BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 127 forks source link

Opening a telemetry screen with a button on another telemetry screen #1793

Open KodiakLiDAR opened 1 year ago

KodiakLiDAR commented 1 year ago

Hello OpenC3 Team,

I would like to open one telemetry (child screen) screen by clicking a button on another telemetry screen (master screen).

I'd like to have one "master" telemetry screen with a series of buttons (one for each sub-system) that will open a "child" telemetry screen with relevant data for each button's respective subsystem.

Essentially, wondering if capability exists for developing a telemetry screen button that will launch a separate telemetry screen.

Thanks so much for any and all help.

Kindly, Kodiak

AbdelAzizMohamedMousa commented 1 year ago

Yes, it is possible to develop a telemetry screen button that will launch a separate telemetry screen. Here's an example code snippet in Python that demonstrates how to do it using the PyQt5 library: `from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton

class MasterTelemetryScreen(QMainWindow): def init(self): super().init() self.setWindowTitle("Master Telemetry Screen")

    button1 = QPushButton("Subsystem 1", self)
    button1.setGeometry(50, 50, 100, 30)
    button1.clicked.connect(lambda: self.open_child_screen("Subsystem 1"))

    button2 = QPushButton("Subsystem 2", self)
    button2.setGeometry(50, 100, 100, 30)
    button2.clicked.connect(lambda: self.open_child_screen("Subsystem 2"))

def open_child_screen(self, subsystem):
    child_screen = ChildTelemetryScreen(subsystem)
    child_screen.show()

class ChildTelemetryScreen(QMainWindow): def init(self, subsystem): super().init() self.setWindowTitle(f"{subsystem} Telemetry Screen")

    # Add widgets and set layout for the child screen here

app = QApplication([]) master_screen = MasterTelemetryScreen() masterscreen.show() app.exec() `

In this example, the MasterTelemetryScreen class represents the master screen with buttons for each subsystem, and the ChildTelemetryScreen class represents the child screen that will be opened when a button is clicked.

Each button is connected to a lambda function that calls the open_child_screen method of the MasterTelemetryScreen class with the appropriate subsystem name as an argument.

The open_child_screen method creates an instance of the ChildTelemetryScreen class with the subsystem name passed as a parameter, and then shows the child screen using the show method.

You can customize the ChildTelemetryScreen class to add widgets and layout as needed to display the telemetry data for the selected subsystem.