0
我想在这里gui使一个控制台像文本框,并告诉我,如果我有我的文件夹中使用相同的MD5哈希图片。Python的pyqt文件哈希与gui控制台
我真的很困惑,为什么这不适合我。我已经尝试了很多不同的方式来做这件事,而且没有任何事情可以为我工作。
这是我正在使用的代码(当你玩的时候记住你没有错误但不起作用)。
import webbrowser, hashlib, os, sys, time, random, win32api, re , time, subprocess
from PyQt4.QtCore import QSize, QTimer, QRect, pyqtSlot
from PyQt4.QtGui import QApplication,QLineEdit ,QGraphicsRectItem , QMainWindow, QPushButton, QWidget, QIcon, QLabel, QPainter, QPixmap, QMessageBox, QAction, QKeySequence, QFont, QFontMetrics, QMovie
from PyQt4 import QtGui
class UIWindow(QWidget):
def __init__(self, QWidget, parent=None):
super(UIWindow, self).__init__(parent)
self.resize(QSize(400, 450))
self.textbox = QLineEdit('dance',QWidget)
self.textbox.move(20, 300)
self.textbox.resize(280,300)
self.btn = QPushButton('files',self)
self.btn .resize(100, 40)
self.btn .move(260, 400)
def sesh():
for root, dirs,files in os.walk("C:\Users\Matt\Desktop\photos", topdown=True):
for name in files:
#print(os.path.join(root, name))
FileName = (os.path.join(root, name))
hasher = hashlib.md5()
with open(str(FileName), 'rb') as afile:
buf = afile.read()
hasher.update(buf)
if (hasher.hexdigest()) == '653cd1d521d8f343c998e0d568a1e5ea':
self.textbox.setText('file is here')
if (hasher.hexdigest()) == 'd41d8cd98f00b204e9800998ecf8427e':
self.textbox.setText('file is here')
if (hasher.hexdigest()) == '03c7c0ace395d80182db07ae2c30f034':
self.textbox.setText('file is here')
if (hasher.hexdigest()) == '6c0cbf5029aed0af395ac4b864c6b095':
self.textbox.setText('file is here')
else:
self.textbox.setText ("file is NOT here")
def click():
self.textbox.setText('Button clicked.' +str(sesh()))
self.btn .clicked.connect(click)
class MainWindow(QMainWindow,):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setGeometry(50, 50, 1000, 1000)
self.setFixedSize(950, 620)
self.startUIWindow()
self.setWindowIcon(QtGui.QIcon('Images\Logo.png'))
def startUIWindow(self):
self.Window = UIWindow(self)
self.setWindowTitle("pythonw")
self.setCentralWidget(self.Window)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = MainWindow()
sys.exit(app.exec_())
,如果有人能做出这样的工作对我来说这将是惊人的,我会非常感激我只是完全在这一点上失去了。
这并没有解决我的问题,谢谢试图帮助,虽然我仍然没有得到任何东西 – Tyrell
哦,我调整了一件事,现在做的工作有一种方法,你会知道如何打印更多,然后在我的QLineEdit一行,因为一的哈希不在我的文件夹中,它的正义告诉我,其中一个文件在那里,但没有告诉我,其中一个文件不在文件夹 – Tyrell
(1)中,请说明你的调整是完成它 - (2)最简单的方法不是试图让它多行,而是改变你的返回值,使其更具描述性。我将编辑我的答案以提供示例。 – Alan