Beispiel #1
0
    def _init_ui(self):
        self.text_edit = QTextEdit()
        self.stacked_widget = QStackedWidget()

        list_widget = MItemViewSet(view_type=MItemViewSet.ListViewType)
        list_widget.set_header_list([{
            'key': 'name',
            'label': 'Name',
            'icon': 'list_view.svg'
        }])
        list_widget.sig_left_clicked.connect(self.slot_change_widget)
        data_list = []
        for index, (name, cls, code) in enumerate(get_test_widget()):
            data_list.append({'name': name[:-8], 'data': code})
            widget = cls()
            widget.setProperty('code', code)
            self.stacked_widget.addWidget(widget)
        list_widget.setup_data(data_list)

        test_widget = MDockWidget('Example List')
        test_widget.setWidget(list_widget)
        self.addDockWidget(Qt.LeftDockWidgetArea, test_widget)

        code_widget = MDockWidget('Example Code')
        code_widget.setWidget(self.text_edit)
        self.addDockWidget(Qt.RightDockWidgetArea, code_widget)
        self.setCentralWidget(self.stacked_widget)
Beispiel #2
0
class MDemo(QMainWindow):
    def __init__(self, parent=None):
        super(MDemo, self).__init__(parent)
        self.setWindowTitle('Dayu Widgets Demo')
        self._init_ui()

    def _init_ui(self):
        self.text_edit = QTextEdit()
        self.stacked_widget = QStackedWidget()

        list_widget = MItemViewSet(view_type=MItemViewSet.ListViewType)
        list_widget.set_header_list([{
            'key': 'name',
            'label': 'Name',
            'icon': 'list_view.svg'
        }])
        list_widget.sig_left_clicked.connect(self.slot_change_widget)
        data_list = []
        for index, (name, cls, code) in enumerate(get_test_widget()):
            data_list.append({'name': name[:-8], 'data': code})
            widget = cls()
            widget.setProperty('code', code)
            self.stacked_widget.addWidget(widget)
        list_widget.setup_data(data_list)

        test_widget = MDockWidget('Example List')
        test_widget.setWidget(list_widget)
        self.addDockWidget(Qt.LeftDockWidgetArea, test_widget)

        code_widget = MDockWidget('Example Code')
        code_widget.setWidget(self.text_edit)
        self.addDockWidget(Qt.RightDockWidgetArea, code_widget)
        self.setCentralWidget(self.stacked_widget)

    def slot_change_widget(self, index):
        self.stacked_widget.setCurrentIndex(index.row())
        widget = self.stacked_widget.widget(index.row())
        self.text_edit.setPlainText(''.join(widget.property('code')))
 def _slot_show_detail(self):
     dialog = QTextEdit(self)
     dialog.setReadOnly(True)
     geo = QApplication.desktop().screenGeometry()
     dialog.setGeometry(geo.width() / 2,
                        geo.height() / 2,
                        geo.width() / 4,
                        geo.height() / 4)
     dialog.setWindowTitle(self.tr('Error Detail Information'))
     dialog.setText(self.property('history'))
     dialog.setWindowFlags(Qt.Dialog)
     dialog.show()