Merhabalar, ilginç bir şekilde kapanmayan bir pencerem var. Kodlar aşağıda bulunuyor :
# Needed Libs
from PyQt5.QtWidgets import *
import sys
import random
# Binding
import passwordGen_main
import passwordGen_optionMenu
import warningBox
class warningBox(QWidget, warningBox.Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.close_btn.clicked.connect(self.close_)
def close_(self):
self.close()
# optionMenu
class startWindow(QWidget, passwordGen_optionMenu.Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.continueBtn.clicked.connect(self.transition)
def transition(self):
currentText = self.comboBox_3.currentText()
length = self.lineEdit.text()
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\difficulity.txt","w") as file1:
print(currentText, file=file1, flush=True)
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\length.txt","w") as file2:
print(length, file=file2, flush=True)
self.w = mainWindow()
self.w.show()
self.w.setWindowTitle("Password Generator")
self.close()
# Password Generating Window
class mainWindow(QWidget, passwordGen_main.Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.characters = [
["!","'","^","+","%","&","/","(",")","=","?","_","-","<",">","*",".",",",":",";","q","Q","w","W","k","K","o","O","u","U","l","L","x","X","a","A","b","B","j","J","h","v","V","n","N","e","E","z","Z","0","1","2","3","4","5","6","7","8","9","|","#","£","€","~","$"],
["a","b","c","d","e","f","g","h","i","j","k","l","n","m","o","p","q","r","s","t","u","w","v","y","z","A","B","C","D","E","F","G","H","I","J","K","L","N","M","O","P","Q","R","S","T","U","W","V","Y","Z","x","X","0","1","2","3","4","5","6","7","8","9","_","*","!","/",".","?","=","%","_","_","_","_","<","$"],
["a","b","c","d","e","f","g","h","i","j","k","l","n","m","o","p","q","r","s","t","u","w","v","y","z"]
]
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\difficulity.txt","r") as file1:
difficulity = file1.read()
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\length.txt","r") as file2:
length = file2.read()
if "Difficulity" in difficulity:
self.w = warningBox()
self.close()
self.w.show()
elif "Easy" in difficulity:
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\password.txt",'w') as passwordFile:
count = 0
while count <= int(length):
x = random.choice(self.characters[2])
count += 1
print(x, end="", file=passwordFile, flush=True)
elif "Medium" in difficulity:
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\password.txt",'w') as passwordFile:
count = 0
while count <= int(length):
x = random.choice(self.characters[1])
count += 1
print(x, end="", file=passwordFile, flush=True)
elif "Hard" in difficulity:
with open(r"E:\Yeni klasör (4)\pythonProject5\ozel_projeler\Pro\PracticePython\passwordGen\password.txt",'w') as passwordFile:
count = 0
while count <= int(length):
x = random.choice(self.characters[0])
count += 1
print(x, end="", file=passwordFile, flush=True)
if __name__ == "__main__":
app = QApplication(sys.argv)
startW = startWindow()
startW.setWindowTitle("Password Generator")
startW.show()
sys.exit(app.exec_())
if "Difficulity" in difficulity:
self.close()
self.w = warningBox()
self.w.show()
Sorunun bulunduğu kodlar bunlar.
Bir combobox’umuz bulunuyor ve buradan “Easy”, “Medium”, “Hard” olmak üzere 3 seçenekten biri seçilecek. Fakat olur da kullanıcı combobox’un varsayılan seçeneği (“Difficulity”)ile devam ederse diye hata bildirecek olan bir pencere oluşturdum (warningBox).
Eğer difficulity seçilerekten ilerleme yapılırsa, warningBox show edilsin ve ana pencere kapansın (self.close()
) istiyorum. Fakat ne yaparsam yapayım hiçbir şekilde kapanmıyor. Bunun sebebi ne olabilir acaba ? Yardımcı olur musunuz ?
Eğer bütün dosyalara erişip bizzat kendiniz çalıştırmak isterseniz dosyaları atabilirim.
Şimdiden teşekkürler.