示例#1
0
  def eventFilter(self, object, event):
    '''
    On utilise eventFilter() pour "trapper" un evennement unique au plus tot apres la creation
    du controle car le nom n'est pas definit lors de l'appel d'__init() et je n'ai pas reussi
    a recuperer le signal objectNameChanged.
    '''
    if event.type() == QtCore.QEvent.DynamicPropertyChange:
      self.__myName = object.objectName()
      pictureBaseName = self.__imagePath + self.__myName

      if QtCore.QResource(pictureBaseName + ".svg").isValid():
        self.icon.addPixmap     (QtGui.QPixmap(pictureBaseName + ".svg"),       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        if QtCore.QResource(pictureBaseName + "_down.svg").isValid():
          self.iconDown.addPixmap (QtGui.QPixmap(pictureBaseName + "_down.svg"),  QtGui.QIcon.Normal, QtGui.QIcon.Off)
        else:
          self.iconDown.addPixmap (QtGui.QPixmap(pictureBaseName + ".svg"),  QtGui.QIcon.Normal, QtGui.QIcon.Off)
        if QtCore.QResource(pictureBaseName + "_light.svg").isValid():
          self.iconLight.addPixmap(QtGui.QPixmap(pictureBaseName + "_light.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        else:
          self.iconLight.addPixmap (QtGui.QPixmap(pictureBaseName + ".svg"),  QtGui.QIcon.Normal, QtGui.QIcon.Off)
      else:
        print(self.tr("Image resource of button ({}) not found").format(pictureBaseName + ".svg"))
      self.__imagesOk = True

    if event.type() == QtCore.QEvent.EnabledChange:
      if self.__imagesOk:
        if self.isEnabled():
          if self.__buttonStatus:
            self.setIcon(self.iconLight)
          else:
            self.setIcon(self.icon)
        else:
          self.setIcon(self.icon)

    return False
示例#2
0
    def __init__(self, parent=None):
        super(UIRadioTelescopeControl, self).__init__(parent)
        self.logger = logging.getLogger(
            __name__)  # Create the logger for the file
        self.motor_warn_msg_shown = False

        # Load the resources binary
        resource_object = QtCore.QResource()
        resource_file = resource_object.registerResource(
            os.path.abspath("Core/GUI/resources.rcc"))
        if resource_file.bit_length() == 0:
            self.logger.error(
                "Resources file could not be loaded. Program is exiting.")
            sys.exit(-1)  # Indicate an error when exiting

        # Create the main GUI window and the other windows
        self.main_win = QtWidgets.QMainWindow(
        )  # Create the main window of the GUI
        self.ui_man_cont_win = QtWidgets.QMainWindow(
            parent=self.main_win)  # Create the Manual control window
        self.ui_tcp_win = QtWidgets.QMainWindow(
            parent=self.main_win)  # Create the TCP settings window object
        self.ui_location_win = QtWidgets.QDialog(
            parent=self.main_win)  # Create the location settings window object
        self.ui_calibration_win = QtWidgets.QMainWindow(
            parent=self.main_win)  # Create the calibration window object
        self.ui_planetary_obj_win = QtWidgets.QMainWindow(
            parent=self.main_win)  # Planetary object selection GUI
        self.ui_sky_scanning_win = QtWidgets.QMainWindow(
            parent=self.main_win)  # Sky scanning control window

        # Extra dialogs
        self.map_dialog = QtWidgets.QDialog(
            parent=self.ui_location_win)  # Location selection from map dialog
        self.satellite_dialog = QtWidgets.QDialog(
            parent=self.ui_calibration_win)  # Satellite selection dialog
        self.tle_settings_dialog = QtWidgets.QDialog(
            parent=self.main_win)  # Create the TLE settings widget
        self.tle_info_msg_box = QtWidgets.QMessageBox(
        )  # Message box to show TLE retrieval status

        # Initial setup of the message box
        self.tle_info_msg_box.setVisible(
            False)  # No need to be visible all the time
        self.tle_info_msg_box.setAutoFillBackground(True)
        self.tle_info_msg_box.setWindowTitle("TLE Retriever")
        self.tle_info_msg_box.setStandardButtons(
            QtWidgets.QMessageBox.NoButton)

        try:
            self.main_widget = self.ui_loader(':/UI_Files/RadioTelescope',
                                              self.main_win)
            self.man_cont_widget = self.ui_loader(':/UI_Files/ManualControl',
                                                  self.ui_man_cont_win)
            self.tcp_widget = self.ui_loader(':/UI_Files/TCPSettings',
                                             self.ui_tcp_win)
            self.location_widget = self.ui_loader(':/UI_Files/Location',
                                                  self.ui_location_win)
            self.map_dialog = self.ui_loader(':/UI_Files/MapsDialog',
                                             self.map_dialog)
            self.calib_win = self.ui_loader(':/UI_Files/Calibration',
                                            self.ui_calibration_win)
            self.plan_obj_win = self.ui_loader(':/UI_Files/PlanetaryObject',
                                               self.ui_planetary_obj_win)
            self.sky_scan_win = self.ui_loader(':/UI_Files/SkyScanning',
                                               self.ui_sky_scanning_win)
            self.sat_sel_diag = self.ui_loader(
                ':/UI_Files/SatelliteSelectionDialog', self.satellite_dialog)
            self.tle_settings_widget = self.ui_loader(
                ':/UI_Files/TLESettingsDialog', self.tle_settings_dialog)
        except FileNotFoundError:
            self.logger.exception(
                "Something happened when loading GUI files. See traceback")
            sys.exit(-1)  # Indicate a problematic shutdown
        self.tle_info_msg_box.setParent(
            self.main_widget)  # Set the main program window to be the parent
        self.tle_info_msg_box.setWindowModality(QtCore.Qt.ApplicationModal)

        # Set the icons for the GUI windows
        try:
            self.main_widget.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/radiotelescope'))
            self.man_cont_widget.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/manControl'))
            self.tcp_widget.setWindowIcon(QtGui.QIcon(':/Window_Icons/Net'))
            self.location_widget.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/location'))
            self.calib_win.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/calibration'))
            self.plan_obj_win.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/planetary'))
            self.sky_scan_win.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/skyScanning'))
            self.sat_sel_diag.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/satelliteSelection'))
            self.map_dialog.setWindowIcon(QtGui.QIcon(':/Window_Icons/maps'))
            self.tle_settings_widget.setWindowIcon(
                QtGui.QIcon(':/Window_Icons/TLESettings'))
        except Exception:
            self.logger.exception(
                "Problem setting window icons. See traceback below.")
        self.setup_ui(
        )  # Call the function to make all the connections for the GUI things

        # Timer for the date and time label
        self.timer = QtCore.QTimer()  # Create a timer object
        self.timer.timeout.connect(
            self.date_time)  # Assign the timeout signal to date and time show
        self.timer.setInterval(1000)  # Update date and time ever second

        QtWidgets.QApplication.setStyle(
            QtWidgets.QStyleFactory.create(
                "Fusion"))  # Change the style of the GUI