Пишу программу по проверке знаний ударений. Файл в интерпретаторе выполняется правильно, но после превращения его в .ехе файл при помощи pyinstaller очень редко, через раз стала выполняться основная функция MakeButton, перестали создаваться кнопки. Скажите пожалуйста, с чем это может быть связано. Заранее спасибо.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QButtonGroup
import sys
from random import randrange
from mnwind import Ui_MainWindow
from emhwind import Ui_EmhWindow
from statwind import Ui_StatWindow
app = QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
EmhWindow = QtWidgets.QMainWindow()
StatWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
emh = Ui_EmhWindow()
st = Ui_StatWindow()
ui.setupUi(MainWindow)
emh.setupUi(EmhWindow)
st.setupUi(StatWindow)
MainWindow.show()
btn_grp = QButtonGroup()
all_count = 0
cor_count = 0
def open_file():
with open('emphasis.txt', encoding='utf-8') as EMH:
rand = randrange(286)
for i in range(rand - 1):
EMH.readline()
word = EMH.readline()
return word
def go_further():
emh.cor_lbl.hide()
emh.incor_lbl.hide()
emh.go_btn.hide()
DeleteButton(emh.word_lay)
word = open_file()
MakeButton(emh.word_lay, word)
emh.go_btn.clicked.connect(go_further)
def n_evernoe(self):
global all_count
all_count += 1
emh.cor_lbl.hide()
emh.incor_lbl.show()
emh.go_btn.show()
btn_grp.button(54).setStyleSheet("border: none;"
"color: green;"
"font-weight: bold;"
"font: 75 20pt")
for x in btn_grp.buttons():
x.setEnabled(False)
def v_ernoe(self):
global all_count
all_count += 1
global cor_count
cor_count += 1
emh.incor_lbl.hide()
emh.cor_lbl.show()
emh.go_btn.show()
btn_grp.button(54).setStyleSheet("border: none;"
"color: green;"
"font-weight: bold;"
"font: 75 20pt")
for x in btn_grp.buttons():
x.setEnabled(False)
def MakeButton(lay, word):
for i in range(len(word)):
btn = QtWidgets.QPushButton('{}'.format(word[i].lower()))
if word[i] in ["А", "У", "Е", "Ы", "О", "Э", "Я", "И", "Ю"]:
btn.setStyleSheet("border: none;"
"color: red;"
"font-weight: bold;"
"font: 75 20pt")
btn.clicked.connect(v_ernoe)
btn_grp.addButton(btn)
btn_grp.setId(btn, 54)
elif word[i] in ["а", "у", "е", "ы", "о", "э", "я", "и", "ю"]:
btn.setStyleSheet("border: none;"
"color: red;"
"font-weight: bold;"
"font: 75 20pt")
btn.clicked.connect(n_evernoe)
btn_grp.addButton(btn)
else:
btn.setStyleSheet("border: none;"
"color: rgb(32, 34, 50);"
"font-weight: bold;"
"font: 75 20pt")
btn_grp.addButton(btn)
lay.addWidget(btn)
def DeleteButton(lay):
for i in reversed(range(lay.count())):
lay.itemAt(i).widget().setParent(None)
def go_emh():
EmhWindow.show()
MainWindow.close()
emh.cor_lbl.hide()
emh.incor_lbl.hide()
emh.go_btn.hide()
word = open_file()
MakeButton(emh.word_lay, word)
ui.start_btn.clicked.connect(go_emh)
def go_stat():
MainWindow.close()
StatWindow.show()
if all_count != 0:
st.all_lbl.setText(str(all_count))
st.corr_lbl.setText(str(cor_count))
proc = round(cor_count / all_count * 100)
st.proc_lbl.setText(str(proc) + '%')
if proc <= 50:
st.mark_lbl.setText('2')
elif proc > 50 and proc < 70:
st.mark_lbl.setText('3')
elif proc >= 70 and proc < 90:
st.mark_lbl.setText('4')
elif proc >= 90:
st.mark_lbl.setText('5')
ui.stats_btn.clicked.connect(go_stat)
def clear_stat():
global all_count
global cor_count
all_count = 0
cor_count = 0
st.all_lbl.setText('')
st.corr_lbl.setText('')
st.proc_lbl.setText('')
st.mark_lbl.setText('')
st.clear_btn.clicked.connect(clear_stat)
def go_main():
if EmhWindow.close():
MainWindow.show()
EmhWindow.close()
DeleteButton(emh.word_lay)
emh.cor_lbl.hide()
emh.incor_lbl.hide()
emh.go_btn.hide()
if StatWindow.close():
StatWindow.close()
MainWindow.show()
emh.ex_btn.clicked.connect(go_main)
st.exi_btn.clicked.connect(go_main)
ui.exit_btn.clicked.connect(sys.exit)
sys.exit(app.exec_())