def __init__(self, context): """! The constructor.""" QPushButton.__init__(self) self._context = context self._context.addLanguageEventListner(self.onTranslate) self._context.addCloseEventListner(self.onDestroy) self.setCheckable(True) self.setFocusPolicy(Qt.NoFocus) self.setStyleSheet(R.values.styles.transparent_background) self.setIcon(R.getIconById("icon_pause")) self.setIconSize(QSize(80, 80)) self._button_state = EmergencyStopState.UNLOCKED self._keep_running = True self.connect(self, SIGNAL('clicked(bool)'), self._trigger_button) self._estop_pub = rospy.Publisher(self.EMERGENCY_STOP_TOPIC_NAME, Bool, latch=True, queue_size=1) self._preempt_move_base_pub = rospy.Publisher("/move_base/cancel", GoalID, queue_size=1) self._estop_pub_thread = threading.Thread( name='emergency_stop_publisher_loop', target=self._emergency_stop_publisher_loop) self._estop_pub_thread.start()
def _trigger_button(self, checked): """Called when user click on ermergency stop button. @param checked: Button status (True/False). @type checked: bool. """ self._context.resquestEmergencyStop(checked) self._button_state = checked if checked == EmergencyStopState.LOCKED: lng = self._context.getLanguage() self._context.sendAlarm(Alarm.CRITICAL, R.values.strings.emergency_stop(lng)) self.setIcon(R.getIconById("icon_play")) else: self.setIcon(R.getIconById("icon_pause"))
def setupMinimumTools(self): self.control_mode_widget = ControlModeWidget(self._context) self.ctrl_layout.addWidget(self.control_mode_widget) self.user_account = UserAccountsWidget(self._context) self.user_account.onCreate(None) self.user_layout.addWidget(self.user_account) self.timestamp_widget = Timestamp(self._context) self.timestamp_widget.onCreate(None) self.user_layout.addWidget(self.timestamp_widget) self.translator_widget = TranslatorUi(self._context) self.user_layout.addWidget(self.translator_widget) self.diagnostic_widget = DiagnosticsWidget(self._context) self.user_layout.addWidget(self.diagnostic_widget) self.emergency_stop = EmergencyStopButton(self._context) self.interruption_layout.addWidget(self.emergency_stop) self.alarms_manager = AlarmManagerWidget(self._context) self.alarm_layout.addWidget(self.alarms_manager) #Display Airbus Group logo self.logo_label.setPixmap( R.getPixmapById('logo_airbus_group').scaled( self.logo_label.width() - 2, self.logo_label.height() - 2, Qt.KeepAspectRatio, Qt.SmoothTransformation))
def onCreate(self, param): # Extend the widget with all attributes and children from UI file loadUi(R.layouts.account_popup, self) self.user_icon_label.setPixmap(R.getPixmapById('ico_user')) user_info = self.getParent().getContext().getUserInfo() if user_info.privilege < Privilege.EXPERT: self.accounts_manager_button.setEnabled(False) else: self.accounts_manager_button.setEnabled(True) self.user_id_label.setText(user_info.userid) privilege = Privilege.TOSTR[user_info.privilege] self.access_rights_label.setText(privilege[0].upper()+privilege[1:]) self.time_label.setText('2h:38m') self.connect(self.connection_button, SIGNAL("clicked()"), self.open_login_dialog) self.connect(self.accounts_manager_button, SIGNAL("clicked()"), self.open_accounts_manager_dialog) self.connect(self.deconnection_button, SIGNAL("clicked()"), self.disconnect_user_account) self.deconnection_button.setEnabled(True) self.adjustSize()
def __init__(self, context): QWidget.__init__(self) loadUi(R.layouts.alarm_listview, self) self.setFixedHeight(self.MINIMUM_HEIGHT) self.alarm_listview.setSpacing(5) self._context = context self._parent = context.getParent() self._status = self.CLOSED self._lng = context.getLanguage() self._incremental = Incremental() self.connect(self._incremental, SIGNAL('valueChanged(int)'), self.setFixedHeight) self.connect(self.drawable_button, SIGNAL('clicked()'), self.switchDrawable) self._parent.alarm_label.setPixmap(R.getPixmapById("ico_alarm").scaled( 75,75, Qt.KeepAspectRatio,Qt.SmoothTransformation)) self._context.addAlarmEventListner(self.onAppendAlarm) self._context.addLanguageEventListner(self.onTranslate) self._parent.alarm_label.setVisible(False) self.setVisible(False)
def refresh(self): lng = self.getContext().getLanguage() self.setPixmap(R.getPixmapById(lng).scaled( self.width(), self.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) )
def __init__(self): QSplashScreen.__init__(self) # Extend the widget with all attributes and children from UI file loadUi(R.layouts.welcome, self) self.setPixmap( R.getPixmapById("wellcome_background").scaled( 600, 400, Qt.KeepAspectRatio, Qt.SmoothTransformation)) self.loading_progess.setText("Loading ...")
def __init__(self, parent, country): """! The constructor.""" QPushButton.__init__(self, parent) self._parent = parent self._country = country self.setMinimumSize(QSize(40, 40)) self.setMaximumSize(QSize(60, 60)) self.setStyleSheet(R.values.styles.transparent_background) self.setIcon(R.getIconById(country)) self.setIconSize(QSize(self.width(),self.height()))
def onCreate(self, param): self._user_icon_label = QLabel() self._user_icon_label.setStyleSheet(R.values.styles.text) self._user_icon_label.setFixedSize(QSize(25,25)) self._user_icon_label.setPixmap(R.getPixmapById('ico_user').scaled( self._user_icon_label.width(), self._user_icon_label.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation)) ###### self._user_id_label = QLabel() self._user_id_label.setStyleSheet(R.values.styles.transparent_background) ###### self.getLayout().addWidget(self._user_icon_label) self.getLayout().addWidget(self._user_id_label)
def run(): name = 'rqt_gui_py_node_%d' % os.getpid() rospy.init_node(name, disable_signals=True) app = GuiApplication(sys.argv) splash = CobotGuiSplash() splash.start() window = QMainWindow() gui = CobotGuiMain(splash) config = rospy.get_param("~config", "${cobot_gui}/config/default.conf") config = get_pkg_dir_from_prefix(config) gui.setupUserConfig(config) window.setCentralWidget(gui) window.setGeometry(gui.geometry()) window.setWindowIcon(R.getIconById('cobot_gui')) if gui.getDisplayMode() in FULL_SCREEN_ARGS: window.showFullScreen() else: window.show() splash.close() #Set the gui signal for cleanup app.gui = gui app.connect(app, SIGNAL("aboutToQuit()"), app.cleanGui) #Set the ctrl+c signal for cleanup def signal_handler(signal, frame): app.quit() signal.signal(signal.SIGINT, signal_handler) #set the rospy shutdown signal rospy.on_shutdown(app.quit) #return of app sys.exit(app.exec_())
def update_state(self, state, msg): self.setIcon(R.getIconById(state)) self.setIconSize(QSize(40, 40)) self.setToolTip(msg)