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)
Esempio n. 2
0
    def _init_ui(self):
        self.register_field('percent', 20)
        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different orientation'))
        for orn in [Qt.Horizontal, Qt.Vertical]:
            line_edit_hor = MSlider(orn)
            line_edit_hor.setRange(1, 100)
            self.bind('percent', line_edit_hor, 'value')
            lay = QVBoxLayout()
            lay.addWidget(line_edit_hor)
            main_lay.addLayout(lay)
        spin_box = MSpinBox()
        spin_box.setRange(1, 100)
        self.bind('percent', spin_box, 'value', signal='valueChanged')

        lay3 = QHBoxLayout()
        button_grp = MPushButtonGroup()
        button_grp.set_button_list([
            {
                'text': '+',
                'clicked': functools.partial(self.slot_change_value, 10)
            },
            {
                'text': '-',
                'clicked': functools.partial(self.slot_change_value, -10)
            },
        ])
        lay3.addWidget(spin_box)
        lay3.addWidget(button_grp)
        lay3.addStretch()
        main_lay.addWidget(MDivider('data bind'))
        main_lay.addLayout(lay3)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 3
0
    def _init_ui(self):
        check_box_1 = MSwitch()
        check_box_1.setChecked(True)
        check_box_2 = MSwitch()
        check_box_3 = MSwitch()
        check_box_3.setEnabled(False)
        lay = QHBoxLayout()
        lay.addWidget(check_box_1)
        lay.addWidget(check_box_2)
        lay.addWidget(check_box_3)

        size_lay = QVBoxLayout()
        size_list = [
            ('Huge', MSwitch.huge),
            ('Large', MSwitch.large),
            ('Medium', MSwitch.medium),
            ('Small', MSwitch.small),
            ('Tiny', MSwitch.tiny),
        ]
        for label, cls in size_list:
            lay2 = QHBoxLayout()
            lay2.addWidget(MLabel(label))
            lay2.addWidget(cls())
            size_lay.addLayout(lay2)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))
        main_lay.addLayout(lay)
        main_lay.addWidget(MDivider('different size'))
        main_lay.addLayout(size_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 4
0
    def _init_ui(self):
        size_lay = QHBoxLayout()
        size_list = [
            ('Huge', MLoading.huge),
            ('Large', MLoading.large),
            ('Medium', MLoading.medium),
            ('Small', MLoading.small),
            ('Tiny', MLoading.tiny),
        ]
        for label, cls in size_list:
            size_lay.addWidget(MLabel(label))
            size_lay.addWidget(cls())
            size_lay.addSpacing(10)

        color_lay = QHBoxLayout()
        color_list = [('cyan', '#13c2c2'), ('green', '#52c41a'),
                      ('magenta', '#eb2f96'), ('red', '#f5222d'),
                      ('yellow', '#fadb14'), ('volcano', '#fa541c')]
        for label, color in color_list:
            color_lay.addWidget(MLabel(label))
            color_lay.addWidget(MLoading.tiny(color=color))
            color_lay.addSpacing(10)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different size'))
        main_lay.addLayout(size_lay)
        main_lay.addWidget(MDivider('different color'))
        main_lay.addLayout(color_lay)
        main_lay.addWidget(MDivider('loading wrapper'))
        # main_lay.addLayout(wrapper_lay)

        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 5
0
    def _init_ui(self):
        check_box_1 = MSwitch()
        check_box_1.setChecked(True)
        check_box_2 = MSwitch()
        check_box_3 = MSwitch()
        check_box_3.setEnabled(False)
        lay = QHBoxLayout()
        lay.addWidget(check_box_1)
        lay.addWidget(check_box_2)
        lay.addWidget(check_box_3)

        size_lay = QFormLayout()
        size_lay.addRow('Huge', MSwitch().huge())
        size_lay.addRow('Large', MSwitch().large())
        size_lay.addRow('Medium', MSwitch().medium())
        size_lay.addRow('Small', MSwitch().small())
        size_lay.addRow('Tiny', MSwitch().tiny())

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))
        main_lay.addLayout(lay)
        main_lay.addWidget(MDivider('different size'))
        main_lay.addLayout(size_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 6
0
    def __init__(self, parent=None):
        super(SpinBoxExample, self).__init__(parent)
        self.setWindowTitle('Examples for Spin Box')

        main_lay = QVBoxLayout()
        class_list = [
            MSpinBox, MDoubleSpinBox, MDateTimeEdit, MDateEdit, MTimeEdit
        ]
        for cls in class_list:
            main_lay.addWidget(MDivider(cls.__name__))
            lay = QHBoxLayout()
            lay.addWidget(cls().large())
            lay.addWidget(cls().medium())
            lay.addWidget(cls().small())
            main_lay.addLayout(lay)

        main_lay.addWidget(MDivider('Pop Calendar Widget'))
        date_time_edit = MDateTimeEdit()
        date_time_edit.setCalendarPopup(True)
        date_edit = MDateEdit()
        date_edit.setCalendarPopup(True)
        time_edit = MTimeEdit()
        time_edit.setCalendarPopup(True)
        date_lay = QHBoxLayout()
        date_lay.addWidget(date_time_edit)
        date_lay.addWidget(date_edit)
        date_lay.addWidget(time_edit)
        main_lay.addLayout(date_lay)

        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 7
0
    def _init_ui(self):
        progress_1 = MProgressBar()
        progress_1.setValue(1)
        progress_1.setAlignment(Qt.AlignCenter)
        progress_2 = MProgressBar()
        progress_2.setValue(80)

        progress_normal = MProgressBar()
        progress_normal.setValue(30)
        progress_success = MProgressBar(status=MProgressBar.SuccessStatus)
        progress_success.setValue(100)
        progress_error = MProgressBar(status=MProgressBar.ErrorStatus)
        progress_error.setValue(50)
        form_lay = QFormLayout()
        form_lay.addRow('Primary:', progress_normal)
        form_lay.addRow('Success:', progress_success)
        form_lay.addRow('Error:', progress_error)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))

        main_lay.addWidget(progress_1)
        main_lay.addWidget(progress_2)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(form_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 8
0
    def _init_ui(self):
        MMessage.config(duration=1)
        entity_list = [
            {
                'clicked': functools.partial(self.slot_show_message, MMessage.info,
                                             'Go to "Home Page"'),
                'svg': 'home_line.svg'},
            {
                'text': 'pl',
                'clicked': functools.partial(self.slot_show_message, MMessage.info, 'Go to "pl"'),
                'svg': 'user_line.svg'},
            {
                'text': 'pl_0010',
                'clicked': functools.partial(self.slot_show_message, MMessage.info,
                                             'Go to "pl_0010"'),
            }
        ]
        no_icon_eg = MBreadcrumb()
        no_icon_eg.set_item_list(entity_list)

        separator_eg = MBreadcrumb(separator='=>')
        separator_eg.set_item_list(entity_list)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('normal'))
        main_lay.addWidget(no_icon_eg)
        main_lay.addWidget(MDivider('separator: =>'))
        main_lay.addWidget(separator_eg)

        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 9
0
    def _init_ui(self):
        standalone_lay = QHBoxLayout()
        standalone_lay.addWidget(MBadge.count(0))
        standalone_lay.addWidget(MBadge.count(20))
        standalone_lay.addWidget(MBadge.count(100))
        standalone_lay.addWidget(MBadge.dot(True))
        standalone_lay.addWidget(MBadge.text('new'))
        standalone_lay.addStretch()

        button = MToolButton().svg('trash_line.svg')
        avatar = MAvatar.large(MPixmap('avatar.png'))
        button_alert = MToolButton().svg('alert_fill.svg').large()
        badge_1 = MBadge.dot(True, widget=button)
        badge_2 = MBadge.dot(True, widget=avatar)
        badge_3 = MBadge.dot(True, widget=button_alert)
        button.clicked.connect(lambda: badge_1.set_dayu_dot(False))

        spin_box = MSpinBox()
        spin_box.setRange(0, 9999)
        spin_box.valueChanged.connect(badge_3.set_dayu_count)
        spin_box.setValue(1)

        self.register_field('button1_selected', u'北京')
        menu1 = MMenu()
        menu1.set_data([u'北京', u'上海', u'广州', u'深圳'])
        select1 = MComboBox()
        select1.set_menu(menu1)
        self.bind('button1_selected',
                  select1,
                  'value',
                  signal='sig_value_changed')

        badge_hot = MBadge.text('hot', widget=MLabel(u'你的理想城市  '))

        sub_lay1 = QHBoxLayout()
        sub_lay1.addWidget(badge_1)
        sub_lay1.addWidget(badge_2)
        sub_lay1.addWidget(badge_3)
        sub_lay1.addStretch()

        sub_lay2 = QHBoxLayout()
        sub_lay2.addWidget(badge_hot)
        sub_lay2.addWidget(select1)
        sub_lay2.addStretch()

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('use standalone'))
        main_lay.addLayout(standalone_lay)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(sub_lay1)
        main_lay.addWidget(spin_box)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(sub_lay2)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 10
0
    def __init__(self, parent=None):
        super(RadioButtonExample, self).__init__(parent)
        self.setWindowTitle('Example for MRadioButton')
        widget_1 = QWidget()
        lay_1 = QHBoxLayout()
        lay_1.addWidget(MRadioButton('Maya'))
        lay_1.addWidget(MRadioButton('Nuke'))
        lay_1.addWidget(MRadioButton('Houdini'))
        widget_1.setLayout(lay_1)

        check_box_icon_1 = MRadioButton('Folder')
        check_box_icon_1.setIcon(MIcon('folder_fill.svg'))
        check_box_icon_2 = MRadioButton('Media')
        check_box_icon_2.setIcon(MIcon('media_fill.svg'))
        check_box_icon_3 = MRadioButton('User')
        check_box_icon_3.setIcon(MIcon('user_fill.svg'))
        check_box_icon_2.setChecked(True)
        widget_2 = QWidget()
        lay_2 = QHBoxLayout()
        lay_2.addWidget(check_box_icon_1)
        lay_2.addWidget(check_box_icon_2)
        lay_2.addWidget(check_box_icon_3)
        widget_2.setLayout(lay_2)

        check_box_single = MRadioButton(u'支付宝')
        check_box_single.setChecked(True)
        check_box_single.setEnabled(False)

        check_box_bind = MRadioButton('Data Bind')
        label = MLabel()
        button = MPushButton(text='Change State')
        button.clicked.connect(
            lambda: self.set_field('checked', not self.field('checked')))
        self.register_field('checked', True)
        self.register_field(
            'checked_text', lambda: 'Yes!'
            if self.field('checked') else 'No!!')
        self.bind('checked', check_box_bind, 'checked', signal='toggled')
        self.bind('checked_text', label, 'text')

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))
        main_lay.addWidget(widget_1)
        main_lay.addWidget(check_box_single)
        main_lay.addWidget(MDivider('Icon'))
        main_lay.addWidget(widget_2)
        main_lay.addWidget(MDivider('Data Bind'))
        main_lay.addWidget(check_box_bind)
        main_lay.addWidget(label)
        main_lay.addWidget(button)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 11
0
    def __init__(self, parent=None):
        super(AlertExample, self).__init__(parent)
        self.setWindowTitle('Example for MAlert')
        main_lay = QVBoxLayout()
        self.setLayout(main_lay)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addWidget(
            MAlert(text='Information Message', parent=self).info())
        main_lay.addWidget(
            MAlert(text='Success Message', parent=self).success())
        main_lay.addWidget(
            MAlert(text='Warning Message', parent=self).warning())
        main_lay.addWidget(MAlert(text='Error Message', parent=self).error())

        closeable_alert = MAlert('Some Message', parent=self).closable()

        main_lay.addWidget(MLabel(u'不同的提示信息类型'))
        main_lay.addWidget(MDivider('closable'))
        main_lay.addWidget(closeable_alert)
        main_lay.addWidget(MDivider('data bind'))
        self.register_field('msg', '')
        self.register_field('msg_type', MAlert.InfoType)

        data_bind_alert = MAlert(parent=self)
        data_bind_alert.set_closeable(True)

        self.bind('msg', data_bind_alert, 'dayu_text')
        self.bind('msg_type', data_bind_alert, 'dayu_type')
        button_grp = MPushButtonGroup()
        button_grp.set_button_list([{
            'text':
            'error',
            'clicked':
            functools.partial(self.slot_change_alert, 'password is wrong',
                              MAlert.ErrorType)
        }, {
            'text':
            'success',
            'clicked':
            functools.partial(self.slot_change_alert, 'login success',
                              MAlert.SuccessType)
        }, {
            'text':
            'no more error',
            'clicked':
            functools.partial(self.slot_change_alert, '', MAlert.InfoType)
        }])
        main_lay.addWidget(button_grp)
        main_lay.addWidget(data_bind_alert)
        main_lay.addStretch()
Esempio n. 12
0
    def __init__(self, parent=None):
        super(CheckBoxExample, self).__init__(parent)
        self.setWindowTitle('Example for MCheckBox')
        grid_lay = QGridLayout()

        for index, (text, state) in enumerate([('Unchecked', Qt.Unchecked),
                                               ('Checked', Qt.Checked),
                                               ('Partially',
                                                Qt.PartiallyChecked)]):
            check_box_normal = MCheckBox(text)
            check_box_normal.setCheckState(state)

            check_box_disabled = MCheckBox(text)
            check_box_disabled.setCheckState(state)
            check_box_disabled.setEnabled(False)

            grid_lay.addWidget(check_box_normal, 0, index)
            grid_lay.addWidget(check_box_disabled, 1, index)

        icon_lay = QHBoxLayout()
        for text, icon in [('Maya', MIcon('app-maya.png')),
                           ('Nuke', MIcon('app-nuke.png')),
                           ('Houdini', MIcon('app-houdini.png'))]:
            check_box_icon = MCheckBox(text)
            check_box_icon.setIcon(icon)
            icon_lay.addWidget(check_box_icon)

        check_box_bind = MCheckBox('Data Bind')
        label = MLabel()
        button = MPushButton(text='Change State')
        button.clicked.connect(
            lambda: self.set_field('checked', not self.field('checked')))
        self.register_field('checked', True)
        self.register_field(
            'checked_text', lambda: 'Yes!'
            if self.field('checked') else 'No!!')
        self.bind('checked', check_box_bind, 'checked', signal='stateChanged')
        self.bind('checked_text', label, 'text')

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))
        main_lay.addLayout(grid_lay)
        main_lay.addWidget(MDivider('Icon'))
        main_lay.addLayout(icon_lay)
        main_lay.addWidget(MDivider('Data Bind'))
        main_lay.addWidget(check_box_bind)
        main_lay.addWidget(label)
        main_lay.addWidget(button)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 13
0
    def _init_ui(self):
        page_1 = MPage()
        page_1.set_total(255)

        page_2 = MPage()
        page_2.set_total(100)

        main_lay = QVBoxLayout()
        self.setLayout(main_lay)
        main_lay.addWidget(MDivider())
        main_lay.addWidget(page_1)
        main_lay.addWidget(MDivider())
        main_lay.addWidget(page_2)
        main_lay.addStretch()
Esempio n. 14
0
    def _init_ui(self):

        self.setWindowModality(Qt.ApplicationModal)
        meta_card_lay = QHBoxLayout()
        meta_card_lay.setSpacing(20)
        for setting in [
            {
                'title':
                u'ZEUS',
                'cover':
                MPixmap(
                    r'C:\Users\huangPeiXin\Documents\houdini17.5\python2.7libs\Zeus_Lin\res\ZeusDesign\zeus.png'
                )
            },
            {
                'title':
                u'IDO',
                'cover':
                MPixmap(
                    r'C:\Users\huangPeiXin\Documents\houdini17.5\python2.7libs\Zeus_Lin\res\ZeusDesign\ido.png'
                )
            },
        ]:
            meta_card = MMeta()
            meta_card.setup_data(setting)
            meta_card_lay.addWidget(meta_card)

        left_lay = QVBoxLayout()

        left_lay.addWidget(MDivider('About Zeus'))
        left_lay.addLayout(meta_card_lay)
        left_lay.addWidget(MDivider(''))
        left_lay.setSpacing(20)
        label_1 = MLabel(u"Zues是由一灯工作室开发的一个软件")
        label_1.setAlignment(Qt.AlignHCenter)
        label_2 = MLabel(u"用于管理CG开发的相关资源")
        label_2.setAlignment(Qt.AlignHCenter)
        left_lay.addWidget(label_1)
        left_lay.addWidget(label_2)
        btn = MPushButton(u"确定")
        btn.clicked.connect(self.close)
        left_lay.addWidget(btn)
        left_lay.addStretch()

        self.setLayout(left_lay)

        dayu_theme.background_color = "#262626"

        dayu_theme.apply(self)
Esempio n. 15
0
    def _init_ui(self):
        self.resize(250, 350)
        self.button_login = MToolButton().svg(
            'user_line.svg').text_beside_icon()
        self.button_login.setText('Login')
        self.button_login.clicked.connect(self.onclick)
        button_lay = QVBoxLayout()

        button_lay.addWidget(self.button_login)

        self.tree = QTreeWidget()
        self.tree.setColumnCount(1)
        self.tree.setHeaderHidden(1)
        self.tree.setGeometry(QRect(1, 1, 250, 500))
        self.tree.itemClicked.connect(self.testt)

        new_widget_1 = QTreeWidgetItem(self.tree)
        new_widget_1.setText(0, u'技能培训')

        new_widget_2 = QTreeWidgetItem(self.tree)
        new_widget_2.setText(0, u'企业培训')

        new_widget_3 = QTreeWidgetItem(self.tree)
        new_widget_3.setText(0, u'职业技能培训')

        new_widget_3_1 = QTreeWidgetItem(new_widget_3)
        new_widget_3_1.setText(0, u'餐饮厨艺')
        new_widget_3_2 = QTreeWidgetItem(new_widget_3)
        new_widget_3_2.setText(0, u'家庭服务')
        new_widget_3_3 = QTreeWidgetItem(new_widget_3)
        new_widget_3_3.setText(0, u'运输与物流')

        new_widget_3_3_1 = QTreeWidgetItem(new_widget_3_3)
        new_widget_3_3_1.setText(0, u'运输与物流第一章')

        tree_layout = QVBoxLayout()
        tree_layout.addWidget(self.tree)

        main_lay = QVBoxLayout()
        main_lay.addLayout(button_lay)
        main_lay.addLayout(tree_layout)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 16
0
    def _init_ui(self):
        form_lay = QFormLayout()
        form_lay.setLabelAlignment(Qt.AlignRight)
        gender_grp = MRadioButtonGroup()
        gender_grp.set_button_list([{
            'text': 'Female',
            'icon': MIcon('female.svg')
        }, {
            'text': 'Male',
            'icon': MIcon('male.svg')
        }])

        country_combo_box = MComboBox().small()
        country_combo_box.addItems(['China', 'France', 'Japan', 'US'])
        date_edit = MDateEdit().small()
        date_edit.setCalendarPopup(True)

        form_lay.addRow('Name:', MLineEdit().small())
        form_lay.addRow('Gender:', gender_grp)
        form_lay.addRow('Age:', MSpinBox().small())
        form_lay.addRow('Password:'******'Country:', country_combo_box)
        form_lay.addRow('Birthday:', date_edit)
        switch = MSwitch()
        switch.setChecked(True)
        form_lay.addRow('Switch:', switch)
        slider = MSlider()
        slider.setValue(30)
        form_lay.addRow('Slider:', slider)

        button_lay = QHBoxLayout()
        button_lay.addStretch()
        button_lay.addWidget(MPushButton(text='Submit').primary())
        button_lay.addWidget(MPushButton(text='Cancel'))

        main_lay = QVBoxLayout()
        main_lay.addLayout(form_lay)
        main_lay.addWidget(MCheckBox('I accept the terms and conditions'))
        main_lay.addStretch()
        main_lay.addWidget(MDivider())
        main_lay.addLayout(button_lay)
        self.setLayout(main_lay)
Esempio n. 17
0
    def _init_ui(self):
        size_lay = QVBoxLayout()
        sub_lay1 = QHBoxLayout()
        sub_lay1.addWidget(MToolButton().svg('left_line.svg').icon_only())
        sub_lay1.addWidget(MToolButton().svg('right_line.svg').icon_only())
        sub_lay1.addWidget(MToolButton().svg('up_line.svg').icon_only())
        sub_lay1.addWidget(MToolButton().svg('down_line.svg').icon_only())
        sub_lay1.addStretch()
        size_lay.addLayout(sub_lay1)

        button2 = MToolButton().svg('detail_line.svg').icon_only()
        button2.setEnabled(False)
        button7 = MToolButton().svg('trash_line.svg').icon_only()
        button7.setCheckable(True)
        state_lay = QHBoxLayout()
        state_lay.addWidget(button2)
        state_lay.addWidget(button7)
        state_lay.addStretch()

        button_trash = MToolButton().svg('trash_line.svg').text_beside_icon()
        button_trash.setText('Delete')
        button_login = MToolButton().svg('user_line.svg').text_beside_icon()
        button_login.setText('Login')

        button_lay = QHBoxLayout()
        button_lay.addWidget(button_trash)
        button_lay.addWidget(button_login)

        sub_lay2 = QHBoxLayout()
        sub_lay2.addWidget(button2)
        sub_lay2.addWidget(button7)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different button_size'))
        main_lay.addLayout(size_lay)
        main_lay.addWidget(MDivider('disabled & checkable'))
        main_lay.addLayout(state_lay)
        main_lay.addWidget(MDivider('type=normal'))
        main_lay.addLayout(button_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 18
0
    def __init__(self, parent=None):
        super(PushButtonExample, self).__init__(parent)
        self.setWindowTitle('Example for MPushButton')

        sub_lay1 = QHBoxLayout()
        sub_lay1.addWidget(MPushButton('Default'))
        sub_lay1.addWidget(MPushButton('Primary').primary())
        sub_lay1.addWidget(MPushButton('Success').success())
        sub_lay1.addWidget(MPushButton('Warning').warning())
        sub_lay1.addWidget(MPushButton('Danger').danger())

        sub_lay2 = QHBoxLayout()
        sub_lay2.addWidget(MPushButton('Upload', MIcon('cloud_line.svg')))
        sub_lay2.addWidget(
            MPushButton('Submit', MIcon('folder_line.svg', '#ddd')).primary())
        sub_lay2.addWidget(
            MPushButton('Submit', MIcon('success_line.svg', '#ddd')).success())
        sub_lay2.addWidget(
            MPushButton('Edit', MIcon('edit_line.svg', '#ddd')).warning())
        sub_lay2.addWidget(
            MPushButton('Delete', MIcon('trash_line.svg', '#ddd')).danger())

        sub_lay3 = QHBoxLayout()
        sub_lay3.addWidget(MPushButton('Large').large().primary())
        sub_lay3.addWidget(MPushButton('Medium').medium().primary())
        sub_lay3.addWidget(MPushButton('Small').small().primary())

        disabled_button = MPushButton('Disabled')
        disabled_button.setEnabled(False)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(sub_lay1)
        main_lay.addLayout(sub_lay2)
        main_lay.addWidget(MDivider('different size'))
        main_lay.addLayout(sub_lay3)
        main_lay.addWidget(MDivider('disabled'))
        main_lay.addWidget(disabled_button)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 19
0
    def _init_ui(self):
        progress_1 = MProgressBar()
        progress_1.setValue(10)
        progress_1.setAlignment(Qt.AlignCenter)
        progress_2 = MProgressBar()
        progress_2.setValue(80)

        progress_normal = MProgressBar()
        progress_normal.setValue(30)
        progress_success = MProgressBar().success()
        progress_success.setValue(100)
        progress_error = MProgressBar().error()
        progress_error.setValue(50)
        form_lay = QFormLayout()
        form_lay.addRow('Primary:', progress_normal)
        form_lay.addRow('Success:', progress_success)
        form_lay.addRow('Error:', progress_error)

        self.progress_count = 0
        self.timer = QTimer()
        self.timer.setInterval(10)
        self.timer.timeout.connect(self.slot_timeout)
        run_button = MPushButton(text='Run Something')
        run_button.clicked.connect(self.slot_run)
        self.auto_color_progress = MProgressBar().auto_color()
        auto_color_lay = QVBoxLayout()
        auto_color_lay.addWidget(run_button)
        auto_color_lay.addWidget(self.auto_color_progress)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Basic'))

        main_lay.addWidget(progress_1)
        main_lay.addWidget(progress_2)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(form_lay)
        main_lay.addWidget(MDivider('auto color'))
        main_lay.addLayout(auto_color_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 20
0
    def __init__(self, parent=None):
        super(AvatarExample, self).__init__(parent)
        self.setWindowTitle('Example for MAvatar')
        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different size'))

        size_list = [('Huge', MAvatar.huge), ('Large', MAvatar.large),
                     ('Medium', MAvatar.medium), ('Small', MAvatar.small),
                     ('Tiny', MAvatar.tiny)]

        self.pix_map_list = [
            None,
            MPixmap('avatar.png'),
            MPixmap('app-maya.png'),
            MPixmap('app-nuke.png'),
            MPixmap('app-houdini.png')
        ]
        form_lay = QFormLayout()
        form_lay.setLabelAlignment(Qt.AlignRight)

        for label, cls in size_list:
            h_lay = QHBoxLayout()
            for image in self.pix_map_list:
                avatar_tmp = cls(image)
                h_lay.addWidget(avatar_tmp)
            h_lay.addStretch()
            form_lay.addRow(MLabel(label), h_lay)
        main_lay.addLayout(form_lay)
        self.register_field('image', None)
        main_lay.addWidget(MDivider('different image'))
        avatar = MAvatar()
        self.bind('image', avatar, 'dayu_image')
        button = MPushButton(text='Change Avatar Image').primary()
        button.clicked.connect(self.slot_change_image)

        main_lay.addWidget(avatar)
        main_lay.addWidget(button)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 21
0
    def __init__(self,
                 cover=None,
                 avatar=None,
                 title=None,
                 description=None,
                 extra=False,
                 parent=None):
        super(MMeta, self).__init__(parent)
        self.setAttribute(Qt.WA_StyledBackground)
        self._cover_label = QLabel()
        self._avatar = MAvatar()
        self._title_label = MLabel().h4()
        self._description_label = MLabel().secondary()
        self._description_label.setWordWrap(True)
        self._description_label.set_elide_mode(Qt.ElideRight)
        self._title_layout = QHBoxLayout()
        self._title_layout.addWidget(self._title_label)
        self._title_layout.addStretch()
        self._extra_button = MToolButton(
            parent=self).icon_only().svg('more.svg')
        self._title_layout.addWidget(self._extra_button)
        self._extra_button.setVisible(extra)

        content_lay = QFormLayout()
        content_lay.setContentsMargins(5, 5, 5, 5)
        content_lay.addRow(self._avatar, self._title_layout)
        content_lay.addRow(self._description_label)

        self._button_layout = QHBoxLayout()

        main_lay = QVBoxLayout()
        main_lay.setSpacing(0)
        main_lay.setContentsMargins(1, 1, 1, 1)
        main_lay.addWidget(self._cover_label)
        main_lay.addLayout(content_lay)
        main_lay.addLayout(self._button_layout)
        main_lay.addStretch()
        self.setLayout(main_lay)
        self._cover_label.setFixedSize(QSize(200, 200))
Esempio n. 22
0
    def _init_ui(self):

        basic_card_lay = MFlowLayout()
        basic_card_lay.setSpacing(20)
        for setting in [{
                'title': '',
        }, {
                'title': 'Card Title',
                'size': dayu_theme.small
        }, {
                'title': 'Card Title',
                'image': MPixmap('app-houdini.png')
        }, {
                'title': 'Card Title',
                'extra': 'More',
                'image': MPixmap('app-houdini.png')
        }, {
                'title': 'Card Title',
                'extra': 'More',
        }]:
            card_0 = MCard(**setting)
            content_widget_0 = QWidget()
            content_lay_0 = QVBoxLayout()
            content_lay_0.setContentsMargins(15, 15, 15, 15)
            content_widget_0.setLayout(content_lay_0)
            for i in range(4):
                content_lay_0.addWidget(MLabel('Card Content {}'.format(i +
                                                                        1)))
            card_0.set_widget(content_widget_0)

            basic_card_lay.addWidget(card_0)

        meta_card_lay = MFlowLayout()
        meta_card_lay.setSpacing(20)
        for setting in [
            {
                'title': u'Houdini',
                'description': u'Side Effects Software的旗舰级产品,是创建高级视觉效果的有效工具',
                'avatar': MPixmap('user_line.svg'),
                'cover': MPixmap('app-houdini.png')
            },
            {
                'title': u'Autodesk Maya',
                'description': u'3D 数字动画和视觉效果的世界领先软件应用程序',
                'cover': MPixmap('app-maya.png')
            },
        ]:
            meta_card = MMeta()
            meta_card.setup_data(setting)
            meta_card_lay.addWidget(meta_card)

        task_card_lay = QVBoxLayout()
        # task_card_lay.setSpacing(10)
        for setting in [
            {
                'title': u'Task A',
                'description':
                u'demo pl_0010 Animation \n2019/04/01 - 2019/04/09',
                'avatar': MPixmap('success_line.svg',
                                  dayu_theme.success_color),
            }, {
                'title': u'Task B',
                'description': u'#2 closed by xiao hua.',
                'avatar': MPixmap('error_line.svg', dayu_theme.error_color)
            }, {
                'title': u'Task C',
                'description': u'#3 closed by xiao hua.',
                'avatar': MPixmap('warning_line.svg', dayu_theme.warning_color)
            }
        ] * 5:
            meta_card = MMeta(extra=True)
            meta_card.setup_data(setting)
            task_card_lay.addWidget(meta_card)

        left_lay = QVBoxLayout()
        left_lay.addWidget(MDivider('Basic'))
        left_lay.addLayout(basic_card_lay)
        left_lay.addWidget(MDivider('Meta E-Commerce Example'))
        left_lay.addLayout(meta_card_lay)
        left_lay.addStretch()
        left_widget = QWidget()
        left_widget.setLayout(left_lay)

        right_lay = QVBoxLayout()
        right_lay.addWidget(MDivider('Meta Task Item Example'))
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        task_widget = QWidget()
        task_widget.setLayout(task_card_lay)
        scroll.setWidget(task_widget)

        right_lay.addWidget(scroll)
        right_widget = QWidget()
        right_widget.setLayout(right_lay)

        splitter = QSplitter()
        splitter.addWidget(left_widget)
        splitter.addWidget(right_widget)
        splitter.setStretchFactor(0, 80)
        splitter.setStretchFactor(1, 20)
        main_lay = QVBoxLayout()
        main_lay.addWidget(splitter)
        self.setLayout(main_lay)
Esempio n. 23
0
    def _init_ui(self):
        title_lay = QGridLayout()
        title_lay.addWidget(MLabel(u'一级标题').h1(), 0, 0)
        title_lay.addWidget(MLabel(u'二级标题').h2(), 1, 0)
        title_lay.addWidget(MLabel(u'三级标题').h3(), 2, 0)
        title_lay.addWidget(MLabel(u'四级标题').h4(), 3, 0)
        title_lay.addWidget(MLabel('h1 Level').h1(), 0, 1)
        title_lay.addWidget(MLabel('h2 Level').h2(), 1, 1)
        title_lay.addWidget(MLabel('h3 Level').h3(), 2, 1)
        title_lay.addWidget(MLabel('h4 Level').h4(), 3, 1)

        text_type_lay = QHBoxLayout()
        text_type_lay.addWidget(MLabel('MLabel: Normal'))
        text_type_lay.addWidget(MLabel('MLabel: Secondary').secondary())
        text_type_lay.addWidget(MLabel('MLabel: Warning').warning())
        text_type_lay.addWidget(MLabel('MLabel: Danger').danger())
        disable_text = MLabel('MLabel: Disabled')
        disable_text.setEnabled(False)
        text_type_lay.addWidget(disable_text)

        text_attr_lay = QHBoxLayout()
        text_attr_lay.addWidget(MLabel('MLabel: Mark').mark())
        text_attr_lay.addWidget(MLabel('MLabel: Code').code())
        text_attr_lay.addWidget(MLabel('MLabel: Underline').underline())
        text_attr_lay.addWidget(MLabel('MLabel: Delete').delete())
        text_attr_lay.addWidget(MLabel('MLabel: Strong').strong())

        text_mix_lay = QHBoxLayout()
        text_mix_lay.addWidget(
            MLabel('MLabel: Strong & Underline').strong().underline())
        text_mix_lay.addWidget(
            MLabel('MLabel: Danger & Delete').danger().delete())
        text_mix_lay.addWidget(
            MLabel('MLabel: Warning & Strong').warning().strong())
        text_mix_lay.addWidget(MLabel('MLabel: H4 & Mark').h4().mark())

        data_bind_lay = QHBoxLayout()
        data_bind_label = MLabel()
        button = MPushButton(text='Random An Animal').primary()
        button.clicked.connect(self.slot_change_text)
        data_bind_lay.addWidget(data_bind_label)
        data_bind_lay.addWidget(button)
        data_bind_lay.addStretch()
        self.register_field('show_text', 'Guess')
        self.bind('show_text', data_bind_label, 'text')

        lay_elide = QVBoxLayout()
        label_none = MLabel('This is a elide NONE mode label. '
                            'Ellipsis should NOT appear in the text.')
        label_left = MLabel(
            'This is a elide LEFT mode label. '
            'The ellipsis should appear at the beginning of the text. '
            'xiao mao xiao gou xiao ci wei')
        label_left.set_elide_mode(Qt.ElideLeft)
        label_middle = MLabel(
            'This is a elide MIDDLE mode label. '
            'The ellipsis should appear in the middle of the text. '
            'xiao mao xiao gou xiao ci wei')
        label_middle.set_elide_mode(Qt.ElideMiddle)
        label_right = MLabel()
        label_right.setText(
            'This is a elide RIGHT mode label. '
            'The ellipsis should appear at the end of the text. '
            'Some text to fill the line bala bala bala.')
        label_right.set_elide_mode(Qt.ElideRight)
        lay_elide.addWidget(label_none)
        lay_elide.addWidget(label_left)
        lay_elide.addWidget(label_middle)
        lay_elide.addWidget(label_right)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different level'))
        main_lay.addLayout(title_lay)
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(text_type_lay)
        main_lay.addWidget(MDivider('different property'))
        main_lay.addLayout(text_attr_lay)
        main_lay.addWidget(MDivider('mix'))
        main_lay.addLayout(text_mix_lay)

        # main_lay.addWidget(MDivider('data bind'))
        # main_lay.addLayout(data_bind_lay)
        main_lay.addWidget(MDivider('elide mode'))
        main_lay.addLayout(lay_elide)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 24
0
    def _init_ui(self):
        size_lay = QHBoxLayout()
        line_edit_l = MLineEdit().large()
        line_edit_l.setPlaceholderText('large size')
        line_edit_m = MLineEdit().medium()
        line_edit_m.setPlaceholderText('default size')
        line_edit_s = MLineEdit().small()
        line_edit_s.setPlaceholderText('small size')
        size_lay.addWidget(line_edit_l)
        size_lay.addWidget(line_edit_m)
        size_lay.addWidget(line_edit_s)

        line_edit_tool_button = MLineEdit(text='MToolButton')
        line_edit_tool_button.set_prefix_widget(
            MToolButton().svg('user_line.svg').icon_only())

        line_edit_label = MLineEdit(text='MLabel')
        tool_button = MLabel(text='User').mark().secondary()
        tool_button.setAlignment(Qt.AlignCenter)
        tool_button.setFixedWidth(80)
        line_edit_label.set_prefix_widget(tool_button)

        line_edit_push_button = MLineEdit(text='MPushButton')
        push_button = MPushButton(text='Go').primary()
        push_button.setFixedWidth(40)
        line_edit_push_button.set_suffix_widget(push_button)

        search_engine_line_edit = MLineEdit().search_engine().large()
        search_engine_line_edit.returnPressed.connect(self.slot_search)

        line_edit_options = MLineEdit()
        combobox = MComboBox()
        option_menu = MMenu()
        option_menu.set_separator('|')
        option_menu.set_data([r'http://', r'https://'])
        combobox.set_menu(option_menu)
        combobox.set_value('http://')
        combobox.setFixedWidth(90)
        line_edit_options.set_prefix_widget(combobox)

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different size'))
        main_lay.addLayout(size_lay)
        main_lay.addWidget(MDivider('custom prefix and suffix widget'))
        main_lay.addWidget(line_edit_tool_button)
        main_lay.addWidget(line_edit_label)
        main_lay.addWidget(line_edit_push_button)
        main_lay.addWidget(MDivider('preset'))

        main_lay.addWidget(MLabel('error'))
        main_lay.addWidget(
            MLineEdit(text='waring: file d:/ddd/ccc.jpg not exists.').error())
        main_lay.addWidget(MLabel('search'))
        main_lay.addWidget(MLineEdit().search().small())
        main_lay.addWidget(MLabel('search_engine'))
        main_lay.addWidget(search_engine_line_edit)
        main_lay.addWidget(MLabel('file'))
        main_lay.addWidget(MLineEdit().file().small())
        main_lay.addWidget(MLabel('folder'))
        main_lay.addWidget(MLineEdit().folder().small())
        main_lay.addWidget(MLabel('MLineEdit.options()'))
        main_lay.addWidget(line_edit_options)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 25
0
    def _init_ui(self):
        button3 = MPushButton(text='Normal Message').primary()
        button4 = MPushButton(text='Success Message').success()
        button5 = MPushButton(text='Warning Message').warning()
        button6 = MPushButton(text='Error Message').danger()
        button3.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.info,
                              {'text': u'这是一条普通提示'}))
        button4.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.success,
                              {'text': u'恭喜你,成功啦!'}))
        button5.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.warning,
                              {'text': u'我警告你哦!'}))
        button6.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.error,
                              {'text': u'失败了!'}))

        sub_lay1 = QHBoxLayout()
        sub_lay1.addWidget(button3)
        sub_lay1.addWidget(button4)
        sub_lay1.addWidget(button5)
        sub_lay1.addWidget(button6)

        button_duration = MPushButton(text='show 5s Message')
        button_duration.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.info, {
                'text': u'该条消息将显示5秒后关闭',
                'duration': 5
            }))
        button_closable = MPushButton(text='closable Message')
        button_closable.clicked.connect(
            functools.partial(self.slot_show_message, MMessage.info, {
                'text': u'可手动关闭提示',
                'closable': True
            }))
        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('different type'))
        main_lay.addLayout(sub_lay1)
        main_lay.addWidget(MLabel(u'不同的提示状态:普通、成功、警告、错误。默认2秒后消失'))
        main_lay.addWidget(MDivider('set duration'))
        main_lay.addWidget(button_duration)
        main_lay.addWidget(MLabel(u'自定义时长,config中设置duration值,单位为秒'))

        main_lay.addWidget(MDivider('set closable'))
        main_lay.addWidget(button_closable)
        main_lay.addWidget(MLabel(u'设置是否可关闭,config中设置closable 为 True'))

        button_grp = MPushButtonGroup()
        button_grp.set_button_list([
            {
                'text':
                'set duration to 1s',
                'clicked':
                functools.partial(self.slot_set_config, MMessage.config,
                                  {'duration': 1})
            },
            {
                'text':
                'set duration to 10s',
                'clicked':
                functools.partial(self.slot_set_config, MMessage.config,
                                  {'duration': 10})
            },
            {
                'text':
                'set top to 5',
                'clicked':
                functools.partial(self.slot_set_config, MMessage.config,
                                  {'top': 5})
            },
            {
                'text':
                'set top to 50',
                'clicked':
                functools.partial(self.slot_set_config, MMessage.config,
                                  {'top': 50})
            },
        ])
        loading_button = MPushButton('Display a loading indicator')
        loading_button.clicked.connect(self.slot_show_loading)
        main_lay.addWidget(MDivider('set global setting'))
        main_lay.addWidget(button_grp)
        main_lay.addWidget(
            MLabel(u'全局设置默认duration(默认2秒);top(离parent顶端的距离,默认24px)'))
        main_lay.addWidget(loading_button)

        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 26
0
    def _init_ui(self):
        browser_1 = MClickBrowserFilePushButton(
            text='Browser File PushButton').primary()
        browser_2 = MClickBrowserFolderPushButton(
            text='Browser Folder PushButton')
        browser_2.setIcon(MIcon('upload_line.svg'))
        browser_3 = MClickBrowserFilePushButton(text='Browser Multi Files',
                                                multiple=True).primary()
        lay_1 = QHBoxLayout()
        lay_1.addWidget(browser_1)
        lay_1.addWidget(browser_2)
        lay_1.addWidget(browser_3)

        browser_4 = MClickBrowserFileToolButton().huge()
        label_4 = MLabel()
        label_4.set_elide_mode(Qt.ElideMiddle)
        browser_4.sig_file_changed.connect(label_4.setText)

        browser_5 = MClickBrowserFolderToolButton().huge()
        label_5 = MLabel()
        label_5.set_elide_mode(Qt.ElideMiddle)
        browser_5.sig_folder_changed.connect(label_5.setText)

        lay_2 = QHBoxLayout()
        lay_2.addWidget(label_4)
        lay_2.addWidget(browser_4)
        lay_2.addWidget(label_5)
        lay_2.addWidget(browser_5)

        browser_6 = MDragFileButton(text='Click or drag file here')
        browser_6.set_dayu_svg('attachment_line.svg')
        label_6 = MLabel()
        label_6.set_elide_mode(Qt.ElideMiddle)
        browser_6.sig_file_changed.connect(label_6.setText)

        browser_7 = MDragFolderButton()
        label_7 = MLabel()
        label_7.set_elide_mode(Qt.ElideRight)
        browser_7.sig_folder_changed.connect(label_7.setText)

        lay_3 = QGridLayout()
        lay_3.addWidget(browser_6, 2, 0)
        lay_3.addWidget(browser_7, 2, 1)
        lay_3.addWidget(label_6, 3, 0)
        lay_3.addWidget(label_7, 3, 1)

        browser_8 = MDragFileButton(text='Click or drag media file here',
                                    multiple=False)
        browser_8.set_dayu_svg('media_line.svg')
        browser_8.set_dayu_filters(['.mov', '.mp4'])
        browser_8_label = MLabel()
        browser_8_label.set_elide_mode(Qt.ElideRight)
        self.register_field('current_file', '')
        self.bind('current_file',
                  browser_8,
                  'dayu_path',
                  signal='sig_file_changed')
        self.bind('current_file', browser_8_label, 'text')

        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('MClickBrowser*PushButton'))
        main_lay.addLayout(lay_1)
        main_lay.addWidget(MDivider('MClickBrowser*ToolButton'))
        main_lay.addLayout(lay_2)
        main_lay.addWidget(MDivider('MDragBrowser*ToolButton'))
        main_lay.addLayout(lay_3)
        main_lay.addWidget(MDivider('data bind'))
        main_lay.addWidget(browser_8)
        main_lay.addWidget(browser_8_label)
        main_lay.addStretch()
        self.setLayout(main_lay)
Esempio n. 27
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(b'windowOpacity')
        self._opacity_ani.setStartValue(0.0)
        self._opacity_ani.setEndValue(0.9)

        self._get_center_position(parent)
        self._fade_int()
    def _init_ui(self):
        main_lay = QVBoxLayout()
        self.setLayout(main_lay)
        main_lay.addWidget(MDivider('circle'))
        lay1 = QHBoxLayout()
        circle_1 = MProgressCircle(parent=self)
        circle_1.setFormat(u'%p Days')
        circle_1.setValue(80)
        circle_2 = MProgressCircle(parent=self)
        circle_2.set_dayu_color(dayu_theme.success_color)
        circle_2.setValue(100)
        circle_3 = MProgressCircle(parent=self)
        circle_3.set_dayu_color(dayu_theme.error_color)
        circle_3.setValue(40)

        dashboard_1 = MProgressCircle.dashboard(parent=self)
        dashboard_1.setFormat(u'%p Days')
        dashboard_1.setValue(80)
        dashboard_2 = MProgressCircle.dashboard(parent=self)
        dashboard_2.set_dayu_color(dayu_theme.success_color)
        dashboard_2.setValue(100)
        dashboard_3 = MProgressCircle.dashboard(parent=self)
        dashboard_3.set_dayu_color(dayu_theme.error_color)
        dashboard_3.setValue(40)

        lay1.addWidget(circle_1)
        lay1.addWidget(circle_2)
        lay1.addWidget(circle_3)

        dashboard_lay = QHBoxLayout()
        dashboard_lay.addWidget(dashboard_1)
        dashboard_lay.addWidget(dashboard_2)
        dashboard_lay.addWidget(dashboard_3)
        main_lay.addLayout(lay1)
        main_lay.addWidget(MDivider('dashboard'))
        main_lay.addLayout(dashboard_lay)
        main_lay.addWidget(MDivider('different radius'))

        circle_4 = MProgressCircle(parent=self)
        circle_4.set_dayu_width(100)
        circle_4.setValue(40)
        circle_5 = MProgressCircle(parent=self)
        circle_5.setValue(40)
        circle_6 = MProgressCircle(parent=self)
        circle_6.set_dayu_width(160)
        circle_6.setValue(40)
        lay2 = QHBoxLayout()
        lay2.addWidget(circle_4)
        lay2.addWidget(circle_5)
        lay2.addWidget(circle_6)

        main_lay.addLayout(lay2)
        main_lay.addWidget(MDivider('data bind'))

        self.register_field('percent', 0)
        self.register_field('color', self.get_color)
        self.register_field('format', self.get_format)
        circle = MProgressCircle(parent=self)

        self.bind('percent', circle, 'value')
        self.bind('color', circle, 'dayu_color')
        self.bind('format', circle, 'format')
        lay3 = QHBoxLayout()
        button_grp = MPushButtonGroup()
        button_grp.set_dayu_type(MPushButton.DefaultType)
        button_grp.set_button_list([
            {'text': '+', 'clicked': functools.partial(self.slot_change_percent, 10)},
            {'text': '-', 'clicked': functools.partial(self.slot_change_percent, -10)},
        ])
        lay3.addWidget(circle)
        lay3.addWidget(button_grp)
        lay3.addStretch()
        main_lay.addLayout(lay3)

        custom_widget = QWidget()
        custom_layout = QVBoxLayout()
        custom_layout.setContentsMargins(20, 20, 20, 20)
        custom_layout.addStretch()
        custom_widget.setLayout(custom_layout)
        lab1 = MLabel(text='42,001,776').h3()
        lab2 = MLabel(text=u'消费人群规模').secondary()
        lab3 = MLabel(text=u'总占人数 75%').secondary()
        lab1.setAlignment(Qt.AlignCenter)
        lab2.setAlignment(Qt.AlignCenter)
        lab3.setAlignment(Qt.AlignCenter)
        custom_layout.addWidget(lab1)
        custom_layout.addWidget(lab2)
        custom_layout.addWidget(MDivider())
        custom_layout.addWidget(lab3)
        custom_layout.addStretch()
        custom_circle = MProgressCircle()
        custom_circle.set_dayu_width(180)
        custom_circle.setValue(75)
        custom_circle.set_widget(custom_widget)

        main_lay.addWidget(MDivider('custom circle'))
        main_lay.addWidget(custom_circle)
        main_lay.addStretch()
Esempio n. 29
0
    def __init__(self, parent=None):
        super(MTagTest, self).__init__(parent)
        self.setWindowTitle('Examples for MTag')
        self.default_lay = MFlowLayout()
        self.default_lay.addWidget(MTag(text='Tag 1'))
        self.default_lay.addWidget(MTag(text='Closeable Tag').closeable())
        add_tag = MNewTag('New Tag')
        add_tag.sig_add_tag.connect(self.slot_add_tag)
        self.default_lay.addWidget(add_tag)

        color_lay = MFlowLayout()
        for text, color in [
            ('magenta', dayu_theme.magenta),
            ('red', dayu_theme.red),
            ('volcano', dayu_theme.volcano),
            ('orange', dayu_theme.orange),
            ('gold', dayu_theme.gold),
            ('lime', dayu_theme.lime),
            ('green', dayu_theme.green),
            ('cyan', dayu_theme.cyan),
            ('blue', dayu_theme.blue),
            ('geekblue', dayu_theme.geekblue),
            ('purple', dayu_theme.purple),
        ]:
            tag = MTag(text=text).closeable()
            tag.set_dayu_color(color)
            tag.sig_closed.connect(
                functools.partial(MMessage.success, 'Delete "{}"'.format(text),
                                  self))
            color_lay.addWidget(tag)

        no_border_lay = MFlowLayout()
        for text, color in [
            ('red', dayu_theme.red),
            ('green', dayu_theme.green),
            ('blue', dayu_theme.blue),
            ('geekblue', dayu_theme.geekblue),
            ('volcano', dayu_theme.volcano),
            ('orange', dayu_theme.orange),
            ('purple', dayu_theme.purple),
            ('lime', dayu_theme.lime),
        ]:
            tag = MTag(text=text).border(False).clickable()
            tag.set_dayu_color(color)
            tag.sig_clicked.connect(
                functools.partial(MMessage.success, 'Click "{}"'.format(text),
                                  self))
            no_border_lay.addWidget(tag)

        label = MLabel('Categories:')
        topic_lay = QHBoxLayout()
        topic_lay.addWidget(label)
        for i in ['Movies', 'Books', 'Music', 'Sports']:
            topic_lay.addWidget(MCheckableTag(text=i))
        topic_lay.addStretch()
        main_lay = QVBoxLayout()
        main_lay.addWidget(MDivider('Normal'))
        main_lay.addLayout(self.default_lay)
        main_lay.addWidget(MDivider('Border'))
        main_lay.addLayout(color_lay)
        main_lay.addWidget(MDivider('No Border & Click'))
        main_lay.addLayout(no_border_lay)
        main_lay.addWidget(MDivider('Checkable'))
        main_lay.addLayout(topic_lay)
        main_lay.addStretch()
        self.setLayout(main_lay)