python-3.x - python中的退出代码-1073740791(0xC0000409)出错
问题描述
所以我试图制作的程序只接受 2018-2050 之间的有效月份和年份,但 pycharm 会显示“进程以退出代码-1073740791(0xC0000409)完成”消息而崩溃,我知道它在哪一行执行此操作,但我不知道如何修复它,这是我正在使用的代码,当单击确定时,错误出现在最后一个 elif 中。正如其他帖子中所建议的那样,我已经尝试重新安装 python 和 pycharm,但没有任何反应。
import sys
from PyQt5.QtWidgets import (QVBoxLayout,QHBoxLayout,QPushButton,
QLineEdit,QApplication,QLabel,QCheckBox,QWidget)
class Window(QWidget):
def __init__(self):
super().__init__()
self.init_ui()
def accepted(month, year):
conf = True
try:
int(month)
int(year)
except ValueError:
conf = False
if conf:
if (int(month) > 12 or int(month) < 1) or (int(year) < 2019 or
int(year) > 2050):
conf = False
return conf
def init_ui(self):
self.btn1=QPushButton('OK')
self.btn2=QPushButton('Clear')
self.btn3=QPushButton('Cancel')
self.txt1=QLabel('Month input')
self.txt2=QLabel('Year Input')
self.b1=QLineEdit()
self.b2=QLineEdit()
h_box1: QHBoxLayout=QHBoxLayout()
h_box1.addWidget(self.txt1)
h_box1.addWidget(self.b1)
h_box2 = QHBoxLayout()
h_box2.addWidget(self.txt2)
h_box2.addWidget(self.b2)
h_box3=QHBoxLayout()
h_box3.addWidget(self.btn1)
h_box3.addWidget(self.btn2)
h_box3.addWidget(self.btn3)
layout=QVBoxLayout()
layout.addLayout(h_box1)
layout.addLayout(h_box2)
layout.addLayout(h_box3)
self.setLayout(layout)
self.setWindowTitle('Calendar Manager')
self.show()
self.btn1.clicked.connect(self.buttons)
self.btn2.clicked.connect(self.buttons)
self.btn3.clicked.connect(self.buttons)
def buttons(self):
clicked=self.sender()
if clicked.text() == 'Clear':
self.b1.clear()
self.b2.clear()
elif clicked.text() == 'Cancel':
sys.exit()
elif clicked.text() == 'OK':
if not accepted(self.b1.text(),self.b2.text()):
self.b1.clear()
self.b2.clear()
else:
pass
app=QApplication(sys.argv)
a_window=Window()
sys.exit(app.exec_())
解决方案
所以问题是 self 在两个实例中,第一个是 def 中的参数接受,其次是 self.accepted 当我调用它时。
推荐阅读
- android - 游戏开始时因未知原因崩溃
- apache-spark - dataset.collectAsList() 导致集群中的 java.lang.ClassCastException
- reactjs - 当 treeselect 具有空值时,它不会显示
- wordpress - 如何制作默认的woocommerce产品标题?
- python-3.x - 如何在 DNA 字符串行中找到 A 的最长现有子字符串并返回长度?
- c++ - 当我尝试进行 TPC-E 测试时,Make 实用程序抱怨“未定义的引用”
- python - 熊猫:从其他数据框中添加具有匹配行索引的列
- java - 在处理中重绘当前像素周围的选定像素区域
- python - django 不显示值形式 db
- python - 在 Python 中使用 os.walk 查找大于 300MB 的文件?