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)
def _init_ui(self): form_lay = QtWidgets.QFormLayout() form_lay.setLabelAlignment(QtCore.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 = QtWidgets.QHBoxLayout() button_lay.addStretch() button_lay.addWidget(MPushButton(text="Submit").primary()) button_lay.addWidget(MPushButton(text="Cancel")) main_lay = QtWidgets.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)
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)
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 slot_new_account(self): custom_widget = QtWidgets.QWidget() custom_lay = QtWidgets.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_widget_to_bottom(MPushButton("Cancel")) drawer.add_widget_to_bottom(submit_button) scale_x, _ = get_scale_factor() drawer.setFixedWidth(300 * scale_x) drawer.set_widget(custom_widget) drawer.show()