def __init__(self, parent=None): super(CheckBoxExample, self).__init__(parent) self.setWindowTitle("Example for MCheckBox") grid_lay = QtWidgets.QGridLayout() for index, (text, state) in enumerate([ ("Unchecked", QtCore.Qt.Unchecked), ("Checked", QtCore.Qt.Checked), ("Partially", QtCore.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 = QtWidgets.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 = QtWidgets.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)
def __init__(self, parent=None): super(RadioButtonExample, self).__init__(parent) self.setWindowTitle("Example for MRadioButton") widget_1 = QtWidgets.QWidget() lay_1 = QtWidgets.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 = QtWidgets.QWidget() lay_2 = QtWidgets.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("支付宝") 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 = QtWidgets.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)
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)
def _init_ui(self): self.app_data = [ {"text": "Maya", "icon": MIcon("app-maya.png")}, {"text": "Nuke", "icon": MIcon("app-nuke.png")}, {"text": "Houdini", "icon": MIcon("app-houdini.png")}, ] radio_group_h = MCheckBoxGroup() radio_group_v = MCheckBoxGroup(orientation=QtCore.Qt.Vertical) radio_group_h.set_button_list(self.app_data) radio_group_v.set_button_list(self.app_data) self.data_list = ["北京", "上海", "广州", "深圳", "郑州", "石家庄"] radio_group_b = MCheckBoxGroup() radio_group_b.set_button_list(self.data_list) button = MPushButton(text="Change Value") button.clicked.connect(self.slot_button_clicked) label = MLabel() self.register_field("checked_app", ["北京", "郑州"]) self.register_field( "checked_app_text", lambda: " & ".join(self.field("checked_app")) ) self.bind( "checked_app", radio_group_b, "dayu_checked", signal="sig_checked_changed" ) self.bind("checked_app_text", label, "text") radio_group_tri = MCheckBoxGroup() radio_group_tri.set_button_list(self.app_data) self.register_field("check_grp", ["Maya"]) self.bind( "check_grp", radio_group_tri, "dayu_checked", signal="sig_checked_changed" ) main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("Orientation Qt.Horizontal")) main_lay.addWidget(radio_group_h) main_lay.addWidget(MDivider("Orientation Qt.Vertical")) main_lay.addWidget(radio_group_v) main_lay.addWidget(MDivider("Data Bind")) main_lay.addWidget(radio_group_b) main_lay.addWidget(label) main_lay.addWidget(button) main_lay.addWidget(MDivider("Try Context Menu")) main_lay.addWidget(radio_group_tri) main_lay.addStretch() self.setLayout(main_lay)
def __init__(self, parent=None): super(PushButtonExample, self).__init__(parent) self.setWindowTitle("Example for MPushButton") sub_lay1 = QtWidgets.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 = QtWidgets.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 = QtWidgets.QHBoxLayout() sub_lay3.addWidget(MPushButton("Large").large().primary()) sub_lay3.addWidget(MPushButton("Medium").medium().primary()) sub_lay3.addWidget(MPushButton("Small").small().primary()) disabled_button_1 = MPushButton("Disabled").huge() disabled_button_1.setEnabled(False) disabled_button_2 = MPushButton("Disabled").large() disabled_button_2.setEnabled(False) disabled_button_3 = MPushButton("Disabled") disabled_button_3.setEnabled(False) disabled_button_4 = MPushButton("Disabled").small() disabled_button_4.setEnabled(False) disable_lay = QtWidgets.QHBoxLayout() disable_lay.addWidget(disabled_button_1) disable_lay.addWidget(disabled_button_2) disable_lay.addWidget(disabled_button_3) disable_lay.addWidget(disabled_button_4) main_lay = QtWidgets.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.addLayout(disable_lay) main_lay.addStretch() self.setLayout(main_lay)
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)
def _init_ui(self): scale_x, _ = get_scale_factor() self.button_grp = MRadioButtonGroup() self.button_grp.set_button_list( ["top", {"text": "right", "checked": True}, "bottom", "left"] ) open_button_2 = MPushButton("Open").primary() open_button_2.clicked.connect(self.slot_open_button_2) placement_lay = QtWidgets.QHBoxLayout() placement_lay.addWidget(self.button_grp) placement_lay.addSpacing(20 * scale_x) placement_lay.addWidget(open_button_2) placement_lay.addStretch() new_account_button = MPushButton( text="New account", icon=MIcon("add_line.svg", "#fff") ).primary() new_account_button.clicked.connect(self.slot_new_account) new_account_lay = QtWidgets.QHBoxLayout() new_account_lay.addWidget(MLabel("Submit form in drawer")) new_account_lay.addWidget(new_account_button) new_account_lay.addStretch() main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("Custom Placement")) main_lay.addLayout(placement_lay) main_lay.addWidget(MDivider("Submit form in drawer")) main_lay.addLayout(new_account_lay) main_lay.addWidget(MDivider("Preview drawer")) self.setLayout(main_lay)
def _init_ui(self): self.button_grp = MRadioButtonGroup() self.button_grp.set_button_list( ['top', { 'text': 'right', 'checked': True }, 'bottom', 'left']) open_button_2 = MPushButton('Open').primary() open_button_2.clicked.connect(self.slot_open_button_2) placement_lay = QHBoxLayout() placement_lay.addWidget(self.button_grp) placement_lay.addSpacing(20) placement_lay.addWidget(open_button_2) placement_lay.addStretch() new_account_button = MPushButton(text='New account', icon=MIcon('add_line.svg', '#fff')).primary() new_account_button.clicked.connect(self.slot_new_account) new_account_lay = QHBoxLayout() new_account_lay.addWidget(MLabel('Submit form in drawer')) new_account_lay.addWidget(new_account_button) new_account_lay.addStretch() main_lay = QVBoxLayout() main_lay.addWidget(MDivider('Custom Placement')) main_lay.addLayout(placement_lay) main_lay.addWidget(MDivider('Submit form in drawer')) main_lay.addLayout(new_account_lay) main_lay.addWidget(MDivider('Preview drawer')) 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 test_mpushbutton_init(qtbot, dayu_type, dayu_size, icon, text): """Test MPushButton set_dayu_size and set_dayu_type.""" widget = MPushButton(icon=MIcon(icon) if icon else icon, text=text) widget.set_dayu_size(dayu_size) widget.set_dayu_type(dayu_type) qtbot.addWidget(widget) assert widget.property('dayu_type') == dayu_type assert widget.property('dayu_size') == dayu_size
def _init_ui(self): button_config_list = [ { "text": "Add", "icon": MIcon("add_line.svg", "#fff"), "type": MPushButton.PrimaryType, }, { "text": "Edit", "icon": MIcon("edit_fill.svg", "#fff"), "type": MPushButton.WarningType, }, { "text": "Delete", "icon": MIcon("trash_line.svg", "#fff"), "type": MPushButton.DangerType, }, ] button_group_h = MPushButtonGroup() button_group_h.set_dayu_size(dayu_theme.large) button_group_h.set_button_list(button_config_list) h_lay = QtWidgets.QHBoxLayout() h_lay.addWidget(button_group_h) h_lay.addStretch() button_group_v = MPushButtonGroup(orientation=QtCore.Qt.Vertical) button_group_v.set_button_list(button_config_list) h_lay_2 = QtWidgets.QHBoxLayout() h_lay_2.addWidget(button_group_v) h_lay_2.addStretch() main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget( MLabel( "MPushButtonGroup is MPushButton collection. they are not exclusive." )) main_lay.addWidget( MDivider("MPushButton group: Horizontal & Small Size")) main_lay.addLayout(h_lay) main_lay.addWidget( MDivider("MPushButton group: Vertical & Default Size")) main_lay.addLayout(h_lay_2) 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)
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)
def enterEvent(self, event): """Override enter event to highlight the icon""" if self._dayu_svg: self.setIcon(MIcon(self._dayu_svg, dayu_theme.primary_color)) return super(MToolButton, self).enterEvent(event)
def _polish_icon(self, checked=None): if self._dayu_svg: if self.isCheckable() and self.isChecked(): self.setIcon(MIcon(self._dayu_svg, dayu_theme.primary_color)) else: self.setIcon(MIcon(self._dayu_svg))
def _(input_tuple): return MIcon(*input_tuple)
def _(input_string): return MIcon(input_string)
def _init_ui(self): radio_group_h = MRadioButtonGroup() radio_group_h.set_button_list( ["Apple", { "text": "Banana" }, { "text": "Pear" }]) radio_grp_1_lay = QtWidgets.QHBoxLayout() radio_grp_1_lay.addWidget(radio_group_h) radio_grp_1_lay.addStretch() app_data = [ { "text": "Maya", "icon": MIcon("app-maya.png") }, { "text": "Nuke", "icon": MIcon("app-nuke.png") }, { "text": "Houdini", "icon": MIcon("app-houdini.png") }, ] radio_group_v = MRadioButtonGroup(orientation=QtCore.Qt.Vertical) radio_group_v.set_button_list(app_data) radio_group_button_h = MRadioButtonGroup() radio_group_button_h.set_button_list(app_data) radio_grp_h_lay = QtWidgets.QHBoxLayout() radio_grp_h_lay.addWidget(radio_group_button_h) radio_grp_h_lay.addStretch() radio_group_button_v = MRadioButtonGroup( orientation=QtCore.Qt.Vertical) radio_group_button_v.set_button_list(app_data) self.register_field("value1", -1) self.register_field( "value1_text", functools.partial(self.value_to_text, "value1", app_data)) self.register_field("value2", 0) self.register_field( "value2_text", functools.partial(self.value_to_text, "value2", app_data)) self.register_field("value3", -1) self.register_field( "value3_text", functools.partial(self.value_to_text, "value3", app_data)) button1 = MPushButton(text="Group 1") button2 = MPushButton(text="Group 2") button3 = MPushButton(text="Group 3") button1.clicked.connect( functools.partial(self.slot_change_value, "value1")) button2.clicked.connect( functools.partial(self.slot_change_value, "value2")) button3.clicked.connect( functools.partial(self.slot_change_value, "value3")) self.bind("value1", radio_group_v, "dayu_checked", signal="sig_checked_changed") self.bind("value2", radio_group_button_h, "dayu_checked", signal="sig_checked_changed") self.bind("value3", radio_group_button_v, "dayu_checked", signal="sig_checked_changed") self.bind("value1_text", button1, "text") self.bind("value2_text", button2, "text") self.bind("value3_text", button3, "text") main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget( MDivider("MRadioButtonGroup: orientation=Qt.Horizontal ")) main_lay.addLayout(radio_grp_1_lay) main_lay.addWidget( MDivider("MRadioButtonGroup: orientation=Qt.Vertical")) main_lay.addWidget(radio_group_v) main_lay.addWidget(button1) main_lay.addWidget( MDivider( "MRadioButtonGroup: orientation=Qt.Horizontal type=button")) main_lay.addLayout(radio_grp_h_lay) main_lay.addWidget(button2) main_lay.addWidget( MDivider( "MRadioButtonGroup: orientation=Qt.Vertical, type=button")) main_lay.addWidget(radio_group_button_v) main_lay.addWidget(button3) main_lay.addStretch() self.setLayout(main_lay)
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)
def _init_ui(self): tool_group_h = MToolButtonGroup(size=dayu_theme.small) tool_group_h.set_button_list( ["Apple", { "text": "Banana" }, { "text": "Pear" }]) tool_1_lay = QtWidgets.QHBoxLayout() tool_1_lay.addWidget(tool_group_h) tool_1_lay.addStretch() app_data = [ { "text": "Maya", "icon": MIcon("app-maya.png"), "checkable": True }, { "text": "Nuke", "icon": MIcon("app-nuke.png"), "checkable": True }, { "text": "Houdini", "icon": MIcon("app-houdini.png"), "checkable": True }, ] tool_group_v = MToolButtonGroup(exclusive=True, size=dayu_theme.small, orientation=QtCore.Qt.Vertical) tool_group_v.set_button_list(app_data) tool_group_button_h = MToolButtonGroup() tool_group_button_h.set_button_list(app_data) tool_2_lay = QtWidgets.QHBoxLayout() tool_2_lay.addWidget(tool_group_button_h) tool_2_lay.addStretch() tool_grp_excl_true = MToolButtonGroup(orientation=QtCore.Qt.Horizontal, exclusive=True) tool_grp_excl_true.set_button_list([ { "svg": "table_view.svg", "checkable": True, "tooltip": "Table View" }, { "svg": "list_view.svg", "checkable": True, "tooltip": "List View" }, { "svg": "tree_view.svg", "checkable": True, "tooltip": "Tree View" }, { "svg": "big_view.svg", "checkable": True, "tooltip": "Big View" }, ]) tool_grp_excl_true.set_dayu_checked(0) tool_excl_lay = QtWidgets.QHBoxLayout() tool_excl_lay.addWidget(tool_grp_excl_true) tool_excl_lay.addStretch() tool_grp_excl_false = MToolButtonGroup( orientation=QtCore.Qt.Horizontal, exclusive=False) tool_grp_excl_false.set_button_list([ { "tooltip": "加粗", "svg": "bold.svg", "checkable": True }, { "tooltip": "倾斜", "svg": "italic.svg", "checkable": True }, { "tooltip": "下划线", "svg": "underline.svg", "checkable": True }, ]) tool_excl_2_lay = QtWidgets.QHBoxLayout() tool_excl_2_lay.addWidget(tool_grp_excl_false) tool_excl_2_lay.addStretch() main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("orientation=Qt.Horizontal ")) main_lay.addLayout(tool_1_lay) main_lay.addWidget(MDivider("orientation=Qt.Vertical")) main_lay.addWidget(tool_group_v) main_lay.addWidget(MDivider("orientation=Qt.Horizontal")) main_lay.addLayout(tool_2_lay) main_lay.addWidget(MDivider("checkable=True; exclusive=True")) main_lay.addLayout(tool_excl_lay) main_lay.addWidget(MDivider("checkable=True; exclusive=False")) main_lay.addLayout(tool_excl_2_lay) main_lay.addStretch() self.setLayout(main_lay)
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 = QtWidgets.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(QtCore.Qt.ElideMiddle) browser_4.sig_file_changed.connect(label_4.setText) browser_5 = MClickBrowserFolderToolButton().huge() label_5 = MLabel() label_5.set_elide_mode(QtCore.Qt.ElideMiddle) browser_5.sig_folder_changed.connect(label_5.setText) lay_2 = QtWidgets.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(QtCore.Qt.ElideMiddle) browser_6.sig_file_changed.connect(label_6.setText) browser_7 = MDragFolderButton() label_7 = MLabel() label_7.set_elide_mode(QtCore.Qt.ElideRight) browser_7.sig_folder_changed.connect(label_7.setText) lay_3 = QtWidgets.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(QtCore.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 = QtWidgets.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)