### Using LabelExample Widget Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Demonstrates the basic application setup required to run a dayu_widgets example like LabelExample. It initializes a Qt application, creates the example widget, applies the custom Dayu theme, and displays the widget. Requires dayu_widgets.dayu_theme and dayu_widgets.qt.application. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = LabelExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running Dayu Widgets Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt This snippet demonstrates the basic application setup using `dayu_widgets.qt.application`. It initializes a specific widget (e.g., MenuExample), applies the global Dayu theme using `dayu_theme.apply()`, and shows the main widget window. This context manager ensures proper application lifecycle management. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = MenuExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running PushButtonExample Application (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Demonstrates the basic application setup using `dayu_widgets.qt.application` to run and display the `PushButtonExample` widget with the dayu theme applied. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = PushButtonExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing Page Example Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Sets up and runs a basic PyQt application to display the PageExample widget, applying the dayu_widgets theme. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = PageExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running ProgressCircleExample Application (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Demonstrates the basic application setup using `dayu_widgets.qt.application` to run and display the `ProgressCircleExample` widget with the dayu theme applied. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ProgressCircleExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running PushButtonGroupExample Application (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Demonstrates the basic application setup using `dayu_widgets.qt.application` to run and display the `PushButtonGroupExample` widget with the dayu theme applied. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = PushButtonGroupExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running ThemeExample Application Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Provides the standard entry point code for running the `ThemeExample` example. It initializes the Qt application using a context manager, creates an instance of the example widget, applies the `dayu_theme`, and displays the widget. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ThemeExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Using ToolButton Example Widget in Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example showing the basic instantiation and display of the ToolButtonExample widget. It demonstrates the typical pattern for running a Dayu Widgets example: importing necessary modules, creating a QApplication instance, initializing the widget, applying the Dayu theme, and showing the widget. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ToolButtonExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing ItemViewSetExample UI Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Initializes various MItemViewSet types (Table, List, Tree, Big, Searchable Tree) and configures their headers. It sets up buttons for search/expand/collapse and refresh, arranges them in a QVBoxLayout with dividers, and prepares data binding and initial data setup. Requires dayu_widgets.MItemViewSet, dayu_widgets.MPushButton, dayu_widgets.MDivider, and QtWidgets. ```Python item_view_set_table = MItemViewSet(view_type=MItemViewSet.TableViewType) item_view_set_table.set_header_list(mock.header_list) item_view_set_list = MItemViewSet(view_type=MItemViewSet.ListViewType) item_view_set_list.set_header_list(mock.header_list) item_view_set_tree = MItemViewSet(view_type=MItemViewSet.TreeViewType) item_view_set_tree.set_header_list(mock.header_list) item_view_set_thumbnail = MItemViewSet(view_type=MItemViewSet.BigViewType) item_view_set_thumbnail.set_header_list(mock.header_list) item_view_set_search = MItemViewSet(view_type=MItemViewSet.TreeViewType) item_view_set_search.set_header_list(mock.header_list) item_view_set_search.searchable() expand_button = MPushButton("Expand All") expand_button.clicked.connect(item_view_set_search.item_view.expandAll) coll_button = MPushButton("Collapse All") coll_button.clicked.connect(item_view_set_search.item_view.collapseAll) item_view_set_search.insert_widget(coll_button) item_view_set_search.insert_widget(expand_button) refresh_button = MPushButton("Refresh Data") refresh_button.clicked.connect(self.slot_update_data) main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("Table View")) main_lay.addWidget(refresh_button) main_lay.addWidget(item_view_set_table) main_lay.addWidget(MDivider("List View")) main_lay.addWidget(item_view_set_list) main_lay.addWidget(MDivider("Tree View")) main_lay.addWidget(item_view_set_tree) main_lay.addWidget(MDivider("Big View")) main_lay.addWidget(item_view_set_thumbnail) main_lay.addWidget(MDivider("With Search line edit")) main_lay.addWidget(item_view_set_search) main_lay.addStretch() self.setLayout(main_lay) item_view_set_tree.setup_data(mock.tree_data_list) item_view_set_search.setup_data(mock.tree_data_list) self.view_list = [ item_view_set_table, item_view_set_list, item_view_set_thumbnail, ] self.bind( "item_view_set_example_header_state", item_view_set_table.item_view.header_view, "state", ) self.slot_update_data() ``` -------------------------------- ### Running TableViewExample Application Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Shows the standard boilerplate for running a `dayu_widgets` example application using the `dayu_widgets.qt.application` context manager. It initializes the QApplication, creates an instance of `TableViewExample`, applies the `dayu_theme`, and shows the main window. ```python # Import local modules from dayu_widgets.qt import application with application() as app: test = TableViewExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing Message Example Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Sets up and runs a basic PyQt application to display the MessageExample widget, applying the dayu_widgets theme. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = MessageExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running MTabWidgetTest Application Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Provides the standard entry point code for running the `MTabWidgetTest` example. It initializes the Qt application using a context manager, creates an instance of the example widget, applies the `dayu_theme`, and displays the widget. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = MTabWidgetTest() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing MenuTabWidget Example Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Sets up and runs a basic PyQt application to display the MenuTabWidgetExample, applying the dayu_widgets theme for consistent styling. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = MenuTabWidgetExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Using ToolButtonGroup Example Widget in Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example showing the basic instantiation and display of the ToolButtonGroupExample widget. It follows the typical pattern for running a Dayu Widgets example: importing necessary modules, creating a QApplication instance, initializing the widget, applying the Dayu theme, and showing the widget. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ToolButtonGroupExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running TextEditExample Application Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Provides the standard entry point code for running the `TextEditExample` example. It initializes the Qt application using a context manager, creates an instance of the example widget, applies the `dayu_theme`, and displays the widget. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = TextEditExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Running ListViewExample Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Initializes a Qt application context using dayu_widgets.qt.application, creates an instance of the ListViewExample widget, applies the dayu_theme for styling, and displays the main window. This is a typical entry point for dayu_widgets example applications. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ListViewExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Run dayu_widgets Examples via Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/README.md This command runs the example program for dayu_widgets directly as a Python module. It requires a Qt environment (like PySide2 or PyQt5) to be already installed in your Python environment. ```Shell python -m dayu_widgets ``` -------------------------------- ### Initializing SequenceFileExample UI Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt This snippet illustrates the UI setup for the `SequenceFileExample` widget. It includes adding a `MDragFileButton` to allow file selection or drag-and-drop, setting file filters, connecting a signal for file changes, and integrating a `MSequenceFile` widget into the layout. ```python browser = MDragFileButton(text="Click or drag files") browser.set_dayu_filters([".py", "pyc", ".jpg", ".mov", "exr"]) browser.sig_file_changed.connect(self.slot_add_file) self.sequence_file_1 = MSequenceFile() main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("different size")) main_lay.addWidget(browser) main_lay.addWidget(self.sequence_file_1) main_lay.addStretch() self.setLayout(main_lay) @QtCore.Slot(str) ``` -------------------------------- ### Running LoadingExample Application - Python (Partial) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Begins the initialization of a Qt application context using dayu_widgets.qt.application and creates an instance of the LoadingExample widget. It sets up the basic structure for applying the theme and showing the widget, although the snippet is incomplete. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = LoadingExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Install dayu_widgets Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/README.md This command installs the dayu_widgets library using pip, the standard package installer for Python. This is the primary method to get the library into your Python environment. ```Shell pip install dayu_widgets ``` -------------------------------- ### Initializing ToolButton Example UI in Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for a ToolButtonExample widget. It demonstrates various features of MToolButton, including different sizes, enabling/disabling, checkable state, icon-only display, and text-beside-icon display, arranging them using QVBoxLayout and QHBoxLayout. ```Python size_lay = QtWidgets.QVBoxLayout() sub_lay1 = QtWidgets.QHBoxLayout() sub_lay1.addWidget(MToolButton().svg("left_line.svg").icon_only().huge()) sub_lay1.addWidget(MToolButton().svg("right_line.svg").icon_only().large()) sub_lay1.addWidget(MToolButton().svg("up_line.svg").icon_only()) sub_lay1.addWidget(MToolButton().svg("up_line.svg").icon_only().small()) sub_lay1.addWidget(MToolButton().svg("down_line.svg").icon_only().tiny()) custom_size = MToolButton().svg("left_line.svg").icon_only() custom_size.set_dayu_size(200) custom_size.setToolTip("Custom Size 200") sub_lay1.addStretch() size_lay.addLayout(sub_lay1) size_lay.addWidget(custom_size) button2 = MToolButton().svg("detail_line.svg").icon_only() button2.setEnabled(False) button7 = MToolButton().svg("bold.svg").icon_only() button7.setCheckable(True) state_lay = QtWidgets.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 = QtWidgets.QHBoxLayout() button_lay.addWidget(button_trash) button_lay.addWidget(button_login) main_lay = QtWidgets.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) ``` -------------------------------- ### Running LineTabWidgetExample Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Initializes a Qt application context using dayu_widgets.qt.application, creates an instance of the LineTabWidgetExample widget, applies the dayu_theme for styling, and displays the main window. Follows the standard pattern for dayu_widgets examples. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = LineTabWidgetExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing Toast Example UI in Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for a ToastExample widget, demonstrating different message types (normal, success, warning, error, loading) using MPushButton and MToast widgets from the dayu_widgets library. It arranges buttons using QHBoxLayout and QVBoxLayout. ```Python 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, MToast.info, {"text": "好像没啥用"}) ) button4.clicked.connect( functools.partial(self.slot_show_message, MToast.success, {"text": "领取成功"}) ) button5.clicked.connect( functools.partial(self.slot_show_message, MToast.warning, {"text": "暂不支持"}) ) button6.clicked.connect( functools.partial( self.slot_show_message, MToast.error, {"text": "支付失败,请重试"} ) ) sub_lay1 = QtWidgets.QHBoxLayout() sub_lay1.addWidget(button3) sub_lay1.addWidget(button4) sub_lay1.addWidget(button5) sub_lay1.addWidget(button6) loading_button = MPushButton("Loading Toast").primary() loading_button.clicked.connect(self.slot_show_loading) main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(MDivider("different type")) main_lay.addLayout(sub_lay1) main_lay.addWidget(MLabel("不同的提示状态:成功、失败、加载中。默认2秒后消失")) main_lay.addWidget(loading_button) main_lay.addStretch() self.setLayout(main_lay) ``` -------------------------------- ### Running LineEditExample Application - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Initializes a Qt application context using dayu_widgets.qt.application, creates an instance of the LineEditExample widget, applies the dayu_theme for styling, and displays the main window. This is a typical entry point for dayu_widgets example applications. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = LineEditExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Using ComboBoxExample Widget Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Sets up a QApplication and displays the ComboBoxExample widget from the dayu_widgets library, applying the default dayu_theme. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = ComboBoxExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Using SpinBoxExample Widget Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt This snippet shows how to run the `SpinBoxExample` widget from the `dayu_widgets` library by initializing a Qt application, applying the theme, and showing the example widget. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = SpinBoxExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Installing dayu_widgets with pip (Shell) Source: https://github.com/phenom-films/dayu_widgets/blob/master/docs/README.md This command installs the dayu_widgets PySide UI library using the Python package installer, pip. It downloads and installs the library and its dependencies from PyPI. Requires a Python environment with pip installed. ```shell pip install dayu_widgets ``` -------------------------------- ### Initializing ComboBoxExample UI Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for ComboBoxExample widget. It demonstrates creating MComboBox widgets with different sizes and data sources (using MMenu), and binding their values to fields. ```Python cities = ["北京", "上海", "广州", "深圳"] self.register_field("button1_selected", "北京") menu1 = MMenu(parent=self) menu1.set_data(cities) size_list = [ ("Large", dayu_theme.large), ("Medium", dayu_theme.medium), ("Small", dayu_theme.small), ] size_lay = QtWidgets.QHBoxLayout() for label, size in size_list: combo_box = MComboBox() combo_box.set_dayu_size(size) combo_box.set_menu(menu1) size_lay.addWidget(combo_box) self.bind( "button1_selected", combo_box, "value", signal="sig_value_changed" ) self.register_field("button2_selected", ["北京"]) menu2 = MMenu(exclusive=False, parent=self) menu2.set_data(cities) select2 = MComboBox() select2.set_menu(menu2) self.bind("button2_selected", select2, "value", signal="sig_value_changed") ``` -------------------------------- ### Initializing ToolButtonGroup Example UI in Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for a ToolButtonGroupExample widget. It demonstrates creating MToolButtonGroup instances with different configurations, including horizontal and vertical orientation, exclusive and non-exclusive selection modes, adding buttons via lists of dictionaries, and arranging them using QVBoxLayout and QHBoxLayout. ```Python 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) ``` -------------------------------- ### Using SplitterExample Widget Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt This snippet demonstrates the basic usage of the `SplitterExample` widget, showing how to import the necessary application context and display the example widget. ```python # Import local modules from dayu_widgets.qt import application with application() as app: test = SplitterExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing ProgressBarExample UI (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure various types of `MProgressBar` widgets, including standard, success, error, and auto-coloring versions, and arrange them in different layouts within a `ProgressBarExample` widget. ```python progress_1 = MProgressBar() progress_1.setValue(10) progress_1.setAlignment(QtCore.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 = QtWidgets.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 = QtCore.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 = QtWidgets.QVBoxLayout() auto_color_lay.addWidget(run_button) auto_color_lay.addWidget(self.auto_color_progress) main_lay = QtWidgets.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) ``` -------------------------------- ### Initializing LabelExample UI Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Configures the UI for LabelExample by adding various MLabel instances showcasing different text levels (h1-h4), types (normal, secondary, warning, danger), attributes (mark, code, underline, delete, strong, mixed), elide modes (Left, Middle, Right), and hyperlink capabilities. It also includes a data binding example and arranges all elements using various Qt layout managers and MDivider. Requires dayu_widgets.MLabel, dayu_widgets.MPushButton, dayu_widgets.MDivider, QtCore.Qt, and QtWidgets. ```Python title_lay = QtWidgets.QGridLayout() title_lay.addWidget(MLabel("一级标题").h1(), 0, 0) title_lay.addWidget(MLabel("二级标题").h2(), 1, 0) title_lay.addWidget(MLabel("三级标题").h3(), 2, 0) title_lay.addWidget(MLabel("四级标题").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 = QtWidgets.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 = QtWidgets.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 = QtWidgets.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 = QtWidgets.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 = QtWidgets.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(QtCore.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(QtCore.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(QtCore.Qt.ElideRight) lay_elide.addWidget(label_none) lay_elide.addWidget(label_left) lay_elide.addWidget(label_middle) lay_elide.addWidget(label_right) hyper_label_1 = MLabel() hyper_label_1.set_link("https://baidu.com", text="baidu") hyper_label_2 = MLabel() hyper_label_2.set_link("https://baidu.com") hyper_label_3 = MLabel() hyper_label_3.set_link( "https://github.com/phenom-films/dayu_widgets", text="Dayu Widgets" ) hyperlink_lay = QtWidgets.QVBoxLayout() hyperlink_lay.addWidget(hyper_label_1) hyperlink_lay.addWidget(hyper_label_2) hyperlink_lay.addWidget(hyper_label_3) # hyperlink_lay.addWidget() main_lay = QtWidgets.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.addWidget(MDivider("hyperlink")) main_lay.addLayout(hyperlink_lay) main_lay.addStretch() self.setLayout(main_lay) ``` -------------------------------- ### Install Project Dependencies with poetry Source: https://github.com/phenom-films/dayu_widgets/blob/master/README.md After cloning the repository and installing Poetry, this command installs all project dependencies specified in the poetry.lock or pyproject.toml file into the project's virtual environment. ```Shell poetry install ``` -------------------------------- ### Configuring Page Example UI - Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Defines the UI layout for the PageExample, creating multiple MPage widgets with different total counts and connecting a signal from one page widget. ```Python page_1 = MPage() page_1.set_total(255) page_1.sig_page_changed.connect(print) page_2 = MPage() page_2.set_total(100) main_lay = QtWidgets.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() ``` -------------------------------- ### Initializing MSwitch Widgets Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Demonstrates the initialization of multiple MSwitch widgets, setting their checked state and enabled state, and arranging them in horizontal and form layouts with dividers. Shows how to apply different predefined sizes to MSwitch widgets. ```python check_box_1 = MSwitch() check_box_1.setChecked(True) check_box_2 = MSwitch() check_box_3 = MSwitch() check_box_3.setEnabled(False) lay = QtWidgets.QHBoxLayout() lay.addWidget(check_box_1) lay.addWidget(check_box_2) lay.addWidget(check_box_3) size_lay = QtWidgets.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 = QtWidgets.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) ``` -------------------------------- ### Using MPushButtonDelegate Widget Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Sets up a QApplication and displays the DelegateButtonExample widget from the dayu_widgets library, applying the default dayu_theme. ```Python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = DelegateButtonExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing CollapseExample UI Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for CollapseExample widget. It demonstrates creating labels with multi-language text, enabling word wrap, creating a list of sections with titles, expand status, and widgets, and adding them to an MCollapse widget within a QVBoxLayout. ```Python label_1 = MLabel( "史蒂夫·乔布斯(Steve Jobs),1955年2月24日生于美国加利福尼亚州旧金山,美国发明家、企业家、美国苹果公司联合创办人。" ) label_2 = MLabel( "斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。" ) label_3 = MLabel( "乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。" ) label_1.setWordWrap(True) label_2.setWordWrap(True) label_3.setWordWrap(True) section_list = [ {"title": "史蒂夫乔布斯", "expand": True, "widget": label_1}, { "title": "可关闭的", "expand": True, "widget": MLabel("This is a closable collapse item"), "closable": True, }, {"title": "斯蒂夫·盖瑞·沃兹尼亚克", "expand": True, "widget": label_2}, ] section_group = MCollapse() section_group.add_section_list(section_list) main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(section_group) main_lay.addStretch() self.setLayout(main_lay) ``` -------------------------------- ### Using SequenceFileExample Widget Python Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt This snippet provides an example of how to instantiate and display the `SequenceFileExample` widget from the `dayu_widgets` library within a standard Qt application environment. ```python # Import local modules from dayu_widgets import dayu_theme from dayu_widgets.qt import application with application() as app: test = SequenceFileExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Initializing ProgressCircleExample UI (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure various types of `MProgressCircle` widgets, including standard, dashboard style, different sizes, data-bound, and custom content, arranging them in different layouts within a `ProgressCircleExample` widget. ```python main_lay = QtWidgets.QVBoxLayout() self.setLayout(main_lay) main_lay.addWidget(MDivider("circle")) lay1 = QtWidgets.QHBoxLayout() circle_1 = MProgressCircle(parent=self) circle_1.setFormat("%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("%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 = QtWidgets.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")) scale_x, _ = get_scale_factor() circle_4 = MProgressCircle(parent=self) circle_4.set_dayu_width(100 * scale_x) circle_4.setValue(40) circle_5 = MProgressCircle(parent=self) circle_5.setValue(40) circle_6 = MProgressCircle(parent=self) circle_6.set_dayu_width(160 * scale_x) circle_6.setValue(40) lay2 = QtWidgets.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 = QtWidgets.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 = QtWidgets.QWidget() custom_layout = QtWidgets.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="消费人群规模").secondary() lab3 = MLabel(text="总占人数 75%").secondary() lab1.setAlignment(QtCore.Qt.AlignCenter) lab2.setAlignment(QtCore.Qt.AlignCenter) lab3.setAlignment(QtCore.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 * scale_x) custom_circle.setValue(75) custom_circle.set_widget(custom_widget) main_lay.addWidget(MDivider("custom circle")) main_lay.addWidget(custom_circle) main_lay.addStretch() ``` -------------------------------- ### Initializing MPushButtonDelegate UI Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure the UI for MPushButtonDelegate widget. It demonstrates setting up an MTableView with MTableModel and MSortFilterModel, applying an MPushButtonDelegate to a specific column, and connecting a signal for button clicks. ```Python model_1 = MTableModel() model_1.set_header_list(header_list) model_sort = MSortFilterModel() model_sort.setSourceModel(model_1) table_grid = MTableView(size=dayu_theme.small, show_row_count=True) table_grid.setShowGrid(True) table_grid.setModel(model_sort) model_sort.set_header_list(header_list) table_grid.set_header_list(header_list) button_delegate = MPushButtonDelegate(parent=self) table_grid.setItemDelegateForColumn(4, button_delegate) button_delegate.sig_clicked.connect(self.slot_cell_clicked) model_1.set_data_list( [ { "name": "John Brown", "sex": "Male", "sex_list": ["Male", "Female"], "age": 18, "score": 89, "city": "New York", "city_list": ["New York", "Ottawa", "London", "Sydney"], "date": "2016-10-03", }, { "name": "Jim Green", "sex": "Male", "sex_list": ["Male", "Female"], "age": 24, "score": 55, "city": "London", "city_list": ["New York", "Ottawa", "London", "Sydney"], "date": "2016-10-01", }, ] ) main_lay = QtWidgets.QVBoxLayout() main_lay.addWidget(table_grid) self.setLayout(main_lay) ``` -------------------------------- ### Initializing PushButtonGroupExample UI (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Example of how to initialize and configure horizontal and vertical `MPushButtonGroup` widgets with different button types, icons, and sizes, arranging them in layouts within a `PushButtonGroupExample` widget. ```python 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) ``` -------------------------------- ### Running Dayu Widgets Application (Python) Source: https://github.com/phenom-films/dayu_widgets/blob/master/llms.txt Initializes and runs a PyQt application using the dayu_widgets application context manager. It creates the main widget, applies the dayu_theme, and displays the widget. ```Python with application() as app: test = TreeViewExample() dayu_theme.apply(test) test.show() ``` -------------------------------- ### Run dayu_widgets Examples via uvx Source: https://github.com/phenom-films/dayu_widgets/blob/master/README.md This command runs the example program using the uvx command-line tool. It's the recommended way as uvx can automatically handle and set up the necessary Python version and Qt dependencies (specified by --with pyside2). ```Shell uvx --python 3.10 --with pyside2 dayu_widgets ```