LineEdit盒信号

时间:2019-04-11 17:53:13

标签: python-3.x sqlite pyqt5

我正在尝试在Python 3.6中使用SQlite3和PyQt5创建一个小型数据库。 通过在LineEditSearch框中键入一个单词并按Enter键,程序将显示该单词,然后应将其置于保留状态,否则不执行该操作,方法是执行click_Edit()函数。为什么?我不明白为什么!

在同一程序中,还有其他可以正常工作的lineEdit框

#!/usr/bin/python3.6
# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton,
     QDialog, QGroupBox, QHBoxLayout, QVBoxLayout, QLabel,
     QDial, QSpinBox, QGridLayout, QLabel, QRadioButton,
     QCheckBox, QWidget, QLineEdit, QSizeGrip, QFrame, QSplitter,
     QSlider, QFormLayout, QScrollArea, QLCDNumber, QProgressBar,
     QToolBox, QTabWidget, QDialogButtonBox, QComboBox,
     QListWidget, QDoubleSpinBox, QMessageBox, QInputDialog,
     QTableWidget, QTableWidgetItem

from PyQt5 import QtGui  
from PyQt5 import QtCore  
import sqlite3

global Cognome,Nome,Data,Ora,Fuso,Località,Long,Lat,Professione


class Window(QMainWindow):

    def __init__(self):
        super().__init__()
        title = "SQlite3 embeded in QTableWidget"
        left=100;top=100;width=1200;height=800;iconName="amiga.png"
        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(iconName))
        self.setGeometry(left,top,width,height)
        self.CreaPulsanteDatabase()
        self.show()

    def CreaPulsanteDatabase(self):
        button = QPushButton("Database", self)
        button.setGeometry(QtCore.QRect(30,100,200,80))
        button.setIcon(QtGui.QIcon("sbirulo.png"))
        button.setIconSize(QtCore.QSize(70,70))
        button.clicked.connect(self.Database)

    def Database(self):
        self.d = DialogDatabase()
        self.d.Crea_FinestraDatabase()
        self.d.Crea_Oggetti()
        self.d.Crea_TableWidget_Persone()
        self.d.Crea_Layout()
        self.d.Apri_Database_Persone()
        self.d.LoadDatabase_Persone()


class DialogDatabase(QDialog):

    def Crea_FinestraDatabase(self):
        title = "Database";left=600;top=360;width=1200;height=700
        iconName="database.png"
        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(iconName))
        self.setGeometry(left,top,width,height)
        self.setStyleSheet('background-color:lightyellow')
        self.show()

    def closeEvent(self,event):
        pass


    def Apri_Database_Persone(self):
        global conn,curs
        conn = sqlite3.connect('Persone.db')
        curs = conn.cursor()
        curs.execute('CREATE TABLE IF NOT EXISTS Persone (Cognome TEXT, Nome TEXT, Data TEXT, Ora TEXT, Fuso TEXT, Località TEXT, Long TEXT, Lat TEXT, Professione TEXT)')

    def LoadDatabase_Persone(self):
        global conn,curs
        while (table.rowCount() > 0):
            table.removeRow(0)
        res = curs.execute('SELECT * FROM Persone')
        for row_index, row_data in enumerate(res):
            table.insertRow(row_index)
            for colm_index, colm_data in enumerate(row_data):
                table.setItem(row_index, colm_index, QTableWidgetItem(str(colm_data)))
        return

    def click_Persone(self):                    # Database Persone
        pass

    def click_Nazioni(self):                    # Database Nazioni
        pass

    def click_Borsa(self):                      # Database Borsa
        pass

    def click_CoordGeo(self):                   # Database CoordGeo (Coordinate Geografiche)
        pass

    def Crea_TableWidget_Persone(self):
        global table
        table = QTableWidget(self)
        table.setRowCount(200)
        table.setColumnCount(9)
        table.setColumnWidth(8,170)
        table.setColumnWidth(7,70)
        table.setColumnWidth(6,70)
        table.setColumnWidth(5,170)
        table.setColumnWidth(4,50)
        table.setColumnWidth(3,60)
        table.setColumnWidth(2,100)
        table.setColumnWidth(1,170)
        table.setColumnWidth(0,170)
        table.setStyleSheet("background-color:rgb(189,255,189)")
        table.setHorizontalHeaderLabels(["Cognome","Nome","Data","Ora","Fuso","Località","Long","Lat","Professione"])
        table.setSortingEnabled(1)
        table.horizontalHeader().sectionClicked.connect(self.Sort_Header_Persone)

    def Sort_Header_Persone(self):
        curs.execute('DELETE FROM Persone')
        allRows = table.rowCount()
        for row in range(0,allRows):
            TabCognome=table.item(row,0);TabNome=table.item(row,1);TabData=table.item(row,2);TabOra=table.item(row,3);TabFuso=table.item(row,4); \
            TabLocalità=table.item(row,5);TabLong=table.item(row,6);TabLat=table.item(row,7);TabProfessione=table.item(row,8)
            curs.execute('INSERT INTO Persone VALUES(?,?,?,?,?,?,?,?,?)', \
                     (TabCognome.text(),TabNome.text(),TabData.text(),TabOra.text(),TabFuso.text(),TabLocalità.text(),TabLong.text(),TabLat.text(),TabProfessione.text()))
        conn.commit()


    def Crea_Layout(self):

        hbox1 = QHBoxLayout()           # hbox1: Box1 orizzontale dei Pulsanti Edit, Delete e Add
        hbox1.addStretch(1)
        hbox1.addWidget(self.btnEdit)
        hbox1.addWidget(self.btnDelete)
        hbox1.addWidget(self.btnAdd)

        hbox2 = QHBoxLayout()           # hbox2: Box2 orizzontale dei Pulsanti Persone, Nazioni, Borsa e CoordGeo
        hbox2.addWidget(self.btnPersone)
        hbox2.addWidget(self.btnNazioni)
        hbox2.addWidget(self.btnBorsa)
        hbox2.addWidget(self.btnCoordGeo)

        hbox3 = QHBoxLayout()           # hbox3: Box3 orizzontale del LabelSearch e LineEdit
        hbox3.addWidget(self.labelSearch)
        hbox3.addWidget(self.lineEditSearch)

        groupbox = QGroupBox()
        vbox1 = QVBoxLayout()           # groupbox: Box1 verticale di LabelDatabase, hbox2 e groupbox
        vbox1.addWidget(self.labelDatabase)
        vbox1.addLayout(hbox2)
        groupbox.setLayout(vbox1)

        vbox2 = QVBoxLayout()           # vbox2: Box2 verticale di hbox1 e hbox3
        vbox2.addLayout(hbox1)
        vbox2.addLayout(hbox3)

        hbox4 = QHBoxLayout()           # hbox4: Box4 orizzontale di groupbox e vbox2
        hbox4.addWidget(groupbox)
        hbox4.addLayout(vbox2)

        vbox3 = QVBoxLayout()           # vbox3: Box3 verticale di hbox4 e TableWidget
        vbox3.addLayout(hbox4)
        vbox3.addWidget(self.label0)
        vbox3.addWidget(table)

        vbox4 = QVBoxLayout()           # vbox4: Box4 verticale dei Pulsanti ChartUp e ChartDown e Chart
        vbox4.addStretch(6)
        vbox4.addWidget(self.btnChartUp)
        vbox4.addWidget(self.btnChartDown)
        vbox4.addWidget(self.btnChart)
        vbox4.addStretch(1)

        hbox5 = QHBoxLayout()           # hbox5: Box5 orizzontale di vbox3 e vbox4
        hbox5.addLayout(vbox3)
        hbox5.addLayout(vbox4)

        self.setLayout(hbox5)


    def click_Edit(self):
        res = curs.execute('SELECT * FROM Persone')
        for row in enumerate(res):
            if row[0] == table.currentRow():
                dati = row[1]
                global Cognome,Nome,Data,Ora,Fuso,Località,Long,Lat,Professione
                Cognome=dati[0];Nome=dati[1];Data=dati[2];Ora=dati[3];Fuso=dati[4];Località=dati[5];Long=dati[6];Lat=dati[7];Professione=dati[8]
        self.de = Edit_Persone()
        self.de.Crea_FinestraEditPersone()
        self.de.Crea_OggettieLayoutEditPersone()

    def click_Delete(self):
        res = curs.execute('SELECT * FROM Persone')
        for row in enumerate(res):
            if row[0] == table.currentRow():
                dati = row[1]
                global Cognome,Nome,Data,Ora,Fuso,Località,Long,Lat,Professione
                Cognome=dati[0];Nome=dati[1];Data=dati[2];Ora=dati[3];Fuso=dati[4];Località=dati[5];Long=dati[6];Lat=dati[7];Professione=dati[8]
        self.de = Delete_Persone()
        self.de.Crea_FinestraDeletePersone()
        self.de.Crea_OggettieLayoutDeletePersone()

    def click_Add(self):
        self.a = Add_Persone()
        self.a.Crea_FinestraAddPersone()
        self.a.Crea_OggettieLayoutAddPersone()

    def click_Chart(self):
        pass

    def click_ChartUp(self):
        pass

    def click_ChartDown(self):
        pass

    def Crea_Oggetti(self):
        self.btnEdit = QPushButton("Edit",self)          # Pulsante Edit
        self.btnEdit.clicked.connect(self.click_Edit)
        self.btnDelete = QPushButton("Delete",self)      # Pulsante Delete
        self.btnDelete.clicked.connect(self.click_Delete)
        self.btnAdd = QPushButton("Add",self)            # Pulsante Add
        self.btnAdd.clicked.connect(self.click_Add)
        self.btnPersone = QPushButton("Persone",self)    # Pulsante Persone
        self.btnPersone.setStyleSheet("background-color:rgb(189,255,189)")
        self.btnPersone.clicked.connect(self.click_Persone)
        self.btnNazioni = QPushButton("Nazioni",self)    # Pulsante Nazioni
        self.btnNazioni.setStyleSheet("background-color:rgb(255,230,255)")
        self.btnNazioni.clicked.connect(self.click_Nazioni)
        self.btnBorsa = QPushButton("Borsa",self)        # Pulsante Borsa
        self.btnBorsa.setStyleSheet("background-color:rgb(204,255,255)")
        self.btnBorsa.clicked.connect(self.click_Borsa)
        self.btnCoordGeo = QPushButton("CoordGeo",self)  # Pulsante CoordGeo
        self.btnCoordGeo.setStyleSheet("background-color:rgb(255,217,179)")
        self.btnCoordGeo.clicked.connect(self.click_CoordGeo)

        self.labelSearch = QLabel("        Search:",self)        # Label 'Search:'

        self.lineEditSearch = QLineEdit(self)
        self.lineEditSearch.returnPressed.connect(self.enter_LineEditSearch)  # Casella LineEdit (per ricerca)

        self.labelDatabase = QLabel("Database",self)  # Label 'Database'
        self.labelDatabase.setAlignment(QtCore.Qt.AlignCenter)
        self.labelDatabase.setFont(QtGui.QFont("BrushScriptStd",36))
        self.labelDatabase.setStyleSheet("color:blue")
        self.btnChart = QPushButton("Chart",self)  # Pulsante Chart
        self.btnChart.setStyleSheet("height:48px;color:blue;font:bold")
        self.btnChart.clicked.connect(self.click_Chart)
        self.btnChartUp = QPushButton(self)        # Pulsante Chart Up
        self.btnChartUp.setIcon(QtGui.QIcon("ManoSu.png"))
        self.btnChartUp.setIconSize(QtCore.QSize(20,30))
        self.btnChartUp.clicked.connect(self.click_ChartUp)
        self.btnChartDown = QPushButton(self)      # Pulsante Chart Down
        self.btnChartDown.setIcon(QtGui.QIcon("ManoGiù.png"))
        self.btnChartDown.setIconSize(QtCore.QSize(20,30))
        self.btnChartDown.clicked.connect(self.click_ChartDown)
        self.label0 = QLabel("",self)
        self.label0.setFont(QtGui.QFont("",8))

    def enter_LineEditSearch(self):
        print(self.lineEditSearch.text())


class Add_Persone(DialogDatabase):

    def Crea_FinestraAddPersone(self):

        title = "Aggiungi un Record al Database Persone";left=600;top=1120;width=1200;height=80;iconName="database.png"
        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(iconName))
        self.setGeometry(left,top,width,height)
        self.setStyleSheet('background-color:white')
        self.show()

    def Crea_OggettieLayoutAddPersone(self):
        Cognomelabel = QLabel("Cognome", self)
        Nomelabel = QLabel("Nome", self)
        Datalabel = QLabel("Data", self)
        Oralabel = QLabel("Ora", self)
        Fusolabel = QLabel("Fuso", self)
        Localitàlabel = QLabel("Località", self)
        Longlabel = QLabel("Long", self)
        Latlabel = QLabel("Lat", self)
        Professionelabel = QLabel("Professione", self)
        self.CognomelineEdit = QLineEdit(self)
        self.CognomelineEdit.returnPressed.connect(self.pressInsert)
        self.NomelineEdit = QLineEdit(self)
        self.NomelineEdit.returnPressed.connect(self.pressInsert)
        self.DatalineEdit = QLineEdit(self)
        self.DatalineEdit.returnPressed.connect(self.pressInsert)
        self.OralineEdit = QLineEdit(self)
        self.OralineEdit.returnPressed.connect(self.pressInsert)
        self.FusolineEdit = QLineEdit(self)
        self.FusolineEdit.returnPressed.connect(self.pressInsert)
        self.LocalitàlineEdit = QLineEdit(self)
        self.LocalitàlineEdit.returnPressed.connect(self.pressInsert)
        self.LonglineEdit = QLineEdit(self)
        self.LonglineEdit.returnPressed.connect(self.pressInsert)
        self.LatlineEdit = QLineEdit(self)
        self.LatlineEdit.returnPressed.connect(self.pressInsert)
        self.ProfessionelineEdit = QLineEdit(self)
        self.ProfessionelineEdit.returnPressed.connect(self.pressInsert)

        grid = QGridLayout()
        grid.addWidget(Cognomelabel, 0, 0, QtCore.Qt.AlignCenter)
        grid.addWidget(self.CognomelineEdit, 1, 0)
        grid.addWidget(Nomelabel, 0, 1, QtCore.Qt.AlignCenter)
        grid.addWidget(self.NomelineEdit, 1, 1)
        grid.addWidget(Datalabel, 0, 2, QtCore.Qt.AlignCenter)
        grid.addWidget(self.DatalineEdit, 1, 2)
        grid.addWidget(Oralabel, 0, 3, QtCore.Qt.AlignCenter)
        grid.addWidget(self.OralineEdit, 1, 3)
        grid.addWidget(Fusolabel, 0, 4, QtCore.Qt.AlignCenter)
        grid.addWidget(self.FusolineEdit, 1, 4)
        grid.addWidget(Localitàlabel, 0, 5, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LocalitàlineEdit, 1, 5)
        grid.addWidget(Longlabel, 0, 6, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LonglineEdit, 1, 6)
        grid.addWidget(Latlabel, 0, 7, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LatlineEdit, 1, 7)
        grid.addWidget(Professionelabel, 0, 8, QtCore.Qt.AlignCenter)
        grid.addWidget(self.ProfessionelineEdit, 1, 8)
        self.setLayout(grid)

    def pressInsert(self):
        Cognome = self.CognomelineEdit.text()
        Nome = self.NomelineEdit.text()
        Data = self.DatalineEdit.text()
        Ora = self.OralineEdit.text()
        Fuso = self.FusolineEdit.text()
        Località = self.LocalitàlineEdit.text()
        Long = self.LonglineEdit.text()
        Lat = self.LatlineEdit.text()
        Professione = self.ProfessionelineEdit.text()

        curs.execute('INSERT INTO Persone VALUES (?,?,?,?,?,?,?,?,?)',(Cognome, Nome, Data, Ora, Fuso, Località, Long, Lat, Professione))
        conn.commit()

        self.CognomelineEdit.setText("");self.NomelineEdit.setText("");self.DatalineEdit.setText("");self.OralineEdit.setText("")
        self.FusolineEdit.setText("");self.LocalitàlineEdit.setText("");self.LonglineEdit.setText("");self.LatlineEdit.setText("");self.ProfessionelineEdit.setText("")
        self.CognomelineEdit.setFocus()

        self.d2 = DialogDatabase()
        self.d2.LoadDatabase_Persone()


class Delete_Persone(DialogDatabase):

    def Crea_FinestraDeletePersone(self):
        title = "Elimina il Record dal Database Persone";left=600;top=1120;width=1200;height=80;iconName="database.png"
        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(iconName))
        self.setGeometry(left,top,width,height)
        self.setStyleSheet('background-color:white')
        self.show()

    global Cognome

    def Crea_OggettieLayoutDeletePersone(self):
        Cognomelabel = QLabel("Cognome", self)
        Nomelabel = QLabel("Nome", self)
        Datalabel = QLabel("Data", self)
        Oralabel = QLabel("Ora", self)
        Fusolabel = QLabel("Fuso", self)
        Localitàlabel = QLabel("Località", self)
        Longlabel = QLabel("Long", self)
        Latlabel = QLabel("Lat", self)
        Professionelabel = QLabel("Professione", self)

        self.CognomelineEdit = QLineEdit(self)
        self.CognomelineEdit.setText(Cognome)
        self.CognomelineEdit.setReadOnly(1)
        self.NomelineEdit = QLineEdit(self)
        self.NomelineEdit.setText(Nome)
        self.NomelineEdit.setReadOnly(1)
        self.DatalineEdit = QLineEdit(self)
        self.DatalineEdit.setText(Data)
        self.DatalineEdit.setReadOnly(1)
        self.OralineEdit = QLineEdit(self)
        self.OralineEdit.setText(Ora)
        self.OralineEdit.setReadOnly(1)
        self.FusolineEdit = QLineEdit(self)
        self.FusolineEdit.setText(Fuso)
        self.FusolineEdit.setReadOnly(1)
        self.LocalitàlineEdit = QLineEdit(self)
        self.LocalitàlineEdit.setText(Località)
        self.LocalitàlineEdit.setReadOnly(1)
        self.LonglineEdit = QLineEdit(self)
        self.LonglineEdit.setText(Long)
        self.LonglineEdit.setReadOnly(1)
        self.LatlineEdit = QLineEdit(self)
        self.LatlineEdit.setText(Lat)
        self.LatlineEdit.setReadOnly(1)
        self.ProfessionelineEdit = QLineEdit(self)
        self.ProfessionelineEdit.setText(Professione)
        self.ProfessionelineEdit.setReadOnly(1)

        self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.buttonbox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonbox.setStyleSheet('color:blue;font:bold')
        self.buttonbox.accepted.connect(self.accept)
        self.buttonbox.rejected.connect(self.reject)

        grid = QGridLayout()
        grid.addWidget(Cognomelabel, 0, 0, QtCore.Qt.AlignCenter)
        grid.addWidget(self.CognomelineEdit, 1, 0)
        grid.addWidget(Nomelabel, 0, 1, QtCore.Qt.AlignCenter)
        grid.addWidget(self.NomelineEdit, 1, 1)
        grid.addWidget(Datalabel, 0, 2, QtCore.Qt.AlignCenter)
        grid.addWidget(self.DatalineEdit, 1, 2)
        grid.addWidget(Oralabel, 0, 3, QtCore.Qt.AlignCenter)
        grid.addWidget(self.OralineEdit, 1, 3)
        grid.addWidget(Fusolabel, 0, 4, QtCore.Qt.AlignCenter)
        grid.addWidget(self.FusolineEdit, 1, 4)
        grid.addWidget(Localitàlabel, 0, 5, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LocalitàlineEdit, 1, 5)
        grid.addWidget(Longlabel, 0, 6, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LonglineEdit, 1, 6)
        grid.addWidget(Latlabel, 0, 7, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LatlineEdit, 1, 7)
        grid.addWidget(Professionelabel, 0, 8, QtCore.Qt.AlignCenter)
        grid.addWidget(self.ProfessionelineEdit, 1, 8)
        grid.addWidget(self.buttonbox, 2, 8)
        self.setLayout(grid)

    def accept(self):
        curs.execute('DELETE FROM Persone WHERE Cognome=? AND Nome=? AND Data=? AND Ora=? AND Fuso=? AND Località=? AND Long=? AND Lat=? AND Professione=?', \
                 (Cognome,Nome,Data,Ora,Fuso,Località,Long,Lat,Professione))
        conn.commit()
        self.d3 = DialogDatabase()
        self.d3.LoadDatabase_Persone()
        self.close()

    def reject(self):
        self.close()


class Edit_Persone(DialogDatabase):

    def Crea_FinestraEditPersone(self):
        title = "Modifica un Record al Database Persone";left=600;top=1120;width=1200;height=80;iconName="database.png"
        self.setWindowTitle(title)
        self.setWindowIcon(QtGui.QIcon(iconName))
        self.setGeometry(left,top,width,height)
        self.setStyleSheet('background-color:white')
        self.show()

    def Crea_OggettieLayoutEditPersone(self):
        Cognomelabel = QLabel("Cognome", self)
        Nomelabel = QLabel("Nome", self)
        Datalabel = QLabel("Data", self)
        Oralabel = QLabel("Ora", self)
        Fusolabel = QLabel("Fuso", self)
        Localitàlabel = QLabel("Località", self)
        Longlabel = QLabel("Long", self)
        Latlabel = QLabel("Lat", self)
        Professionelabel = QLabel("Professione", self)

        self.CognomelineEdit = QLineEdit(self)
        self.CognomelineEdit.setText(Cognome)
        self.CognomelineEdit.returnPressed.connect(self.pressInsertEd)
        self.NomelineEdit = QLineEdit(self)
        self.NomelineEdit.setText(Nome)
        self.NomelineEdit.returnPressed.connect(self.pressInsertEd)
        self.DatalineEdit = QLineEdit(self)
        self.DatalineEdit.setText(Data)
        self.DatalineEdit.returnPressed.connect(self.pressInsertEd)
        self.OralineEdit = QLineEdit(self)
        self.OralineEdit.setText(Ora)
        self.OralineEdit.returnPressed.connect(self.pressInsertEd)
        self.FusolineEdit = QLineEdit(self)
        self.FusolineEdit.setText(Fuso)
        self.FusolineEdit.returnPressed.connect(self.pressInsertEd)
        self.LocalitàlineEdit = QLineEdit(self)
        self.LocalitàlineEdit.setText(Località)
        self.LocalitàlineEdit.returnPressed.connect(self.pressInsertEd)
        self.LonglineEdit = QLineEdit(self)
        self.LonglineEdit.setText(Long)
        self.LonglineEdit.returnPressed.connect(self.pressInsertEd)
        self.LatlineEdit = QLineEdit(self)
        self.LatlineEdit.setText(Lat)
        self.LatlineEdit.returnPressed.connect(self.pressInsertEd)
        self.ProfessionelineEdit = QLineEdit(self)
        self.ProfessionelineEdit.setText(Professione)
        self.ProfessionelineEdit.returnPressed.connect(self.pressInsertEd)

        grid = QGridLayout()
        grid.addWidget(Cognomelabel, 0, 0, QtCore.Qt.AlignCenter)
        grid.addWidget(self.CognomelineEdit, 1, 0)
        grid.addWidget(Nomelabel, 0, 1, QtCore.Qt.AlignCenter)
        grid.addWidget(self.NomelineEdit, 1, 1)
        grid.addWidget(Datalabel, 0, 2, QtCore.Qt.AlignCenter)
        grid.addWidget(self.DatalineEdit, 1, 2)
        grid.addWidget(Oralabel, 0, 3, QtCore.Qt.AlignCenter)
        grid.addWidget(self.OralineEdit, 1, 3)
        grid.addWidget(Fusolabel, 0, 4, QtCore.Qt.AlignCenter)
        grid.addWidget(self.FusolineEdit, 1, 4)
        grid.addWidget(Localitàlabel, 0, 5, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LocalitàlineEdit, 1, 5)
        grid.addWidget(Longlabel, 0, 6, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LonglineEdit, 1, 6)
        grid.addWidget(Latlabel, 0, 7, QtCore.Qt.AlignCenter)
        grid.addWidget(self.LatlineEdit, 1, 7)
        grid.addWidget(Professionelabel, 0, 8, QtCore.Qt.AlignCenter)
        grid.addWidget(self.ProfessionelineEdit, 1, 8)
        self.setLayout(grid)

    def pressInsertEd(self):
        EdCognome = self.CognomelineEdit.text()
        EdNome = self.NomelineEdit.text()
        EdData = self.DatalineEdit.text()
        EdOra = self.OralineEdit.text()
        EdFuso = self.FusolineEdit.text()
        EdLocalità = self.LocalitàlineEdit.text()
        EdLong = self.LonglineEdit.text()
        EdLat = self.LatlineEdit.text()
        EdProfessione = self.ProfessionelineEdit.text()

        curs.execute('UPDATE Persone SET Cognome=?,Nome=?,Data=?,Ora=?,Fuso=?,Località=?,Long=?,Lat=?,Professione=? \
                                 WHERE Cognome=? AND Nome=? AND Data=? AND Ora=? AND Fuso=? AND Località=? AND Long=? AND Lat=? AND Professione=?', \
                                 (EdCognome,EdNome,EdData,EdOra,EdFuso,EdLocalità,EdLong,EdLat,EdProfessione,  Cognome,Nome,Data,Ora,Fuso,Località,Long,Lat,Professione))
        conn.commit()
        self.d3 = DialogDatabase()
        self.d3.LoadDatabase_Persone()
        self.close()


App = QApplication(sys.argv)  
window = Window()   
sys.exit(App.exec_())  

0 个答案:

没有答案