Beispiel #1
0
 def inspect(self, flight):
     # get and format info from this flight
     callsign = flight.call_sign
     flight_type = flight.type.name
     wake = flight.cat.name
     stand = flight.stand.name
     runway = flight.runway.name
     qfu = flight.qfu
     time = traffic.hms(flight.start_t)
     slot = 'No slot' if flight.slot is None else traffic.hms(flight.slot)
     # update the inspector
     self.ui_flightInspector.label_callsign.setText(callsign)
     self.ui_flightInspector.label_movement_type.setText(flight_type)
     self.ui_flightInspector.label_wake.setText(wake)
     self.ui_flightInspector.label_stand.setText(stand)
     self.ui_flightInspector.label_runway.setText(runway)
     self.ui_flightInspector.label_qfu.setText(qfu)
     self.ui_flightInspector.label_time.setText(time)
     self.ui_flightInspector.label_slot.setText(slot)
Beispiel #2
0
    def create_toolbar(self):
        # create layout for time controls and entry
        toolbar = QtWidgets.QHBoxLayout()

        def add_button(text, slot):
            """adds a button to the hbox and connects the slot"""
            button = QtWidgets.QPushButton(text)
            button.clicked.connect(slot)
            toolbar.addWidget(button)

        # lambda function allows to pass extra arguments to slots
        # added space around '-' character to avoid different look and feel
        add_button(' - ', lambda: self.view.zoom_view(0.9))
        add_button('+', lambda: self.view.zoom_view(1.1))
        toolbar.addStretch()
        add_button('<<', lambda: self.set_time_increment(-5))
        add_button(' <', lambda: self.set_time_increment(-1))
        add_button('|>', self.playpause)
        add_button(' >', lambda: self.set_time_increment(1))
        add_button('>>', lambda: self.set_time_increment(5))
        toolbar.addWidget(self.time_entry)
        self.time_entry.setInputMask("00:00:00")
        self.time_entry.editingFinished.connect(self.change_time)
        self.time_entry.setText(traffic.hms(self.simulation.t))
        toolbar.addStretch()

        # shortcuts and key bindings
        def add_shortcut(text, slot):
            """creates an application-wide key binding"""
            shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(text), self)
            shortcut.activated.connect(slot)

        add_shortcut('+', lambda: self.zoom_view(1.1))
        add_shortcut('-', lambda: self.zoom_view(1 / 1.1))
        add_shortcut(' ', self.playpause)
        add_shortcut('q', QtCore.QCoreApplication.instance().quit)

        lbl = QtWidgets.QLabel("Speed")
        sliderlbl = QtWidgets.QLabel(str(self.time_increment))
        sliderlbl.setFixedWidth(25)

        def change_traffic_speed(val):
            self.set_time_increment(val)
            sliderlbl.setText(str(val))

        toolbar.addWidget(lbl)
        toolbar.addStretch()
        toolbar.addWidget(sld)
        label2 = QtWidgets.QLabel("Valeur")
        toolbar.addWidget(label2)

        return toolbar
Beispiel #3
0
 def update_traffic(self):
     self.moving_aircraft.update_aircraft_items()
     self.time_entry.setText(traffic.hms(self.simulation.t))
Beispiel #4
0
    def create_toolbar(self):
        # create layout for time controls and entry
        toolbar = QtWidgets.QHBoxLayout()

        def add_button(text, slot):
            """adds a button to the hbox and connects the slot"""
            button = QtWidgets.QPushButton(text)
            button.clicked.connect(slot)
            toolbar.addWidget(button)

        # lambda function allows to pass extra arguments to slots
        # added space around '-' character to avoid different look and feel
        add_button(' - ', lambda: self.view.zoom_view(0.9))
        add_button('+', lambda: self.view.zoom_view(1.1))
        toolbar.addStretch()
        add_button('<<', lambda: self.set_time_increment(-5))
        add_button(' <', lambda: self.set_time_increment(-1))
        add_button('|>', self.playpause)
        add_button(' >', lambda: self.set_time_increment(1))
        add_button('>>', lambda: self.set_time_increment(5))
        toolbar.addWidget(self.time_entry)
        self.time_entry.setInputMask("00:00:00")
        self.time_entry.editingFinished.connect(self.change_time)
        self.time_entry.setText(traffic.hms(self.simulation.t))
        toolbar.addStretch()

        # shortcuts and key bindings
        def add_shortcut(text, slot):
            """creates an application-wide key binding"""
            shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(text), self)
            shortcut.activated.connect(slot)

        add_shortcut('+', lambda: self.zoom_view(1.1))
        add_shortcut('-', lambda: self.zoom_view(1 / 1.1))
        add_shortcut(' ', self.playpause)
        add_shortcut('q', QtCore.QCoreApplication.instance().quit)

        # add a slider to change aircraft items radius
        # slider
        sld = QtWidgets.QSlider(QtCore.Qt.Horizontal)
        sld.setMinimum(35)
        sld.setMaximum(140)
        sld.setValue(traffic.SEP)

        # labels
        lbl = QtWidgets.QLabel("Rayon")
        sliderlbl = QtWidgets.QLabel(str(traffic.SEP))
        sliderlbl.setFixedWidth(25)

        # slot
        def change_traffic_sep(val):
            traffic.SEP = val
            sliderlbl.setText(str(val))
            for item in self.moving_aircraft.aircraft_items_dict.values():
                item.update_size()

        # connect signal to slot
        sld.valueChanged.connect(change_traffic_sep)

        # add slider and labels to toolbar
        toolbar.addWidget(lbl)
        toolbar.addWidget(sld)
        toolbar.addWidget(sliderlbl)

        return toolbar