当前位置: 首页>>代码示例>>Python>>正文


Python QVBoxLayout.activate方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QVBoxLayout.activate方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.activate方法的具体用法?Python QVBoxLayout.activate怎么用?Python QVBoxLayout.activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QVBoxLayout的用法示例。


在下文中一共展示了QVBoxLayout.activate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: IMU

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import activate [as 别名]

#.........这里部分代码省略.........

    def save_orientation_clicked(self):
        self.imu_gl.save_orientation()
        self.orientation_label.hide()

    def cleanup_gl(self):
        self.state = self.imu_gl.get_state()
        self.imu_gl.hide()
        self.imu_gl.cleanup()

    def restart_gl(self):
        self.imu_gl = IMU3DWidget()

        self.imu_gl.setMinimumSize(150, 150)
        self.imu_gl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.gl_layout.addWidget(self.imu_gl)
        self.imu_gl.show()

        self.save_orientation.clicked.connect(self.save_orientation_clicked)
        self.imu_gl.set_state(self.state)

    def start(self):
        if not self.alive:
            return

        if self.has_status_led:
            async_call(self.imu.is_status_led_enabled, None, self.status_led_action.setChecked, self.increase_error_count)

        self.parent().add_callback_on_untab(lambda x: self.cleanup_gl(), 'imu_cleanup_on_untab')
        self.parent().add_callback_post_untab(lambda x: self.restart_gl(), 'imu_restart_post_untab')
        self.parent().add_callback_on_tab(lambda x: self.cleanup_gl(), 'imu_cleanup_on_tab')
        self.parent().add_callback_post_tab(lambda x: self.restart_gl(), 'imu_restart_post_tab')

        self.gl_layout.activate()
        self.cbe_all_data.set_period(100)
        self.cbe_orientation.set_period(100)
        self.cbe_quaternion.set_period(50)
        self.update_timer.start(50)

        async_call(self.imu.get_convergence_speed, None, self.speed_spinbox.setValue, self.increase_error_count)

        self.mag_plot_widget.stop = False
        self.acc_plot_widget.stop = False
        self.gyr_plot_widget.stop = False
        self.temp_plot_widget.stop = False

    def stop(self):
        self.mag_plot_widget.stop = True
        self.acc_plot_widget.stop = True
        self.gyr_plot_widget.stop = True
        self.temp_plot_widget.stop = True

        self.update_timer.stop()
        self.cbe_all_data.set_period(0)
        self.cbe_orientation.set_period(0)
        self.cbe_quaternion.set_period(0)

    def destroy(self):
        self.alive = False
        self.cleanup_gl()
        if self.calibrate:
            self.calibrate.close()

    @staticmethod
    def has_device_identifier(device_identifier):
        return device_identifier == BrickIMU.DEVICE_IDENTIFIER
开发者ID:Tinkerforge,项目名称:brickv,代码行数:70,代码来源:imu.py

示例2: IMUV2

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import activate [as 别名]

#.........这里部分代码省略.........
        reset.triggered.connect(self.imu.reset)
        self.set_actions([(0, None, [reset])])

    def save_orientation_clicked(self):
        self.imu_gl.save_orientation()
        if self.imu_gl_wrapper is not None:
            self.imu_gl_wrapper.glWidget.save_orientation()
        self.orientation_label.hide()

    def cleanup_gl(self):
        self.state = self.imu_gl.get_state()
        self.imu_gl.hide()
        self.imu_gl.cleanup()

    def restart_gl(self):
        self.imu_gl = IMUV23DWidget()

        self.imu_gl.setFixedSize(200, 200)
        self.gl_layout.addWidget(self.imu_gl)
        self.imu_gl.show()

        self.save_orientation.clicked.connect(self.save_orientation_clicked)
        self.imu_gl.set_state(self.state)

    def start(self):
        if not self.alive:
            return

        self.parent().add_callback_on_untab(lambda x: self.cleanup_gl(), 'imu_v2_cleanup_on_untab')
        self.parent().add_callback_post_untab(lambda x: self.restart_gl(), 'imu_v2_restart_post_untab')
        self.parent().add_callback_on_tab(lambda x: self.cleanup_gl(), 'imu_v2_cleanup_on_tab')
        self.parent().add_callback_post_tab(lambda x: self.restart_gl(), 'imu_v2_restart_post_tab')

        self.gl_layout.activate()

        async_call(self.imu.is_status_led_enabled, None, self.status_led_action.setChecked, self.increase_error_count)
        async_call(self.imu.are_leds_on, None, self.checkbox_leds.setChecked, self.increase_error_count)

        self.cbe_all_data.set_period(50)

        for w in self.data_plot_widget:
            w.stop = False

    def stop(self):
        for w in self.data_plot_widget:
            w.stop = True

        if self.imu_gl_wrapper == None:
            self.cbe_all_data.set_period(0)

    def destroy(self):
        self.alive = False

        self.cleanup_gl()
        # Stop callback to fix deadlock with callback emulation thread.
        self.cbe_all_data.set_period(0)

        if self.calibration != None:
            self.calibration.close()

        if self.imu_gl_wrapper != None:
            self.imu_gl_wrapper.close()

    @staticmethod
    def has_device_identifier(device_identifier):
        return device_identifier == BrickIMUV2.DEVICE_IDENTIFIER
开发者ID:Tinkerforge,项目名称:brickv,代码行数:70,代码来源:imu_v2.py

示例3: E5PassivePopup

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import activate [as 别名]
class E5PassivePopup(QFrame):
    """
    Class implementing dialog-like popup that displays messages without
    interrupting the user.
    """
    Boxed = 0
    Custom = 128
    
    clicked = pyqtSignal((), (QPoint, ))
    
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super(E5PassivePopup, self).__init__(None)
        
        self.__popupStyle = DEFAULT_POPUP_TYPE
        self.__msgView = None
        self.__topLayout = None
        self.__hideDelay = DEFAULT_POPUP_TIME
        self.__hideTimer = QTimer(self)
        self.__autoDelete = False
        self.__fixedPosition = QPoint()
        
        self.setWindowFlags(POPUP_FLAGS)
        self.setFrameStyle(QFrame.Box | QFrame.Plain)
        self.setLineWidth(2)
        self.__hideTimer.timeout.connect(self.hide)
        self.clicked.connect(self.hide)
    
    def setView(self, child):
        """
        Public method to set the message view.
        
        @param child reference to the widget to set as the message view
            (QWidget)
        """
        self.__msgView = child
        self.__topLayout = QVBoxLayout(self)
        self.__topLayout.addWidget(self.__msgView)
        self.__topLayout.activate()
    
    def view(self):
        """
        Public method to get a reference to the message view.
        
        @return reference to the message view (QWidget)
        """
        return self.__msgView
    
    def setVisible(self, visible):
        """
        Public method to show or hide the popup.
        
        @param visible flag indicating the visibility status (boolean)
        """
        if not visible:
            super(E5PassivePopup, self).setVisible(visible)
            return
        
        if self.size() != self.sizeHint():
            self.resize(self.sizeHint())
        
        if self.__fixedPosition.isNull():
            self.__positionSelf()
        else:
            self.move(self.__fixedPosition)
        super(E5PassivePopup, self).setVisible(True)
        
        delay = self.__hideDelay
        if delay < 0:
            delay = DEFAULT_POPUP_TIME
        if delay > 0:
            self.__hideTimer.start(delay)
    
    def show(self, p=None):
        """
        Public slot to show the popup.
        
        @param p position for the popup (QPoint)
        """
        if p is not None:
            self.__fixedPosition = p
        super(E5PassivePopup, self).show()
    
    def setTimeout(self, delay):
        """
        Public method to set the delay for the popup is removed automatically.
        
        Setting the delay to 0 disables the timeout. If you're doing this, you
        may want to connect the clicked() signal to the hide() slot. Setting
        the delay to -1 makes it use the default value.
        
        @param delay value for the delay in milliseconds (integer)
        """
        self.__hideDelay = delay
        if self.__hideTimer.isActive():
            if delay:
#.........这里部分代码省略.........
开发者ID:pycom,项目名称:EricShort,代码行数:103,代码来源:E5PassivePopup.py

示例4: SinkSelectorSettings

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import activate [as 别名]
class SinkSelectorSettings(SettingsSection):

    NAME = 'Multi-Sink Selector'
    ELEMENT = SinkSelector

    Sinks = elements.outputs()

    def __init__(self, size, Id, parent=None):
        super().__init__(size, parent)

        self.id = Id
        self._sinks = []

        self.groupBox = QGroupBox(self)
        self.groupBox.setTitle('Add/Remove outputs')
        self.groupBox.resize(self.width(), self.height())

        self.vlayout = QVBoxLayout(self.groupBox)
        self.vlayout.setContentsMargins(0, 5, 0, 0)

        self.sinksList = QListWidget(self.groupBox)
        self.sinksList.setAlternatingRowColors(True)
        self.vlayout.addWidget(self.sinksList)

        self.buttons = QDialogButtonBox(self.groupBox)
        self.vlayout.addWidget(self.buttons)

        self.add = QPushButton('Add')
        self.remove = QPushButton('Remove')
        self.buttons.addButton(self.add, QDialogButtonBox.YesRole)
        self.buttons.addButton(self.remove, QDialogButtonBox.NoRole)

        self.vlayout.activate()

        self.add.clicked.connect(self._new_sink)
        self.remove.clicked.connect(self.__remove_sink)

    def set_configuration(self, conf):
        if conf is not None and self.id in conf:
            conf = deepcopy(conf)
            for key in conf[self.id]:
                self.__add_sink(conf[self.id][key], key)
        else:
            self.__add_sink({'name': 'AutoSink'}, 'sink0')

    def get_configuration(self):
        conf = {}

        if not (self.groupBox.isCheckable() and not self.groupBox.isChecked()):
            conf[self.id] = {}
            for widget, name in self._sinks:
                conf[self.id][name] = widget.get_settings()

        return conf

    def enable_check(self, enable):
        self.groupBox.setCheckable(enable)
        self.groupBox.setChecked(False)

    def _new_sink(self):
        sinks = sorted(self.Sinks.keys())
        sinks.remove('SinkSelector')
        name, ok = QInputDialog.getItem(self, "Output", "Select output device",
                                        sinks, editable=False)
        if ok:
            self.__add_sink({'name': name})

    def __new_name(self):
        suff = 0

        for _, name in sorted(self._sinks, key=itemgetter(1)):
            if 'sink' + str(suff) != name:
                break
            suff += 1

        return 'sink' + str(suff)

    def __add_sink(self, properties, name=None):
        widget = OutputWidget(properties, self.sinksList)
        widget.resize(self.sinksList.width() - 5, 80)

        item = QListWidgetItem()
        item.setSizeHint(widget.size())

        if name is None:
            name = self.__new_name()

        self._sinks.append((widget, name))
        self.sinksList.addItem(item)
        self.sinksList.setItemWidget(item, widget)

        self.remove.setEnabled(len(self._sinks) > 1)

    def __remove_sink(self):
        self._sinks.pop(self.sinksList.currentRow())
        self.sinksList.removeItemWidget(self.sinksList.currentItem())
        self.sinksList.takeItem(self.sinksList.currentRow())

        self.remove.setEnabled(len(self._sinks) > 1)
开发者ID:tornel,项目名称:linux-show-player,代码行数:101,代码来源:sink_selector.py


注:本文中的PyQt5.QtWidgets.QVBoxLayout.activate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。