hey i have this code
when starting the Process to make database it freeze at all what should i do?

# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
import sys
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(400, 300)
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "memo md5 crypter", None, QtGui.QApplication.UnicodeUTF8))
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(50, 20, 321, 71))
        self.label.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:26pt; font-weight:600;\">memo md5 cracker</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setObjectName(_fromUtf8("label"))
        self.md5hash = QtGui.QLineEdit(Dialog)
        self.md5hash.setGeometry(QtCore.QRect(70, 100, 291, 27))
        self.md5hash.setObjectName(_fromUtf8("md5hash"))
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(30, 100, 41, 17))
        self.label_2.setText(QtGui.QApplication.translate("Dialog", "md5:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.progress = QtGui.QProgressBar(Dialog)
        self.progress.setGeometry(QtCore.QRect(20, 260, 361, 23))
        self.progress.setProperty("value", 0)
        self.progress.setObjectName(_fromUtf8("progress"))
        self.generate = QtGui.QPushButton(Dialog)
        self.generate.setGeometry(QtCore.QRect(20, 210, 151, 27))
        self.generate.setText(QtGui.QApplication.translate("Dialog", "generate data base", None, QtGui.QApplication.UnicodeUTF8))
        self.generate.setObjectName(_fromUtf8("generate"))
        self.check = QtGui.QPushButton(Dialog)
        self.check.setGeometry(QtCore.QRect(180, 210, 97, 27))
        self.check.setText(QtGui.QApplication.translate("Dialog", "check hash", None, QtGui.QApplication.UnicodeUTF8))
        self.check.setObjectName(_fromUtf8("check"))
        self.quit = QtGui.QPushButton(Dialog)
        self.quit.setGeometry(QtCore.QRect(290, 210, 97, 27))
        self.quit.setText(QtGui.QApplication.translate("Dialog", "Quit", None, QtGui.QApplication.UnicodeUTF8))
        self.quit.setObjectName(_fromUtf8("quit"))
        self.label_3 = QtGui.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(30, 140, 67, 17))
        self.label_3.setText(QtGui.QApplication.translate("Dialog", "statue:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.statue = QtGui.QLabel(Dialog)
        self.statue.setGeometry(QtCore.QRect(80, 135, 301, 31))
        self.statue.setText(QtGui.QApplication.translate("Dialog", "idle", None, QtGui.QApplication.UnicodeUTF8))
        self.statue.setObjectName(_fromUtf8("statue"))

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.quit, QtCore.SIGNAL(_fromUtf8("clicked()")), Dialog.close)
        QtCore.QObject.connect(self.generate, QtCore.SIGNAL(_fromUtf8("clicked()")), self.generatefun)
        QtCore.QObject.connect(self.check, QtCore.SIGNAL(_fromUtf8("clicked()")), self.checkfun)


        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        pass
    def generatefun(self):
        import anydbm
        import string
        import hashlib
        from itertools import product
        from multiprocessing import Process
        t1=Process(name="t1", target=self.g1)
        t1.start()
        t1.join()
        t2=Process(name="t2", target=self.g2)
        t2.start()
        t2.join()
    def g1(self):
    import hashlib
    from itertools import product
    import anydbm
    import string
        str=string.printable
        x1=1
        md1=hashlib.md5()
        db1=anydbm.open("md1.dat", "c")
        while x1<100:
            iter1=product(str, repeat=x1)
            for i1 in iter1:
                ij1="".join(i1)
                md1.update(ij1)
                db1[md1.hexdigest()]=ij1
            self.changepro(x1)
            x1=x1+1
        db1.close()
        self.changepro(0)
    def g2(self):
    import hashlib
    from itertools import product
    import anydbm
    import string
        str=string.printable
        x2=100
        md2=hashlib.md5()
        db2=anydbm.open("md2.dat", "c")
        while x2<200:
            iter2=product(str, repeat=x2)
            for i2 in iter2:
                ij2="".join(i2)
                md2.update(ij2)
                md2.update(ij2)
                db2[md2.hexdigest()]=ij2
            self.changepro(x2-100)
            x2=x2+1
            self.changepro(0)
        db2.close()
    def checker(self, md5input):
    import hashlib
    from itertools import product
    import anydbm
        try:
            db1=anydbm.open("md1.dat", "r")
        except IOError:
            self.changeresult("data base 1 not found!")
        try:
            db2=anydbm.open("md2.dat", "r")
        except IOError:
            self.changeresult("data base 2 not found") 

        if db1[md5input]:
            self.changeresult(db1[md5input])
            db1.close()
            db2.close()
        elif db2[md5input]:
            self.changeresult(db2[md5input])
            db1.close()
            db2.close()
        else:
            self.changeresult("hash not found in the data base")
            db1.close()
            db2.close()
    def checkfun(self):
    from multiprocessing import Process
        c1=Process(name="c1", target=self.checker)
        c1.start()

    def changeresult(self, texthere):
        self.statue.setText(QtGui.QApplication.translate("Dialog", texthere, None, QtGui.QApplication.UnicodeUTF8))
    def changepro(self, value):
        self.progress.setProperty("value", int(value))

app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())

Put all your import statements at the start of the code. Repeatedly importing within functions is inefficient and can lead to errors.

hmmm will that stop freezing the program?
i mean is there any errors in the code except the importing issue??

Hard to say, because the problem could be in one of your data files.

hmm like what? is the prolblem with Qt it self? should i use another stuff like wx or gtk? the problem that i searched alot and i couldn't find a solution i guess it becuase the threading andi don't know what to use Process from multiprocessing or threading because i don't know what the different between them and i'v updated my code here it is "sorry for long code but i want to type it all to know where the problem is :|"
and am using Eric ide on ubuntu and i get this error

(process:16046): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.

is this causing the problem? or should i start a new thread for it ? sorry for asking too much
i use ubuntu 11.10 locale EN_US utf-8

# -*- coding: utf-8 -*-
import anydbm
import string
import hashlib
from itertools import product
from multiprocessing import Process
from PyQt4 import QtCore, QtGui
import sys
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(400, 300)
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "memo md5 crypter", None, QtGui.QApplication.UnicodeUTF8))
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(50, 20, 321, 71))
        self.label.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:26pt; font-weight:600;\">memo md5 cracker</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setObjectName(_fromUtf8("label"))
        self.md5hash = QtGui.QLineEdit(Dialog)
        self.md5hash.setGeometry(QtCore.QRect(70, 100, 291, 27))
        self.md5hash.setObjectName(_fromUtf8("md5hash"))
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(30, 100, 41, 17))
        self.label_2.setText(QtGui.QApplication.translate("Dialog", "md5:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.progress = QtGui.QProgressBar(Dialog)
        self.progress.setGeometry(QtCore.QRect(20, 260, 361, 23))
        self.progress.setProperty("value", 0)
        self.progress.setObjectName(_fromUtf8("progress"))
        self.generate = QtGui.QPushButton(Dialog)
        self.generate.setGeometry(QtCore.QRect(20, 210, 151, 27))
        self.generate.setText(QtGui.QApplication.translate("Dialog", "generate data base", None, QtGui.QApplication.UnicodeUTF8))
        self.generate.setObjectName(_fromUtf8("generate"))
        self.check = QtGui.QPushButton(Dialog)
        self.check.setGeometry(QtCore.QRect(180, 210, 97, 27))
        self.check.setText(QtGui.QApplication.translate("Dialog", "check hash", None, QtGui.QApplication.UnicodeUTF8))
        self.check.setObjectName(_fromUtf8("check"))
        self.quit = QtGui.QPushButton(Dialog)
        self.quit.setGeometry(QtCore.QRect(290, 210, 97, 27))
        self.quit.setText(QtGui.QApplication.translate("Dialog", "Quit", None, QtGui.QApplication.UnicodeUTF8))
        self.quit.setObjectName(_fromUtf8("quit"))
        self.label_3 = QtGui.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(30, 140, 67, 17))
        self.label_3.setText(QtGui.QApplication.translate("Dialog", "statue:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.statue = QtGui.QLabel(Dialog)
        self.statue.setGeometry(QtCore.QRect(80, 135, 301, 31))
        self.statue.setText(QtGui.QApplication.translate("Dialog", "idle", None, QtGui.QApplication.UnicodeUTF8))
        self.statue.setObjectName(_fromUtf8("statue"))

        QtCore.QObject.connect(self.quit, QtCore.SIGNAL(_fromUtf8("clicked()")), Dialog.close)
        QtCore.QObject.connect(self.generate, QtCore.SIGNAL(_fromUtf8("clicked()")), self.generatefun)
        QtCore.QObject.connect(self.check, QtCore.SIGNAL(_fromUtf8("clicked()")), self.checkfun)


        QtCore.QMetaObject.connectSlotsByName(Dialog)


    def generatefun(self):

        t1=Process(name="t1", target=self.g1)
        t1.start()
        t1.join()
        t2=Process(name="t2", target=self.g2)
        t2.start()
        t2.join()
    def g1(self):

        str=string.printable
        x1=1
        md1=hashlib.md5()
        db1=anydbm.open("md1.dat", "n")
        while x1<100:
            iter1=product(str, repeat=x1)
            for i1 in iter1:
                ij1="".join(i1)
                md1.update(ij1)
                db1[md1.hexdigest()]=ij1
            self.changepro(x1)
            x1=x1+1
        db1.close()
        self.changepro(0)
    def g2(self):

        str=string.printable
        x2=100
        md2=hashlib.md5()
        db2=anydbm.open("md2.dat", "n")
        while x2<200:
            iter2=product(str, repeat=x2)
            for i2 in iter2:
                ij2="".join(i2)
                md2.update(ij2)
                md2.update(ij2)
                db2[md2.hexdigest()]=ij2
            self.changepro(x2-100)
            x2=x2+1
            self.changepro(0)
        db2.close()
    def checker(self, md5input):

        try:
            db1=anydbm.open("md1.dat" )
        except :
            self.changeresult("data base 1 not found!")
            db1=anydbm.open("md1.dat", "n")
        try:
            db2=anydbm.open("md2.dat")
        except :
            self.changeresult("data base 2 not found")
            db2=anydbm.open("md2.dat", "n")           


        if db1.has_key(md5input):
            self.changeresult(db1[md5input])
            db1.close()
            db2.close()
        elif db2.has_key(md5input):
            self.changeresult(db2[md5input])
            db1.close()
            db2.close()
        else:
            self.changeresult("hash not found in the data base")
            db1.close()
            db2.close()
    def checkfun(self):
        c1=Process(name="c1", target=self.checker(str(self.md5hash.text())))
        c1.start()
        c1.join()
    def changeresult(self, texthere):
        self.statue.setText(QtGui.QApplication.translate("Dialog", texthere, None, QtGui.QApplication.UnicodeUTF8))
    def changepro(self, value):
        self.progress.setProperty("value", int(value))

app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())

hey i have updated my code it still freezzes but i have thus error now
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
Segmentation fault

# -*- coding: utf-8 -*-
import dbm
import string
import hashlib
from itertools import product
from multiprocessing import Process
from threading import Thread
from PyQt4 import QtCore, QtGui
import time
import sys
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(400, 300)
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "memo md5 crypter", None, QtGui.QApplication.UnicodeUTF8))
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(50, 20, 321, 71))
        self.label.setText(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:26pt; font-weight:600;\">memo md5 cracker</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setObjectName(_fromUtf8("label"))
        self.md5hash = QtGui.QLineEdit(Dialog)
        self.md5hash.setGeometry(QtCore.QRect(70, 100, 291, 27))
        self.md5hash.setObjectName(_fromUtf8("md5hash"))
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(30, 100, 41, 17))
        self.label_2.setText(QtGui.QApplication.translate("Dialog", "md5:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.progress = QtGui.QProgressBar(Dialog)
        self.progress.setGeometry(QtCore.QRect(20, 260, 361, 23))
        self.progress.setProperty("value", 0)
        self.progress.setObjectName(_fromUtf8("progress"))
        self.generate = QtGui.QPushButton(Dialog)
        self.generate.setGeometry(QtCore.QRect(20, 210, 151, 27))
        self.generate.setText(QtGui.QApplication.translate("Dialog", "generate data base", None, QtGui.QApplication.UnicodeUTF8))
        self.generate.setObjectName(_fromUtf8("generate"))
        self.check = QtGui.QPushButton(Dialog)
        self.check.setGeometry(QtCore.QRect(180, 210, 97, 27))
        self.check.setText(QtGui.QApplication.translate("Dialog", "check hash", None, QtGui.QApplication.UnicodeUTF8))
        self.check.setObjectName(_fromUtf8("check"))
        self.quit = QtGui.QPushButton(Dialog)
        self.quit.setGeometry(QtCore.QRect(290, 210, 97, 27))
        self.quit.setText(QtGui.QApplication.translate("Dialog", "Quit", None, QtGui.QApplication.UnicodeUTF8))
        self.quit.setObjectName(_fromUtf8("quit"))
        self.label_3 = QtGui.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(30, 140, 67, 17))
        self.label_3.setText(QtGui.QApplication.translate("Dialog", "statue:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.statue = QtGui.QLabel(Dialog)
        self.statue.setGeometry(QtCore.QRect(80, 135, 301, 31))
        self.statue.setText(QtGui.QApplication.translate("Dialog", "idle", None, QtGui.QApplication.UnicodeUTF8))
        self.statue.setObjectName(_fromUtf8("statue"))

        QtCore.QObject.connect(self.quit, QtCore.SIGNAL(_fromUtf8("clicked()")), Dialog.close)
        QtCore.QObject.connect(self.generate, QtCore.SIGNAL(_fromUtf8("clicked()")), self.generatefun)
        QtCore.QObject.connect(self.check, QtCore.SIGNAL(_fromUtf8("clicked()")), self.checkfun)


        QtCore.QMetaObject.connectSlotsByName(Dialog)


    def generatefun(self):

        t1=Thread(target=self.g1)
        t1.start()
        t1.join()

        time.sleep(1)
    def g1(self):

        strj=string.printable

        x1=1
        md1=hashlib.md5()
        db1=dbm.open("md1", "n")
        while x1<=200:
            iter1=product(strj, repeat=x1)
            for i1 in iter1:
                ij1="".join(i1)
                md1.update(ij1)


                mdhex=md1.hexdigest()
                db1[mdhex]=ij1
            self.changepro(x1/2)
            time.sleep(10)

            x1=x1+1
        db1.close()
        self.changepro(0)

    def checker(self, md5input):

        try:
            db1=dbm.open("md1" )
        except :
            self.changeresult("data base 1 not found!")
            db1=dbm.open("md1", "n")


        if db1.has_key(md5input):
            time.sleep(1.5)
            self.changeresult(db1[md5input])
            db1.close()

        else:
            self.changeresult("hash not found in the data base")
            db1.close()
    def checkfun(self):
        c1=Process(name="c1", target=self.checker(str(self.md5hash.text())))
        c1.start()
        c1.join()
    def changeresult(self, texthere):
        self.statue.setText(QtGui.QApplication.translate("Dialog", texthere, None, QtGui.QApplication.UnicodeUTF8))
    def changepro(self, value):
        self.progress.setProperty("value", int(value))

app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)

Dialog.show()
sys.exit(app.exec_())

`

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.