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)
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)
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)
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): self.setWindowModality(Qt.ApplicationModal) self.setMinimumSize(Data.getWindowWidth() / 4.5, Data.getWindowHeight() / 1.6) self.setMaximumSize(Data.getWindowWidth() / 4.5, Data.getWindowHeight() / 1.6) browser_4 = MClickBrowserFolderToolButton().huge() self.lineEdit = MLineEdit(text='filepath') self.lineEdit.setReadOnly(True) browser_4.sig_folder_changed.connect(self.lineEdit.setText) lay_1 = QHBoxLayout() lay_1.addWidget(self.lineEdit) lay_1.addWidget(browser_4) self.tab = MLineTabWidget() widget = QWidget() widget.setLayout(QVBoxLayout()) self.lineEdit_width = MLineEdit() tool_button = MLabel(text=u'宽度').mark().secondary() tool_button.setAlignment(Qt.AlignCenter) tool_button.setFixedWidth(80) self.lineEdit_width.set_prefix_widget(tool_button) self.lineEdit_width.setText("1080") self.lineEdit_width.setValidator(QIntValidator()) self.lineEdit_height = MLineEdit() tool_button = MLabel(text=u'高度').mark().secondary() tool_button.setAlignment(Qt.AlignCenter) tool_button.setFixedWidth(80) self.lineEdit_height.set_prefix_widget(tool_button) self.lineEdit_height.setText("720") self.lineEdit_height.setValidator(QIntValidator()) self.lineEdit_level = MLineEdit() tool_button = MLabel(text=u'精度').mark().secondary() tool_button.setAlignment(Qt.AlignCenter) tool_button.setFixedWidth(80) self.lineEdit_level.set_prefix_widget(tool_button) self.lineEdit_level.setText("50") self.lineEdit_level.setValidator(QIntValidator()) widget.layout().addWidget(MLabel(u'贴图大小')) widget.layout().addWidget(self.lineEdit_width) widget.layout().addWidget(self.lineEdit_height) widget.layout().addSpacing(10) widget.layout().addWidget(MLabel(u'贴图精度')) widget.layout().addWidget(self.lineEdit_level) self.tab.add_tab(widget, u'低精度图片') widget2 = QWidget() widget2.setLayout(QVBoxLayout()) self.MlineEdit_level = MLineEdit() tool_button = MLabel(text=u'精度').mark().secondary() tool_button.setAlignment(Qt.AlignCenter) tool_button.setFixedWidth(80) self.MlineEdit_level.set_prefix_widget(tool_button) self.MlineEdit_level.setText("50") self.MlineEdit_level.setValidator(QIntValidator()) widget2.layout().addWidget(MLabel(u'模型精度')) widget2.layout().addWidget(self.MlineEdit_level) widget2.layout().addSpacing(100) self.tab.add_tab(widget2, u'低精度模型') btn_layout = QHBoxLayout() self.btn_ok = MPushButton(text=u'导出').primary() self.btn_ok.setFixedWidth(80) self.btn_cancel = MPushButton(text=u'取消').primary() self.btn_cancel.setFixedWidth(80) btn_layout.addWidget(self.btn_ok) btn_layout.addWidget(self.btn_cancel) main_lay = QVBoxLayout() main_lay.addSpacing(20) main_lay.addWidget(MDivider(u'路径选择')) main_lay.addLayout(lay_1) main_lay.addWidget(MDivider(u'操作选择')) main_lay.addWidget(self.tab) main_lay.addWidget(MDivider(u'')) main_lay.addLayout(btn_layout) main_lay.addSpacing(20) self.setLayout(main_lay) dayu_theme.background_color = "#262626" dayu_theme.apply(self)