import sys
import RPi.GPIO as GPIO
import time
import subprocess
from PyQt5.QtCore import *
from PyQt5.QtGui import *
GPIO.setmode(GPIO.BOARD)
#--------------Degiskenler---------------
#Girisler
#Cikislar
kapaliCikis= 16
yolcuCikis = 22
soforCikis = 24
geceLambaCikis = 26
aydinlatmaCikis = 32
hostesIkazCikis = 36
#-----------Tanimlamalar-----------------
#Giris
#GPIO.setup(fanButton,GPIO.IN)
#GPIO.setup(durdurButton,GPIO.IN)
#--------------Cikislar---------------------
GPIO.setup(kapaliCikis,GPIO.OUT)
GPIO.setup(yolcuCikis,GPIO.OUT)
GPIO.setup(soforCikis,GPIO.OUT)
GPIO.setup(geceLambaCikis,GPIO.OUT)
GPIO.setup(aydinlatmaCikis,GPIO.OUT)
GPIO.setup(hostesIkazCikis,GPIO.OUT)
class Example():
def __init__(self):
self.fanhiz = 10
#------------------BUTTONLAR--------------------------
#-------------- BUTTON 1 LCD GOSTERICISI---------------
self.lcd1.resize(200,70)
self.lcd1.move(175,50)
#-------------BUTTON 2 LCD GOSTERICISI-----------------
self.lcd2.resize(200,70)
self.lcd2.move(525,50)
#-------------BUTTON 3 LCD GOSTERICISI-----------------
self.lcd3.resize(200,70)
self.lcd3.move(175,150)
#-------------BUTTON 4 LCD GOSTERICISI-----------------
self.lcd4.resize(200,70)
self.lcd4.move(525,150)
#-------------BUTTON 5 LCD GOSTERICISI-----------------
self.lcd5.resize(200,70)
self.lcd5.move(175,250)
#-------------BUTTON 6 LCD GOSTERICISI-----------------
self.lcd6.resize(200,70)
self.lcd6.move(525,250)
#-------------LCD Dokunma islemi islemleri icin bool degiskenleri-----------------
self.lcd6Bool = True
self.lcd5Bool = True
self.lcd4Bool = True
self.lcd3Bool = True
self.lcd2Bool = True
self.lcd1Bool = True
self.btnState = False
self.initUI()
def initUI(self):
#--------------- Kapali -----------------------
self.btn.setToolTip('Buton1 islemleri') # Buton aciklamasini gosteriyor,uzerine gelindiginde.
self.btn.resize(120,70) # BOYUTLANDIRMA
self.btn.move(50, 50) # KONUMLANDIRMA
self.btn.clicked.connect(self.buton1_event) # button1 cikis olayi
self.btn.setAutoFillBackground(True)
#--------------- Yolcu Alma -----------------------
self.btn2.setToolTip('Buton2 islemleri')
self.
btn2.
setFont(QFont('Times',
10)) self.btn2.resize(120,70)
self.btn2.move(400, 50)
self.btn2.clicked.connect(self.buton2_event) # button2 cikis olayi
#--------------- Sofor Kontrol -----------------------
self.
btn3.
setFont(QFont('Times',
10)) self.btn3.resize(120,70)
self.btn3.move(50,150)
self.btn3.clicked.connect(self.buton3_event)
#--------------- Gece Lambalari -----------------------
self.
btn4.
setFont(QFont('Times',
10)) self.btn4.resize(120,70)
self.btn4.move(400,150)
self.btn4.clicked.connect(self.buton4_event)
#--------------- Aydinlatma ---------------------------
self.
btn5.
setFont(QFont('Times',
10)) self.btn5.resize(120,70)
self.btn5.move(50,250)
self.btn5.clicked.connect(self.buton5_event)
#--------------- Hostes Ikaz(imput) -----------------------
self.
btn6.
setFont(QFont('Times',
10)) self.btn6.resize(120,70)
self.btn6.move(400,250)
self.btn6.clicked.connect(self.buton6_event)
#--------------- Cikis -----------------------
cikis.setToolTip('Uygulama Kapanir')
cikis.resize(120,70)
cikis.move(340,350)
cikis.
clicked.
connect(QApplication.
instance().
quit) # cikis buttonu
self.dnm.setGeometry(300, 300, 800, 480)
#self.dnm.showFullScreen()
self.dnm.setWindowTitle('pi ekran')
#self.dnm.setWindowIcon(QIcon('/img/inovar.png')) # icon gostermiyor.!!
self.dnm.show()
def Ac(self,Cpin):
GPIO.output(Cpin,GPIO.HIGH)
def Kapat(self,Cpin):
GPIO.output(Cpin,GPIO.LOW)
# --------------Button1 Tiklama Olayi ------------------
def buton1_event(self):
if self.lcd1Bool == True:
self.lcd1.display(1)
self.Ac(kapaliCikis)
self.btn.setStyleSheet("background-color: yellow")
self.lcd1Bool = False
else:
self.lcd1.display(0)
self.Kapat(kapaliCikis)
self.btn.setStyleSheet("background-color: #257c07")
self.lcd1Bool = True
# --------------Button2 Tiklama Olayi ------------------
def buton2_event(self):
if self.lcd2Bool == True:
self.lcd2.display(1)
self.Ac(yolcuCikis)
self.lcd2Bool = False
else:
self.lcd2.display(0)
self.Kapat(yolcuCikis)
self.lcd2Bool = True
# --------------Button3 Tiklama Olayi ------------------
def buton3_event(self):
if self.lcd3Bool == True:
self.lcd3.display(1)
self.Ac(soforCikis)
self.lcd3Bool = False
else:
self.lcd3.display(0)
self.Kapat(soforCikis)
self.lcd3Bool = True
#--------------Button4 Tiklama Olayi ------------------
def buton4_event(self):
if self.lcd4Bool == True:
self.lcd4.display(1)
self.Ac(geceLambaCikis)
self.lcd4Bool = False
else:
self.lcd4.display(0)
self.Kapat(geceLambaCikis)
self.lcd4Bool = True
#--------------Button5 Tiklama Olayi ------------------
def buton5_event(self):
if self.lcd5Bool == True:
self.lcd5.display(1)
self.Ac(aydinlatmaCikis)
self.lcd5Bool = False
else:
self.lcd5.display(0)
self.Kapat(aydinlatmaCikis)
self.lcd5Bool = True
#--------------Button6 Tiklama Olayi ------------------
def buton6_event(self):
if self.lcd6Bool == True:
self.lcd6.display(1)
self.Ac(hostesIkazCikis)
self.lcd6Bool = False
else:
self.lcd6.display(0)
self.Kapat(hostesIkazCikis)
self.lcd6Bool = True
if __name__ == '__main__':
ex = Example()
"""
dnm = QWidget()
QToolTip.setFont(QFont('SansSerif', 10))
dnm.setGeometry(300, 300, 800, 480)
dnm.setWindowTitle('pi ekran2')
dnm.show()
"""
sys.exit(app.exec_())
import sys
import RPi.GPIO as GPIO
import time
import subprocess
from PyQt5.QtWidgets import (QWidget, QToolTip,
QPushButton,QVBoxLayout, QApplication, QLCDNumber, QLabel)
from PyQt5.QtCore import *
from PyQt5.QtGui import *
GPIO.setmode(GPIO.BOARD)
#--------------Degiskenler---------------
#Girisler
#Cikislar
kapaliCikis= 16
yolcuCikis = 22
soforCikis = 24
geceLambaCikis = 26
aydinlatmaCikis = 32
hostesIkazCikis = 36
#-----------Tanimlamalar-----------------
#Giris
#GPIO.setup(fanButton,GPIO.IN)
#GPIO.setup(durdurButton,GPIO.IN)
#--------------Cikislar---------------------
GPIO.setup(kapaliCikis,GPIO.OUT)
GPIO.setup(yolcuCikis,GPIO.OUT)
GPIO.setup(soforCikis,GPIO.OUT)
GPIO.setup(geceLambaCikis,GPIO.OUT)
GPIO.setup(aydinlatmaCikis,GPIO.OUT)
GPIO.setup(hostesIkazCikis,GPIO.OUT)
class Example():
def __init__(self):
self.fanhiz = 10
self.dnm = QWidget()
#------------------BUTTONLAR--------------------------
self.btn = QPushButton('Kapali',self.dnm)
self.btn2 = QPushButton('Yolcu Alma',self.dnm)
self.btn3 = QPushButton('Sofor Kontrol',self.dnm)
self.btn4 = QPushButton('Gece Lamblari',self.dnm)
self.btn5 = QPushButton('Aydinlatma',self.dnm)
self.btn6 = QPushButton('Hostes ikaz',self.dnm)
#-------------- BUTTON 1 LCD GOSTERICISI---------------
self.lcd1 = QLCDNumber(self.dnm)
self.lcd1.resize(200,70)
self.lcd1.move(175,50)
#-------------BUTTON 2 LCD GOSTERICISI-----------------
self.lcd2 = QLCDNumber(self.dnm)
self.lcd2.resize(200,70)
self.lcd2.move(525,50)
#-------------BUTTON 3 LCD GOSTERICISI-----------------
self.lcd3 = QLCDNumber(self.dnm)
self.lcd3.resize(200,70)
self.lcd3.move(175,150)
#-------------BUTTON 4 LCD GOSTERICISI-----------------
self.lcd4 = QLCDNumber(self.dnm)
self.lcd4.resize(200,70)
self.lcd4.move(525,150)
#-------------BUTTON 5 LCD GOSTERICISI-----------------
self.lcd5 = QLCDNumber(self.dnm)
self.lcd5.resize(200,70)
self.lcd5.move(175,250)
#-------------BUTTON 6 LCD GOSTERICISI-----------------
self.lcd6 = QLCDNumber(self.dnm)
self.lcd6.resize(200,70)
self.lcd6.move(525,250)
#-------------LCD Dokunma islemi islemleri icin bool degiskenleri-----------------
self.lcd6Bool = True
self.lcd5Bool = True
self.lcd4Bool = True
self.lcd3Bool = True
self.lcd2Bool = True
self.lcd1Bool = True
self.btnState = False
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
#--------------- Kapali -----------------------
self.btn.setToolTip('Buton1 islemleri') # Buton aciklamasini gosteriyor,uzerine gelindiginde.
self.btn.resize(120,70) # BOYUTLANDIRMA
self.btn.move(50, 50) # KONUMLANDIRMA
self.btn.clicked.connect(self.buton1_event) # button1 cikis olayi
self.btn.setAutoFillBackground(True)
#--------------- Yolcu Alma -----------------------
self.btn2.setToolTip('Buton2 islemleri')
self.btn2.setFont(QFont('Times',10))
self.btn2.resize(120,70)
self.btn2.move(400, 50)
self.btn2.clicked.connect(self.buton2_event) # button2 cikis olayi
#--------------- Sofor Kontrol -----------------------
self.btn3.setFont(QFont('Times',10))
self.btn3.resize(120,70)
self.btn3.move(50,150)
self.btn3.clicked.connect(self.buton3_event)
#--------------- Gece Lambalari -----------------------
self.btn4.setFont(QFont('Times',10))
self.btn4.resize(120,70)
self.btn4.move(400,150)
self.btn4.clicked.connect(self.buton4_event)
#--------------- Aydinlatma ---------------------------
self.btn5.setFont(QFont('Times',10))
self.btn5.resize(120,70)
self.btn5.move(50,250)
self.btn5.clicked.connect(self.buton5_event)
#--------------- Hostes Ikaz(imput) -----------------------
self.btn6.setFont(QFont('Times',10))
self.btn6.resize(120,70)
self.btn6.move(400,250)
self.btn6.clicked.connect(self.buton6_event)
#--------------- Cikis -----------------------
cikis = QPushButton('Cikis',self.dnm)
cikis.setToolTip('Uygulama Kapanir')
cikis.resize(120,70)
cikis.move(340,350)
cikis.clicked.connect(QApplication.instance().quit) # cikis buttonu
self.dnm.setGeometry(300, 300, 800, 480)
#self.dnm.showFullScreen()
self.dnm.setWindowTitle('pi ekran')
#self.dnm.setWindowIcon(QIcon('/img/inovar.png')) # icon gostermiyor.!!
self.dnm.show()
def Ac(self,Cpin):
GPIO.output(Cpin,GPIO.HIGH)
def Kapat(self,Cpin):
GPIO.output(Cpin,GPIO.LOW)
# --------------Button1 Tiklama Olayi ------------------
def buton1_event(self):
if self.lcd1Bool == True:
self.lcd1.display(1)
self.Ac(kapaliCikis)
self.btn.setStyleSheet("background-color: yellow")
self.lcd1Bool = False
else:
self.lcd1.display(0)
self.Kapat(kapaliCikis)
self.btn.setStyleSheet("background-color: #257c07")
self.lcd1Bool = True
# --------------Button2 Tiklama Olayi ------------------
def buton2_event(self):
if self.lcd2Bool == True:
self.lcd2.display(1)
self.Ac(yolcuCikis)
self.lcd2Bool = False
else:
self.lcd2.display(0)
self.Kapat(yolcuCikis)
self.lcd2Bool = True
# --------------Button3 Tiklama Olayi ------------------
def buton3_event(self):
if self.lcd3Bool == True:
self.lcd3.display(1)
self.Ac(soforCikis)
self.lcd3Bool = False
else:
self.lcd3.display(0)
self.Kapat(soforCikis)
self.lcd3Bool = True
#--------------Button4 Tiklama Olayi ------------------
def buton4_event(self):
if self.lcd4Bool == True:
self.lcd4.display(1)
self.Ac(geceLambaCikis)
self.lcd4Bool = False
else:
self.lcd4.display(0)
self.Kapat(geceLambaCikis)
self.lcd4Bool = True
#--------------Button5 Tiklama Olayi ------------------
def buton5_event(self):
if self.lcd5Bool == True:
self.lcd5.display(1)
self.Ac(aydinlatmaCikis)
self.lcd5Bool = False
else:
self.lcd5.display(0)
self.Kapat(aydinlatmaCikis)
self.lcd5Bool = True
#--------------Button6 Tiklama Olayi ------------------
def buton6_event(self):
if self.lcd6Bool == True:
self.lcd6.display(1)
self.Ac(hostesIkazCikis)
self.lcd6Bool = False
else:
self.lcd6.display(0)
self.Kapat(hostesIkazCikis)
self.lcd6Bool = True
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
"""
dnm = QWidget()
QToolTip.setFont(QFont('SansSerif', 10))
dnm.setGeometry(300, 300, 800, 480)
dnm.setWindowTitle('pi ekran2')
dnm.show()
"""
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks