Skip to content

Commit

Permalink
Merge pull request #29 from cwruRobotics/atexit-gui-app-changes
Browse files Browse the repository at this point in the history
Remove dual inheritence for apps
  • Loading branch information
InvincibleRMC authored Sep 23, 2023
2 parents 120e88d + 9841302 commit e5d4b70
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 23 deletions.
27 changes: 12 additions & 15 deletions src/surface/gui/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,35 @@
from rclpy.node import Node


class App(Node, QWidget):
class App(QWidget):
"""Main app window."""

def __init__(self, node_name: str):
self.app: QApplication = QApplication(sys.argv)
rclpy.init()
super().__init__()
self.node = Node(node_name, parameter_overrides=[])

super().__init__(
node_name=node_name,
parameter_overrides=[])
super(QWidget, self).__init__()

self.declare_parameter('theme', '')
self.node.declare_parameter('theme', '')
self.resize(1850, 720)

def kill():
self.destroy_node()
rclpy.shutdown()

atexit.register(kill)
atexit.register(rclpy.shutdown)

def run_gui(self):
# Kills with Control + C
signal.signal(signal.SIGINT, signal.SIG_DFL)

if self.get_parameter('theme').get_parameter_value().string_value == "dark":
if self.node.get_parameter('theme').get_parameter_value().string_value == "dark":
qdarktheme.setup_theme()
elif self.get_parameter('theme').get_parameter_value().string_value == "watermelon":
elif self.node.get_parameter('theme').get_parameter_value().string_value == "watermelon":
# UGLY But WORKS
self.app.setStyleSheet("QWidget { background-color: green; color: pink; }")
else:
qdarktheme.setup_theme("light")
# Delete node now that we've used it to get params
self.node.destroy_node()

self.show()
sys.exit(self.app.exec())

# TODO: when the app closes it causes an error. Make not cause error?
self.app.exec()
8 changes: 4 additions & 4 deletions src/surface/gui/gui/operator_app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from gui.app import App
from gui.modules.logger import Logger
from gui.modules.seagrass import SeagrassWidget
from gui.modules.task_selector import TaskSelector
from gui.modules.timer import Timer
from gui.widgets.logger import Logger
from gui.widgets.seagrass import SeagrassWidget
from gui.widgets.task_selector import TaskSelector
from gui.widgets.timer import Timer
from PyQt6.QtWidgets import QGridLayout, QTabWidget, QWidget


Expand Down
4 changes: 2 additions & 2 deletions src/surface/gui/gui/pilot_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from gui.app import App
from gui.modules.arm import Arm
from gui.modules.video_widget import SwitchableVideoWidget
from gui.widgets.arm import Arm
from gui.widgets.video_widget import SwitchableVideoWidget
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QHBoxLayout

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Optional

from gui.modules.video_widget import PauseableVideoWidget
from gui.widgets.video_widget import PauseableVideoWidget
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (QFrame, QGridLayout, QHBoxLayout, QLabel,
QPushButton, QVBoxLayout, QWidget)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/surface/gui/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(
name=package_name,
version='0.0.0',
packages=[package_name, os.path.join(package_name, 'modules'),
packages=[package_name, os.path.join(package_name, 'widgets'),
os.path.join(package_name, 'event_nodes')],
data_files=[
('share/ament_index/resource_index/packages',
Expand Down

0 comments on commit e5d4b70

Please sign in to comment.