• 大小: 8KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Python
  • 标签: pyqt5  python2  python3  

资源简介

python2,3下都能运行,看到界面选一个文件夹,文件夹下包括一个文件夹,且其下有图片,代码不易,好好珍惜!

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
import sys
import os
import math
import sip
from PyQt5 import QtCoreQtGuiQtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class face(QWidget):
    end_clicked=pyqtSignal()
    def __init__(self parent=None):
        super(face self).__init__(parent)
        self._width=1200
        self._height=1000
        self.posite()
        self.resize(self._width self._height)
        self.move(2060)
        self.showMaximized()
        #设置界面的大小
        self.end_clicked.connect(self.end_Tip)
        self.base_path=os.path.join(os.getcwd()‘..‘)
        self.ColNum=self._width/200
        self.RowNum=(self._height*0.9)/100

        wwg=QWidget(self)
        self.flag=““
        self.Face_layout = QHBoxLayout(wwg)
        self.v_1=QVBoxLayout()
        self.v_2=QVBoxLayout()
       # layout.addStretch(1)
       #  fram=QVBoxLayout()

        self.listW = MyListWs(self)
        self.listW.setobjectName(“listW“)
        # self.listW.listW_itemSelected.connect(self.listW_itemSelected)

        
        self.moveListWidget = MyListWs(self)      
        self.moveListWidget.setobjectName(“moveListWidget“)


        w1=QWidget()
        self.v_1.addWidget(self.listW)


        self.h1=QHBoxLayout()
        self.btn = QPushButton(“选择图片文件夹“)
        self.btn.clicked.connect(self.readfile)
        # self.btn.click()
        
        self.h1.addWidget(self.btn)
        self.check=QPushButton(“确认选择“)
        self.check.clicked.connect(self.isOk)
        self.h1.addWidget(self.check)

        # self.moveListWidget.itemClicked.connect(lambda item:item.imgpath)

        self.v_2.addWidget(self.moveListWidget)
        w1.setLayout(self.h1)
        self.v_1.addWidget(w1)
        self.Face_layout.addLayout(self.v_1)
        self.Face_layout.addLayout((self.v_2))
        #layout.addLayout(fram_1stretch=2)

        self.setLayout(self.Face_layout)
        self.setWindowtitle(“图片拖拽“)
    def posite(self):
        screen=QDesktopWidget().screenGeometry()
        self._width=screen.width()-50
        self._height=screen.height()-100

        print(screen.width()screen.height())
    def readfile(self):
        directory = QFileDialog.getExistingDirectory(self  “选取文件夹“  “./“)
        # directory = “./acrop“
        
        img_dir=os.listdir(directory)
        if len(img_dir)>0:
            images_dir = os.listdir(os.path.join(directory img_dir[0]))
            images_num = len(images_dir)
           
            img_paths = list()
            for id_img in images_dir:
                img_paths.append(os.path.join(directory img_dir[0] id_img))

            for k in range(images_num):

                imgpath = img_paths[k]
                self.listW.createItem(imgpath)
                QApplication.processEvents()
        else:
            self.end_clicked.emit()



         
    def end_Tip(self):
      

评论

共有 条评论