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)
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)
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))
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)
def setRegeditWindow(self): self.custom_widget = QWidget() custom_lay = QFormLayout() self.custom_widget.setLayout(custom_lay) self.btn_regedit_image = MPushButton(u'选择文件') self.line_edit_regedit_name = MLineEdit() self.line_edit_regedit_password = MLineEdit() self.line_edit_regedit_password2 = MLineEdit() self.switch_identity = MSwitch().large() custom_lay.addRow(u' 选择头像: ', self.btn_regedit_image) custom_lay.addRow(u' 账号名称: ', self.line_edit_regedit_name) custom_lay.addRow(u' 账号密码: ', self.line_edit_regedit_password) custom_lay.addRow(u' 确认密码: ', self.line_edit_regedit_password2) custom_lay.addRow(u' 管理权限: ', self.switch_identity) # custom_lay.addRow(u'管理钥匙: ',self.line_edit_key) # self.custom_widget.layout().addRow(MLabel) self.drawer = MDrawer('Regedit', parent=self) submit_button = MPushButton(u'注册').primary() cancel_button = MPushButton(u'取消') self.drawer.add_button(cancel_button) self.drawer.add_button(submit_button) self.drawer.setFixedWidth(Data.getWindowWidth() / 5) self.drawer.set_widget(self.custom_widget) self.line_edit_regedit_name.setText(self.username) self.line_edit_regedit_password.setText(self.password) self.line_edit_regedit_password2.setText(self.rePassword) self.switch_identity.clicked.connect(self.signUpManager) self.btn_regedit_image.clicked.connect(self.setHeadPorfie) submit_button.clicked.connect(self.regedit) cancel_button.clicked.connect(self.drawer.close)
def slot_new_account(self): custom_widget = QWidget() custom_lay = QFormLayout() custom_lay.addRow('Name', MLineEdit()) custom_lay.addRow('Age', MSpinBox()) custom_lay.addRow('Birth', MDateEdit()) custom_widget.setLayout(custom_lay) drawer = MDrawer('New account', parent=self) submit_button = MPushButton('Submit').primary() submit_button.clicked.connect(drawer.close) drawer.add_button(MPushButton('Cancel')) drawer.add_button(submit_button) drawer.setFixedWidth(200) drawer.set_widget(custom_widget) drawer.show()
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)
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)