-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGörselProgramlama1VeriEditleme.txt
77 lines (63 loc) · 1.96 KB
/
GörselProgramlama1VeriEditleme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from PyQt5.QtWidgets import QWidget, QApplication, QListWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QPushButton
import sys
import mysql.connector
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
passwd = "",
database = "okul"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM ogrenci")
myresult = mycursor.fetchall()
no = []
ad = []
soy = []
for x in myresult:
no.append(str(x[0]))
ad.append(x[1])
soy.append(x[2])
class Pencere(QWidget):
def __init__(self):
super().__init__()
layout = QHBoxLayout(self)
self.list = QListWidget(self)
self.list.addItems(ad)
self.list2 = QListWidget(self)
self.list2.addItems(soy)
self.list3 = QListWidget()
self.list3.addItems(no)
self.lineEdit = QLineEdit(self)
self.lineEdit2 = QLineEdit(self)
self.button = QPushButton("Güncelle", self)
layout.addWidget(self.list)
layout.addWidget(self.list2)
layout.addWidget(self.lineEdit)
layout.addWidget(self.lineEdit2)
layout.addWidget(self.button)
self.list.clicked.connect(self.aktarad)
self.list2.clicked.connect(self.aktarsoyad)
self.button.clicked.connect(self.aktarma)
def aktarad (self):
global row
row = self.list.currentRow()
item = self.list.currentItem()
self.lineEdit.setText(item.text())
def aktarsoyad (self):
item = self.list2.currentItem()
self.lineEdit2.setText(item.text())
def aktarma (self):
global row
ad = str(self.lineEdit.text())
soyad = str(self.lineEdit2.text())
no = 1
no += row
mycursor2 = mydb.cursor()
sql = "UPDATE ogrenci SET adi = %s, soyadi = %s WHERE ono = %s"
val = (ad, soyad, no)
mycursor2.execute(sql, val)
mydb.commit()
uygulama = QApplication(sys.argv)
pencere = Pencere()
pencere.show()
uygulama.exec_()