Пример #1
0
 def mimeData(self, indexes):
     mimedata = QtCore.QMimeData()
     encoded_data = QtCore.QByteArray()
     stream = QtCore.QDataStream(encoded_data, QtCore.QIODevice.WriteOnly)
     for index in indexes:
         if index.isValid():
             text = self.data(index, 0)
     stream << QtCore.QByteArray(text.encode("utf-8"))
     mimedata.setData("application/vnd.treeviewdragdrop.list", encoded_data)
     return mimedata
 def mouseMoveEvent(self, event):
     name = self.label
     drag = QtGui.QDrag(self)
     ba = bytearray(name, "utf-8")
     drag_mime_data = QtCore.QMimeData()
     drag_mime_data.setData(self.QMimeDataType, QtCore.QByteArray(ba))
     drag.setMimeData(drag_mime_data)
     drag.exec_(QtCore.Qt.MoveAction)
Пример #3
0
 def mouseMoveEvent(self, event):
     name = self._label
     print(name)
     drag = QtGui.QDrag(self)
     # ba = bytearray(name, 'utf-8')
     drag_mime_data = QtCore.QMimeData()
     drag_mime_data.setData(self.QMimeDataType, QtCore.QByteArray(name))
     drag.setMimeData(drag_mime_data)
     drag.exec_(QtCore.Qt.MoveAction)
Пример #4
0
def main():
    '''CLI interface'''

    import argparse
    parser = argparse.ArgumentParser(
        prog='UltraSnip',
        description='A desktop snipping tool written in Qt for Python.')
    parser.add_argument(
        '--save',
        '-s',
        type=str,
        help='Path to save capture to for example: output.png',
    )
    parser.add_argument(
        '--measure',
        '-m',
        action='store_true',
        help='Output only the width and height of the region.',
    )
    parser.add_argument(
        '--confirm',
        '-c',
        action='store_true',
        help='Confirm the resulting pixmap using a simple dialog.',
    )

    args = parser.parse_args()

    region = select()
    if args.confirm:
        while not confirm(capture_region(region)):
            region = select(region)

    if region is None:
        sys.exit(1)

    if args.measure:
        print('%sx%s' % (region.width(), region.height()))

    pixmap = capture_region(region)
    if args.save:
        pixmap.save(args.save)
    elif args.measure:
        return
    else:
        from io import BytesIO
        byte_array = QtCore.QByteArray()
        buffer = QtCore.QBuffer(byte_array)
        buffer.open(QtCore.QIODevice.WriteOnly)
        pixmap.save(buffer, 'PNG')
        string_io = BytesIO(byte_array.data())
        string_io.seek(0)
        sys.stdout.buffer.write(string_io.read())
        sys.stdout.flush()

    sys.exit()
Пример #5
0
    def display_gif(self, filepath):
        """delete existing movie and replace with the provided path

        Args:
            filepath (str): of the path
        """
        # Load the file into a QMovie
        if self.movie:
            self.movie.deleteLater()
        self.movie = QtGui.QMovie(filepath, QtCore.QByteArray(), self)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(100)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.show()
Пример #6
0
    def slide_view(self, index, direction="right"):
        if self.currentIndex() == index:
            return

        offset_direction = self.directions.get(direction)
        if offset_direction is None:
            print("BUG: invalid slide direction: {}".format(direction))
            return

        width = self.frameRect().width()
        height = self.frameRect().height()
        offset = QtCore.QPoint(offset_direction.x() * width,
                               offset_direction.y() * height)

        new_page = self.widget(index)
        new_page.setGeometry(0, 0, width, height)
        curr_pos = new_page.pos()
        new_page.move(curr_pos + offset)
        new_page.show()
        new_page.raise_()

        current_page = self.currentWidget()

        b_pos = QtCore.QByteArray(b"pos")

        anim_old = QtCore.QPropertyAnimation(current_page, b_pos, self)
        anim_old.setDuration(250)
        anim_old.setStartValue(curr_pos)
        anim_old.setEndValue(curr_pos - offset)
        anim_old.setEasingCurve(QtCore.QEasingCurve.OutQuad)

        anim_new = QtCore.QPropertyAnimation(new_page, b_pos, self)
        anim_new.setDuration(250)
        anim_new.setStartValue(curr_pos + offset)
        anim_new.setEndValue(curr_pos)
        anim_new.setEasingCurve(QtCore.QEasingCurve.OutQuad)

        anim_group = QtCore.QParallelAnimationGroup(self)
        anim_group.addAnimation(anim_old)
        anim_group.addAnimation(anim_new)

        def slide_finished():
            self.setCurrentWidget(new_page)

        anim_group.finished.connect(slide_finished)
        anim_group.start()
Пример #7
0
    def mimeData(self, indices):
        #print("Generate mime Data - len:"+str(len(indices)),flush=True)
        mimeData      = QtCore.QMimeData()
        encodedData = QtCore.QByteArray()

        if len(indices) != 1:
            return None

        stream = QtCore.QDataStream(encodedData, QtCore.QIODevice.WriteOnly)
        index=indices[0]
        item = index.internalPointer()

        #data=str(id(item))#ukazatel
        data="AHOJ"
        self._dragFrom=index
        mimeData.setData("application/pou.cz", bytes(data, 'utf-8'))
        mimeData.setText(data)
        return mimeData
Пример #8
0
    def dropMimeData(self, data, action, row, column, parent):
        if action == QtCore.Qt.IgnoreAction:
            return True
        if not data.hasFormat("application/vnd.treeviewdragdrop.list"):
            return False
        if column > 0:
            return False

        num_rows = self.rowCount(QtCore.QModelIndex())
        if num_rows <= 0:
            return False

        if row < 0:
            if parent.isValid():
                row = parent.row()
            else:
                return False

        encoded_data = data.data("application/vnd.treeviewdragdrop.list")
        stream = QtCore.QDataStream(encoded_data, QtCore.QIODevice.ReadOnly)

        new_items = []
        rows = 0
        while not stream.atEnd():
            text = QtCore.QByteArray()
            stream >> text
            text = bytes(text).decode("utf-8")
            index = self.nodes.index(text)
            new_items.append((text, index))
            rows += 1

        self.lastDroppedItems = []
        for (text, index) in new_items:
            target_row = row
            if index < row:
                target_row += 1
            self.beginInsertRows(QtCore.QModelIndex(), target_row, target_row)
            self.nodes.insert(target_row, text)
            self.endInsertRows()
            self.lastDroppedItems.append(text)
            row += 1

        self.pendingRemoveRowsAfterDrop = True
        return True
Пример #9
0
    def _download(self, url):
        """Return thumbnail file from *url*.

        Args:
            url (str): The relative url in the form of
                'pictures/thumbnails/{type}/{id}.png'

        """
        full_url = gazu.client.get_full_url(url)
        requests_session = gazu.client.requests_session

        with requests_session.get(full_url,
                                  headers=gazu.client.make_auth_header(),
                                  stream=True) as response:
            bytes = QtCore.QByteArray()
            for chunk in response.iter_content(8192):
                bytes.append(chunk)

            return bytes
Пример #10
0
    def _render_svg(self, svg_path, replace_color=None):
        # Import local modules
        from dayu_widgets import dayu_theme

        replace_color = replace_color or dayu_theme.icon_color
        if (self.cls is QtGui.QIcon) and (replace_color is None):
            return QtGui.QIcon(svg_path)
        with open(svg_path, "r") as f:
            data_content = f.read()
            if replace_color is not None:
                data_content = data_content.replace("#555555", replace_color)
            self._render.load(QtCore.QByteArray(six.b(data_content)))
            pix = QtGui.QPixmap(128, 128)
            pix.fill(QtCore.Qt.transparent)
            painter = QtGui.QPainter(pix)
            self._render.render(painter)
            painter.end()
            if self.cls is QtGui.QPixmap:
                return pix
            else:
                return self.cls(pix)
Пример #11
0
    def _download_icons(self, ids):
        """Return thumbnail for person file from *url*.

        Args:
            url (str): The relative url in the form of
                'pictures/thumbnails/{type}/{id}.png'

        """

        # Create our session
        import requests
        session = requests.Session()
        header = gazu.client.make_auth_header()

        data = {}
        for person_id in ids:

            url = "pictures/thumbnails/persons/{0}.png".format(person_id)
            full_url = gazu.client.get_full_url(url)

            with session.get(full_url, headers=header,
                             stream=True) as response:

                if response.status_code != 200:
                    # Request failed
                    log.error("Failed request: %s" % full_url)
                    continue

                bytes = QtCore.QByteArray()
                for chunk in response.iter_content(8192):
                    bytes.append(chunk)

                if not bytes.isNull():
                    data[person_id] = bytes

        return data
Пример #12
0
    def buildUI(self):

        # menu

        fileNewAction = self.createAction("&New...", self.fileNew,
                                          QtGui.QKeySequence.New, "filenew",
                                          "Create an image file")
        fileOpenAction = self.createAction("&Open...", self.fileNew,
                                           QtGui.QKeySequence.Open, "fileopen",
                                           "Open an existing image file")
        fileSaveAction = self.createAction("&Save", self.fileNew,
                                           QtGui.QKeySequence.Save, "filesave",
                                           "Save the image")
        fileSaveAsAction = self.createAction(
            "Save &As...",
            self.fileNew,
            icon="filesaveas",
            tip="Save the image using a new name")
        filePrintAction = self.createAction("&Print", self.fileNew,
                                            QtGui.QKeySequence.Print,
                                            "fileprint", "Print the image")
        fileQuitAction = self.createAction("&Quit", self.fileNew, "Ctrl+Q",
                                           "filequit", "Close the application")
        editInvertAction = self.createAction("&Invert", self.fileNew, "Ctrl+I",
                                             "editinvert",
                                             "Invert the image's colors", True,
                                             "toggled(bool)")
        editSwapRedAndBlueAction = self.createAction(
            "Sw&ap Red and Blue", self.fileNew, "Ctrl+A", "editswap",
            "Swap the image's red and blue color components", True,
            "toggled(bool)")
        editZoomAction = self.createAction("&Zoom...", self.fileNew, "Alt+Z",
                                           "editzoom", "Zoom the image")
        mirrorGroup = QtWidgets.QActionGroup(self)
        editUnMirrorAction = self.createAction("&Unmirror", self.fileNew,
                                               "Ctrl+U", "editunmirror",
                                               "Unmirror the image", True,
                                               "toggled(bool)")
        mirrorGroup.addAction(editUnMirrorAction)
        editMirrorHorizontalAction = self.createAction(
            "Mirror &Horizontally", self.fileNew, "Ctrl+H", "editmirrorhoriz",
            "Horizontally mirror the image", True, "toggled(bool)")
        mirrorGroup.addAction(editMirrorHorizontalAction)
        editMirrorVerticalAction = self.createAction(
            "Mirror &Vertically", self.fileNew, "Ctrl+V", "editmirrorvert",
            "Vertically mirror the image", True, "toggled(bool)")
        mirrorGroup.addAction(editMirrorVerticalAction)
        editUnMirrorAction.setChecked(True)
        helpAboutAction = self.createAction("&About Image Changer",
                                            self.helpAbout)
        helpHelpAction = self.createAction("&Help", self.helpHelp,
                                           QtGui.QKeySequence.HelpContents)

        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenuActions = (fileNewAction, fileOpenAction, fileSaveAction,
                                fileSaveAsAction, None, filePrintAction,
                                fileQuitAction)
        # self.fileMenu.aboutToShow.connect(self.updateFileMenu)
        editMenu = self.menuBar().addMenu("&Edit")
        self.addActions(
            editMenu,
            (editInvertAction, editSwapRedAndBlueAction, editZoomAction))
        mirrorMenu = editMenu.addMenu(QtGui.QIcon(":/editmirror.png"),
                                      "&Mirror")
        self.addActions(mirrorMenu,
                        (editUnMirrorAction, editMirrorHorizontalAction,
                         editMirrorVerticalAction))
        helpMenu = self.menuBar().addMenu("&Help")
        self.addActions(helpMenu, (helpAboutAction, helpHelpAction))

        fileToolbar = self.addToolBar("File")
        fileToolbar.setObjectName("FileToolBar")
        self.addActions(fileToolbar,
                        (fileNewAction, fileOpenAction, fileSaveAsAction))
        editToolbar = self.addToolBar("Edit")
        editToolbar.setObjectName("EditToolBar")
        self.addActions(
            editToolbar,
            (editInvertAction, editSwapRedAndBlueAction, editUnMirrorAction,
             editMirrorVerticalAction, editMirrorHorizontalAction))
        self.zoomSpinBox = QtWidgets.QSpinBox()
        self.zoomSpinBox.setRange(1, 400)
        self.zoomSpinBox.setSuffix(" %")
        self.zoomSpinBox.setValue(100)
        self.zoomSpinBox.setToolTip("Zoom the image")
        self.zoomSpinBox.setStatusTip(self.zoomSpinBox.toolTip())
        self.zoomSpinBox.setFocusPolicy(QtCore.Qt.NoFocus)
        self.zoomSpinBox.valueChanged[int].connect(self.fileNew)
        editToolbar.addWidget(self.zoomSpinBox)

        self.searchLineEdit = QtWidgets.QLineEdit("Search...")
        self.searchLineEdit.setToolTip("Searching")
        self.searchLineEdit.setMaximumWidth(200)
        self.searchLineEdit.returnPressed.connect(self.populate2)
        editToolbar.addWidget(self.searchLineEdit)

        # self.addActions(self.imageLabel, (editInvertAction,
        #                                   editSwapRedAndBlueAction, editUnMirrorAction,
        #                                   editMirrorVerticalAction, editMirrorHorizontalAction))

        self.resetableActions = ((editInvertAction,
                                  False), (editSwapRedAndBlueAction, False),
                                 (editUnMirrorAction, True))

        settings = QtCore.QSettings("MyCompany", "MyApp")
        self.recentFiles = settings.value("RecentFiles")
        self.restoreGeometry(
            QtCore.QByteArray(settings.value("MainWindow/Geometry")))
        self.restoreState(QtCore.QByteArray(
            settings.value("MainWindow/State")))

        # menu above

        mainSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, self)

        self.tree = QtWidgets.QTreeWidget()
        # tree
        self.tree.setColumnCount(2)
        self.tree.setHeaderLabels([u'分类', ''])

        root = QtWidgets.QTreeWidgetItem(self.tree)
        root.setText(0, u'模型')

        search = "1"
        inputfiled = "pid"
        sql_info = self.sql_back(search, inputfiled)

        for i in sql_info:
            print i[1]
            QtWidgets.QTreeWidgetItem(root, [i[1]], 0)
            name_test = i[1]
            print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<'
            self.sql_dict[name_test] = i[2]
        for k, v in self.sql_dict.items():
            print k, v

        self.tree.addTopLevelItem(root)
        self.tree.clicked.connect(self.on_treeview_clicked3)

        mainSplitter.addWidget(self.tree)

        rightSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical, mainSplitter)
        rightSplitter.setOpaqueResize(False)

        self.listWidget = ThumbListWidget(self)
        self.listWidget2 = ThumbListWidget(self)

        self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(
            self.listItemRightClicked)

        self.listWidget2.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget2.customContextMenuRequested.connect(
            self.listItemRightClicked2)

        self.listWidget2.addfile.connect(self.ref_something)

        rightSplitter.addWidget(self.listWidget)
        rightSplitter.addWidget(self.listWidget2)

        size = 64
        buffer = 12
        self.listWidget.setViewMode(QtWidgets.QListWidget.IconMode)
        self.listWidget.setIconSize(QtCore.QSize(size, size))
        self.listWidget.setResizeMode(QtWidgets.QListWidget.Adjust)
        self.listWidget.setGridSize(QtCore.QSize(size + buffer, size + buffer))
        self.listWidget.setDragEnabled(True)

        self.listWidget2.setIconSize(QtCore.QSize(size, size))
        self.listWidget2.setResizeMode(QtWidgets.QListWidget.Adjust)
        self.listWidget2.setGridSize(QtCore.QSize(size + buffer,
                                                  size + buffer))
        self.listWidget2.setDragEnabled(True)

        mainSplitter.setStretchFactor(1, 20)
        rightSplitter.setStretchFactor(0, 5)

        self.setCentralWidget(mainSplitter)

        #停靠窗口 1
        dock1 = QtWidgets.QDockWidget((u"停靠窗口 1"), self)
        dock1.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable)
        dock1.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea
                              | QtCore.Qt.RightDockWidgetArea)
        te1 = QtWidgets.QTextEdit((u"窗口 1,可在 Main Window 的左部和右部停靠,不可浮动,不可关闭"))
        dock1.setWidget(te1)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock1)

        #停靠窗口 2
        dock2 = QtWidgets.QDockWidget((u"停靠窗口 2"), self)
        dock2.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable
                          | QtWidgets.QDockWidget.DockWidgetClosable)
        # dock2.setTitleBarWidget()
        te2 = QtWidgets.QTextEdit((u"窗口 2,只可浮动"))
        dock2.setWidget(te2)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock2)

        #停靠窗口 2
        dock4 = QtWidgets.QDockWidget((u"停靠窗口 4"), self)
        dock4.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable
                          | QtWidgets.QDockWidget.DockWidgetClosable)
        te4 = QtWidgets.QTextEdit((u"窗口 4,只可浮动"))
        dock4.setWidget(te4)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock4)

        #停靠窗口 3
        # dock3=QtWidgets.QDockWidget((u"停靠窗口 3"),self)
        # dock3.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
        # te3=QtWidgets.QTextEdit((u"窗口 3,可在 Main Window 任意位置停靠,可浮动,可关闭"))
        # dock3.setWidget(te3)
        # self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,dock3)

        #dock1 和dock4 合并
        self.tabifyDockWidget(dock1, dock4)
Пример #13
0
    def buildUI(self):

        self.sizeLabel = QtWidgets.QLabel()
        self.sizeLabel.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Sunken)
        status = self.statusBar()
        status.setSizeGripEnabled(False)
        status.addPermanentWidget(self.sizeLabel)
        status.showMessage("Ready", 5000)

        # menu

        fileNewAction = self.createAction("&New...", self.fileNew,
                                          QtGui.QKeySequence.New, "filenew", "Create an image file")
        fileOpenAction = self.createAction("&Open...", self.fileNew,
                                           QtGui.QKeySequence.Open, "fileopen",
                                           "Open an existing image file")
        fileSaveAction = self.createAction("&Save", self.fileNew,
                                           QtGui.QKeySequence.Save, "filesave", "Save the image")
        fileSaveAsAction = self.createAction("Save &As...",
                                             self.fileNew, icon="filesaveas",
                                             tip="Save the image using a new name")
        filePrintAction = self.createAction("&Print", self.fileNew,
                                            QtGui.QKeySequence.Print, "fileprint", "Print the image")
        fileQuitAction = self.createAction("&Quit", self.fileNew,
                                           "Ctrl+Q", "filequit", "Close the application")
        editInvertAction = self.createAction("&Invert",
                                             self.fileNew, "Ctrl+I", "editinvert",
                                             "Invert the image's colors", True, "toggled(bool)")
        editSwapRedAndBlueAction = self.createAction(
            "Sw&ap Red and Blue", self.fileNew,
            "Ctrl+A", "editswap",
            "Swap the image's red and blue color components",
            True, "toggled(bool)")
        editZoomAction = self.createAction("&Zoom...", self.fileNew,
                                           "Alt+Z", "editzoom", "Zoom the image")
        mirrorGroup = QtWidgets.QActionGroup(self)
        editUnMirrorAction = self.createAction("&Unmirror",
                                               self.setSizeMid, "Ctrl+U", "editunmirror",
                                               "Unmirror the image", True, "toggled(bool)")
        mirrorGroup.addAction(editUnMirrorAction)
        editMirrorHorizontalAction = self.createAction(
            "Mirror &Horizontally", self.setSizeBig,
            "Ctrl+H", "editmirrorhoriz",
            "Horizontally mirror the image", True, "toggled(bool)")
        mirrorGroup.addAction(editMirrorHorizontalAction)
        editMirrorVerticalAction = self.createAction(
            "Mirror &Vertically", self.setSizeSmall,
            "Ctrl+V", "editmirrorvert",
            "Vertically mirror the image", True, "toggled(bool)")
        mirrorGroup.addAction(editMirrorVerticalAction)
        editUnMirrorAction.setChecked(True)
        helpAboutAction = self.createAction("&About Image Changer",
                                            self.helpAbout)
        helpHelpAction = self.createAction("&Help", self.helpHelp,
                                           QtGui.QKeySequence.HelpContents)

        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenuActions = (fileNewAction, fileOpenAction,
                                fileSaveAction, fileSaveAsAction, None,
                                filePrintAction, fileQuitAction)
        # self.fileMenu.aboutToShow.connect(self.updateFileMenu)
        editMenu = self.menuBar().addMenu("&Edit")
        self.addActions(editMenu, (editInvertAction,
                                   editSwapRedAndBlueAction, editZoomAction))
        mirrorMenu = editMenu.addMenu(QtGui.QIcon(":/editmirror.png"),
                                      "&Mirror")
        self.addActions(mirrorMenu, (editUnMirrorAction,
                                     editMirrorHorizontalAction, editMirrorVerticalAction))
        helpMenu = self.menuBar().addMenu("&Help")
        self.addActions(helpMenu, (helpAboutAction, helpHelpAction))

        fileToolbar = self.addToolBar("File")
        fileToolbar.setObjectName("FileToolBar")
        self.addActions(fileToolbar, (fileNewAction, fileOpenAction,
                                      fileSaveAsAction))
        editToolbar = self.addToolBar("Edit")
        editToolbar.setObjectName("EditToolBar")
        self.addActions(editToolbar, (editInvertAction,
                                      editSwapRedAndBlueAction, editUnMirrorAction,
                                      editMirrorVerticalAction,
                                      editMirrorHorizontalAction))
        self.zoomSpinBox = QtWidgets.QSpinBox()
        self.zoomSpinBox.setRange(1, 400)
        self.zoomSpinBox.setSuffix(" %")
        self.zoomSpinBox.setValue(100)
        self.zoomSpinBox.setToolTip("Zoom the image")
        self.zoomSpinBox.setStatusTip(self.zoomSpinBox.toolTip())
        self.zoomSpinBox.setFocusPolicy(QtCore.Qt.NoFocus)
        self.zoomSpinBox.valueChanged[int].connect(self.setPicSize)
        editToolbar.addWidget(self.zoomSpinBox)

        self.searchLineEdit = QtWidgets.QLineEdit()
        self.searchLineEdit.setPlaceholderText(u"搜索...")
        self.searchLineEdit.setToolTip("Searching")
        self.searchLineEdit.setMaximumWidth(200)
        self.searchLineEdit.returnPressed.connect(self.populate2)
        editToolbar.addWidget(self.searchLineEdit)

        # self.addActions(self.imageLabel, (editInvertAction,
        #                                   editSwapRedAndBlueAction, editUnMirrorAction,
        #                                   editMirrorVerticalAction, editMirrorHorizontalAction))

        self.resetableActions = ((editInvertAction, False),
                                 (editSwapRedAndBlueAction, False),
                                 (editUnMirrorAction, True))

        settings = QtCore.QSettings("MyCompany", "MyApp")
        self.recentFiles = settings.value("RecentFiles")
        self.restoreGeometry(
            QtCore.QByteArray(settings.value("MainWindow/Geometry")))
        self.restoreState(QtCore.QByteArray(settings.value("MainWindow/State")))

        # menu above

        mainSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, self)

        self.tree = QtWidgets.QTreeWidget()
        # tree
        self.tree.setColumnCount(2)
        self.tree.setHeaderLabels([u'分类', ''])

        root = QtWidgets.QTreeWidgetItem(self.tree)
        root.setText(0, u'模型')

        # ---------------layer1_list

        layer1_list = []

        search = "1"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                print i, "<<<<<<<<<<<<<<sql_info1"
                # print i[1]
                layre1_item = QtWidgets.QTreeWidgetItem(root, [i[1]], 0)
                layer1_list.append(layre1_item)
                name_test = i[1]
                # print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<'
                self.sql_dict[name_test] = i[2]
        except:
            pass
        print len(layer1_list),"<<<layer1_list"

        # ----------

        layer2_list = []

        #
        search = "2"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # print i[1]
                # 角色
                layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[0], [i[1]], 0)
                layer2_list.append(layre2_item)
                name_test = i[1]
                # print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<'
                self.sql_dict[name_test] = i[2]
        except:
            pass
        #
        search = "3"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # 道具
                layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[1], [i[1]], 0)
                layer2_list.append(layre2_item)
                name_test = i[1]
                self.sql_dict[name_test] = i[2]
        except:
            pass

        #
        search = "4"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # 场景
                layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[2], [i[1]], 0)
                layer2_list.append(layre2_item)
                name_test = i[1]
                self.sql_dict[name_test] = i[2]
        except:
            pass

        #
        search = "7"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # 动物
                layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[1], [i[1]], 0)
                # layer2_list.append(layre2_item)
                name_test = i[1]
                self.sql_dict[name_test] = i[2]
        except:
            pass
        #
        search = "9"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # 城市
                layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[3], [i[1]], 0)
                # layer2_list.append(layre2_item)
                name_test = i[1]
                self.sql_dict[name_test] = i[2]
        except:
            pass

        #
        search = "10"
        inputfiled = "pid"
        try:
            sql_info = self.sql_back(search, inputfiled)
        except:
            print 'Error<<<<<<<<<<<<<<'
            print "cant get information"
            sql_info = None
        # (i['pid'], i['name'], i['id'], i['description'])
        try:

            for i in sql_info:
                # 自然 layer2_list[4]
                layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[4], [i[1]], 0)
                # layer2_list.append(layre2_item)
                name_test = i[1]
                self.sql_dict[name_test] = i[2]
        except:
            pass



        # ------------------

        self.tree.addTopLevelItem(root)
        self.tree.clicked.connect(self.on_treeview_clicked3)

        self.tree.setItemsExpandable(True)

        mainSplitter.addWidget(self.tree)

        rightSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical, mainSplitter)
        rightSplitter.setOpaqueResize(False)

        self.listWidget = ThumbListWidget(self)
        self.listWidget2 = ThumbListWidget(self)

        self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget.customContextMenuRequested.connect(self.listItemRightClicked)
        self.listWidget.itemDoubleClicked.connect(self.openImage)

        self.listWidget2.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.listWidget2.customContextMenuRequested.connect(self.listItemRightClicked2)

        self.listWidget2.addfile.connect(self.ref_something)

        rightSplitter.addWidget(self.listWidget)
        rightSplitter.addWidget(self.listWidget2)

        size = 128
        buffer = 12
        self.listWidget.setViewMode(QtWidgets.QListWidget.IconMode)
        self.listWidget.setIconSize(QtCore.QSize(size, size))
        self.listWidget.setResizeMode(QtWidgets.QListWidget.Adjust)
        self.listWidget.setGridSize(QtCore.QSize(size + buffer, size + buffer))
        self.listWidget.setDragEnabled(True)
        self.listWidget.itemClicked .connect(self.info_populate)

        self.listWidget2.setIconSize(QtCore.QSize(size, size))
        self.listWidget2.setResizeMode(QtWidgets.QListWidget.Adjust)
        self.listWidget2.setGridSize(QtCore.QSize(size + buffer, size + buffer))
        self.listWidget2.setDragEnabled(True)

        mainSplitter.setStretchFactor(1, 20)
        rightSplitter.setStretchFactor(0, 5)

        self.setCentralWidget(mainSplitter)

        # 停靠窗口 1
        dock4=QtWidgets.QDockWidget((u"上传"),self)
        dock4.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
        # dock4.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea)
        te1=upload.UpLoad()
        dock4.setWidget(te1)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,dock4)

        # 停靠窗口 4
        dock1=QtWidgets.QDockWidget((u"详细信息"),self)
        dock1.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable)
        dock1.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea)
        self.info_label = QtWidgets.QLabel((u"NULL"))
        dock1.setWidget(self.info_label)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock1)

        # 停靠窗口 2
        dock2=QtWidgets.QDockWidget((u"截图"),self)
        dock2.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
        # dock2.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable|QtWidgets.QDockWidget.DockWidgetClosable)
        # dock2.setTitleBarWidget()
        # te2=controllerLibraryte.showUI()
        # te2=QtWidgets.QTextEdit()
        te2 = screenshots.Screenshot()
        dock2.setWidget(te2)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,dock2)

        # 停靠窗口 3
        # dock3=QtWidgets.QDockWidget((u"停靠窗口 3"),self)
        # dock3.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
        # te3=QtWidgets.QTextEdit((u"窗口 3,可在 Main Window 任意位置停靠,可浮动,可关闭"))
        # dock3.setWidget(te3)
        # self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,dock3)

        # dock4 和dock1 合并
        self.tabifyDockWidget(dock4, dock1)