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