为什么按钮不连接?

时间:2019-11-15 06:31:16

标签: python-3.x sqlite pyqt5 qpushbutton

当我关闭窗口时,按钮不连接 我要在第一次关闭时打开窗口 但是按钮无法连接

是test.py

import sys
import sqlite3
from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QMainWindow
from easter import Ui_Form
from window_3 import App_2
class App(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Test")
        self.show()

    def closeEvent(self, event):
        Example().__init__()



class Example(QMainWindow, Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        # It is don't working
        self.buttonGroup.buttonClicked.connect(self.add)
        self.show()

    def add(self, sender):
        # It doesn't matter 
        con = sqlite3.connect("top.db")
        cur = con.cursor()
        idd = list(cur.execute("select id from Top").fetchall())
        a = cur.execute('update top set score = ? where id = ?', (int(sender.text()), idd[-1][0]))
        con.commit()

        App_2().__init__()
        self.close()

0 个答案:

没有答案