I was programming with python pyqt5, and I added the code below because I wanted user to customize the toolbar. So I decided to make a dialogue to choose from the functions in the menu bar.
app.py
from dialog.customize_tool import CustomizeTool
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon
...
self.all_tools = {
'프로그램 종료': self.exit_app, '게임 재시작': self.restart_game,
'단어장 선택': self.select_vocab, '최근 단어장': self.recent_vocab,
'툴바 설정': self.customize_tool_bar,
'로그인': self.log_in, '계정 추가': self.add_account,
'개발자 정보': self.show_developer_info, '도움말 보기': self.show_help_info
}
...
def customize_tool_bar(self):
custom = QAction(QIcon('./sys_data/icon/custom.png'), '둘바 설정', self)
custom.triggered.connect(self.get_custom_tools)
custom.setStatusTip('툴바의 구성을 변경합니다.')
custom.setShortcut('Ctrl+T')
return custom
def get_custom_tools(self):
customize_tool = CustomizeTool(self.all_tools, self)
customize_tool.exec_()
self.tool_bar.clear()
for i in customize_tool.user_select:
for k, v in self.all_tools.items():
if i == k:
self.tool_bar.addAction(v())
break
customize_tool.py
from PyQt5.QtWidgets import *
class CustomizeTool(QDialog):
def __init__(self, all_tools: dict, parent):
super(CustomizeTool, self).__init__(parent)
v_box = QVBoxLayout()
v_box.addWidget(self.customize_tool_group())
self.tools = list(all_tools.keys())
self.checkbox = [QCheckBox(i) for i in self.tools]
self.user_select = tuple()
self.setWindowTitle('툴바 설정')
self.resize(200, 200)
self.setLayout(v_box)
self.show()
def customize_tool_group(self):
v_layout = QVBoxLayout()
group_box = QGroupBox('툴바 설정')
save_button = QPushButton('저장')
for j in self.checkbox:
v_layout.addWidget(j)
v_layout.addWidget(save_button)
group_box.setLayout(v_layout)
save_button.clicked.connect(self.submit_checkbox_result())
return group_box
def submit_checkbox_result(self):
self.user_select = tuple(i.text() for i in self.checkbox if i.isChecked())
self.deleteLater()
There is no problem with anything else, but if I just run that function, Process finished with exit code -1073740791 (0xC0000409)
error will occur. Why is that and how should I fix it?
User contributions licensed under CC BY-SA 3.0