Example #1
0
    def _init_ui(self):
        main_lay = QVBoxLayout()

        tab_center = MLineTabWidget()
        tab_center.add_tab(MLabel('test 1 ' * 10),
                           {'text': u'Tab 1', 'svg': 'user_line.svg'})
        tab_center.add_tab(MLabel('test 2 ' * 10), {'svg': 'calendar_line.svg'})
        tab_center.add_tab(MLabel('test 3 ' * 10), u'Tab 3')
        tab_center.tool_button_group.set_dayu_checked(0)

        tab_left = MLineTabWidget(alignment=Qt.AlignLeft)
        tab_left.add_tab(MLabel('test 1 ' * 10), u'Tab 1')
        tab_left.add_tab(MLabel('test 2 ' * 10), u'Tab 2')
        tab_left.add_tab(MLabel('test 3 ' * 10), u'Tab 3')
        tab_left.tool_button_group.set_dayu_checked(0)

        tab_right = MLineTabWidget(alignment=Qt.AlignRight)
        tab_right.add_tab(MLabel('test 1 ' * 10), u'Tab 1')
        tab_right.add_tab(MLabel('test 2 ' * 10), u'Tab 2')
        tab_right.add_tab(MLabel('test 3 ' * 10), u'Tab 3')
        tab_right.tool_button_group.set_dayu_checked(0)

        main_lay.addWidget(MDivider('Center'))
        main_lay.addWidget(tab_center)
        main_lay.addSpacing(20)
        main_lay.addWidget(MDivider('Left'))
        main_lay.addWidget(tab_left)
        main_lay.addSpacing(20)
        main_lay.addWidget(MDivider('Right'))
        main_lay.addWidget(tab_right)
        main_lay.addStretch()
        self.setLayout(main_lay)
Example #2
0
 def __init__(self, alignment=Qt.AlignCenter, parent=None):
     super(MLineTabWidget, self).__init__(parent=parent)
     self.tool_button_group = MUnderlineButtonGroup()
     self.bar_layout = QHBoxLayout()
     self.bar_layout.setContentsMargins(0, 0, 0, 0)
     if alignment == Qt.AlignCenter:
         self.bar_layout.addStretch()
         self.bar_layout.addWidget(self.tool_button_group)
         self.bar_layout.addStretch()
     elif alignment == Qt.AlignLeft:
         self.bar_layout.addWidget(self.tool_button_group)
         self.bar_layout.addStretch()
     elif alignment == Qt.AlignRight:
         self.bar_layout.addStretch()
         self.bar_layout.addWidget(self.tool_button_group)
     self.stack_widget = MStackedWidget()
     self.tool_button_group.sig_checked_changed.connect(self.stack_widget.setCurrentIndex)
     main_lay = QVBoxLayout()
     main_lay.setContentsMargins(0, 0, 0, 0)
     main_lay.setSpacing(0)
     main_lay.addLayout(self.bar_layout)
     main_lay.addWidget(MDivider())
     main_lay.addSpacing(5)
     main_lay.addWidget(self.stack_widget)
     self.setLayout(main_lay)
Example #3
0
    def __init__(self, text, duration=None, dayu_type=None, parent=None):
        super(MToast, self).__init__(parent)
        self.setWindowFlags(
            Qt.FramelessWindowHint | Qt.Dialog | Qt.WA_TranslucentBackground | Qt.WA_DeleteOnClose)
        self.setAttribute(Qt.WA_StyledBackground)

        _icon_lay = QHBoxLayout()
        _icon_lay.addStretch()

        if dayu_type == MToast.LoadingType:
            _icon_lay.addWidget(MLoading(size=dayu_theme.huge, color=dayu_theme.text_color_inverse))
        else:
            _icon_label = MAvatar()
            _icon_label.set_dayu_size(60)
            _icon_label.set_dayu_image(MPixmap('{}_line.svg'.format(dayu_type or MToast.InfoType),
                                               dayu_theme.text_color_inverse))
            _icon_lay.addWidget(_icon_label)
        _icon_lay.addStretch()

        _content_label = MLabel()
        _content_label.setText(text)
        _content_label.setAlignment(Qt.AlignCenter)

        _main_lay = QVBoxLayout()
        _main_lay.setContentsMargins(0, 0, 0, 0)
        _main_lay.addStretch()
        _main_lay.addLayout(_icon_lay)
        _main_lay.addSpacing(10)
        _main_lay.addWidget(_content_label)
        _main_lay.addStretch()
        self.setLayout(_main_lay)
        self.setFixedSize(QSize(120, 120))

        _close_timer = QTimer(self)
        _close_timer.setSingleShot(True)
        _close_timer.timeout.connect(self.close)
        _close_timer.timeout.connect(self.sig_closed)
        _close_timer.setInterval((duration or self.default_config.get('duration')) * 1000)

        _ani_timer = QTimer(self)
        _ani_timer.timeout.connect(self._fade_out)
        _ani_timer.setInterval((duration or self.default_config.get('duration')) * 1000 - 300)

        _close_timer.start()
        _ani_timer.start()

        self._opacity_ani = QPropertyAnimation()
        self._opacity_ani.setTargetObject(self)
        self._opacity_ani.setDuration(300)
        self._opacity_ani.setEasingCurve(QEasingCurve.OutCubic)
        self._opacity_ani.setPropertyName('windowOpacity')
        self._opacity_ani.setStartValue(0.0)
        self._opacity_ani.setEndValue(0.9)

        self._get_center_position(parent)
        self._fade_int()
Example #4
0
 def __init__(self, parent=None):
     super(MMenuTabWidget, self).__init__(parent=parent)
     self.tool_button_group = MBlockButtonGroup()
     self._bar_layout = QHBoxLayout()
     self._bar_layout.setContentsMargins(10, 0, 10, 0)
     self._bar_layout.addWidget(self.tool_button_group)
     self._bar_layout.addStretch()
     bar_widget = QWidget()
     bar_widget.setObjectName('bar_widget')
     bar_widget.setLayout(self._bar_layout)
     bar_widget.setAttribute(Qt.WA_StyledBackground)
     main_lay = QVBoxLayout()
     main_lay.setContentsMargins(0, 0, 0, 0)
     main_lay.setSpacing(0)
     main_lay.addWidget(bar_widget)
     main_lay.addWidget(MDivider())
     main_lay.addSpacing(5)
     self.setLayout(main_lay)
     self.setFixedHeight(dayu_theme.large + 10)