-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGörselProgramlama1VeriListeleme.txt
49 lines (39 loc) · 1.39 KB
/
GörselProgramlama1VeriListeleme.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
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QRadioButton, QListWidget
import sys
import mysql.connector
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
passwd = "",
database = "okul"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT aciklama FROM bolum")
bolumler = mycursor.fetchall()
class Pencere(QWidget):
def __init__(self):
super().__init__()
self.yerlesim = QVBoxLayout(self)
self.radyo = []
for i in range(len(bolumler)):
self.radyo.append(QRadioButton(self))
self.radyo[i].setText(bolumler[i][0])
self.yerlesim.addWidget(self.radyo[i])
self.liste = QListWidget(self)
self.yerlesim.addWidget(self.liste)
self.radyo[0].clicked.connect(lambda: self.click(1))
self.radyo[1].clicked.connect(lambda: self.click(2))
self.radyo[2].clicked.connect(lambda: self.click(3))
self.radyo[3].clicked.connect(lambda: self.click(4))
def click(self,bolum):
mycursor.execute("SELECT * FROM ogrenci WHERE bid=" + str(bolum) )
myresult = mycursor.fetchall()
isimler = []
for sıradaki in myresult:
isimler.append(sıradaki[1] + " " + sıradaki[2])
self.liste.clear()
self.liste.addItems(isimler)
uygulama = QApplication(sys.argv)
yenipencere = Pencere()
yenipencere.show()
uygulama.exec_()