DAVRAZ ELEKTROMOBİL ARAÇ İÇİ KONTROL EKRANI

github:https://github.com/flavves/davrazelektromobil

Kullanılan yöntemler: rezistif 7 Inch dokunmatik ekran,QT designer,python,raspberry pi3b+,8 relay röle kartı

QT designer ile tasarımı oluşturuyoruz.

BUTON EKLEMELERİ VE İCONLAR

Kod kısmına gelirsek

QT designer programından aldığımız ekran şablonunu koda dönüştürüyoruz(Nasıl olduğunu bilmiyorsanız https://www.youtube.com/channel/UCyQQbRVR94Ts8CU4H6ZZvdg)

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(949, 600)
        MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(50, 10, 271, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton.setFont(font)
        self.pushButton.setIconSize(QtCore.QSize(400, 300))
        self.pushButton.setObjectName("pushButton")
        self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QtCore.QRect(670, 10, 261, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setIconSize(QtCore.QSize(150, 150))
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QtCore.QRect(50, 190, 271, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_4.setGeometry(QtCore.QRect(370, 190, 261, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_4.setFont(font)
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_5.setGeometry(QtCore.QRect(670, 190, 261, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_5.setFont(font)
        self.pushButton_5.setObjectName("pushButton_5")
        self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_6.setGeometry(QtCore.QRect(370, 10, 261, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_6.setFont(font)
        self.pushButton_6.setIconSize(QtCore.QSize(300, 110))
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_8.setGeometry(QtCore.QRect(370, 10, 261, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_8.setFont(font)
        self.pushButton_8.setIconSize(QtCore.QSize(300, 110))
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_9.setGeometry(QtCore.QRect(370, 190, 261, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_9.setFont(font)
        self.pushButton_9.setIconSize(QtCore.QSize(100, 100))
        self.pushButton_9.setObjectName("pushButton_9")
        self.pushButton_10 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_10.setGeometry(QtCore.QRect(670, 190, 261, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_10.setFont(font)
        self.pushButton_10.setObjectName("pushButton_10")
        self.pushButton_12 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_12.setGeometry(QtCore.QRect(50, 190, 271, 151))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_12.setFont(font)
        self.pushButton_12.setObjectName("pushButton_12")
        self.pushButton_11 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_11.setGeometry(QtCore.QRect(50, 10, 271, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_11.setFont(font)
        self.pushButton_11.setIconSize(QtCore.QSize(600, 250))
        self.pushButton_11.setObjectName("pushButton_11")
        self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton_7.setGeometry(QtCore.QRect(670, 10, 261, 161))
        font = QtGui.QFont()
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.pushButton_7.setFont(font)
        self.pushButton_7.setIconSize(QtCore.QSize(300, 600))
        self.pushButton_7.setObjectName("pushButton_7")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(30, 410, 301, 161))
        self.label_2.setText("")
        self.label_2.setPixmap(QtGui.QPixmap(":/okul logo/logolar/logov3.ico"))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(680, 360, 256, 256))
        self.label_3.setText("")
        self.label_3.setPixmap(QtGui.QPixmap(":/benim logo/logolar/siyah (1).ico"))
        self.label_3.setObjectName("label_3")
        self.pushButton_3.raise_()
        self.pushButton_9.raise_()
        self.pushButton_10.raise_()
        self.pushButton_7.raise_()
        self.pushButton_8.raise_()
        self.pushButton.raise_()
        self.pushButton_12.raise_()
        self.pushButton_6.raise_()
        self.pushButton_2.raise_()
        self.pushButton_11.raise_()
        self.pushButton_4.raise_()
        self.pushButton_5.raise_()
        self.label_2.raise_()
        self.label_3.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "IŞIK AÇIK"))
        self.pushButton_2.setText(_translate("MainWindow", "MOTOR GERİ"))
        self.pushButton_3.setText(_translate("MainWindow", "SESLİ ASİSTAN"))
        self.pushButton_4.setText(_translate("MainWindow", "MULTİMEDYA"))
        self.pushButton_5.setText(_translate("MainWindow", "KAMERA"))
        self.pushButton_6.setText(_translate("MainWindow", "KAPI KİLİT AÇIK"))
        self.pushButton_8.setText(_translate("MainWindow", "KAPI KİLİTLİ"))
        self.pushButton_9.setText(_translate("MainWindow", "Fonksiyon"))
        self.pushButton_10.setText(_translate("MainWindow", "Fonksiyon"))
        self.pushButton_12.setText(_translate("MainWindow", "SESLİ ASİSTAN"))
        self.pushButton_11.setText(_translate("MainWindow", "IŞIK KAPALI"))
        self.pushButton_7.setText(_translate("MainWindow", "MOTOR İLERİ"))

import icons_rc

Bu dosyayı ana kodlarımızla beraber bulunan klasöre atıyoruz.

# -*- coding: utf-8 -*-
"""
Created on Sat Feb  6 20:25:09 2021
@author: yazılım
"""

import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtGui
import time
from PyQt5 import QtWidgets,uic,QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QLineEdit, QTextBrowser, QPushButton, QVBoxLayout, QProgressBar,QComboBox
from elektrikli_araba_python import Ui_MainWindow
from PyQt5.QtCore import QBasicTimer
from PyQt5.QtGui import *
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.uic import loadUi

from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QVBoxLayout
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5 import QtGui
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QThread
import numpy as np

def ceviriProgramim():

    class MainWindow(QMainWindow):
        def __init__(self):
            super(MainWindow, self).__init__()
            self.ui = Ui_MainWindow()
            self.ui.setupUi(self)
            #Butonları tanımlama
            self.setStyleSheet("background-color: rgb(61, 68,149);")

            self.ui.pushButton_7.setVisible(False)
            self.ui.pushButton_8.setVisible(False)
            self.ui.pushButton_9.setVisible(False)
            self.ui.pushButton_10.setVisible(False)
            self.ui.pushButton_11.setVisible(False)
            self.ui.pushButton_12.setVisible(False)

            self.ui.pushButton.clicked.connect(self.button_clicked_slot)
            self.ui.pushButton_2.clicked.connect(self.button_2clicked_slot)
            self.ui.pushButton_3.clicked.connect(self.button_3clicked_slot)
            self.ui.pushButton_4.clicked.connect(self.button_4clicked_slot)
            self.ui.pushButton_5.clicked.connect(self.button_5clicked_slot)
            self.ui.pushButton_6.clicked.connect(self.button_6clicked_slot)
            self.ui.pushButton_7.clicked.connect(self.button_7clicked_slot)
            self.ui.pushButton_8.clicked.connect(self.button_8clicked_slot)
            self.ui.pushButton_9.clicked.connect(self.button_9clicked_slot)
            self.ui.pushButton_10.clicked.connect(self.button_10clicked_slot)
            self.ui.pushButton_11.clicked.connect(self.button_11clicked_slot)
            self.ui.pushButton_12.clicked.connect(self.button_12clicked_slot)

            # renkler
            self.ui.pushButton.setStyleSheet("background-color: rgb(115, 196,200);")
            #self.ui.pushButton.setIcon(QIcon("buton.png"))
            self.ui.pushButton_2.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_3.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_4.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_5.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_6.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_7.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_8.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_9.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_10.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_11.setStyleSheet("background-color: rgb(115, 196,200);")
            self.ui.pushButton_12.setStyleSheet("background-color: rgb(115, 196,200);")
        def button_3clicked_slot(self):
            print("bays kapattım")
            self.close()
        def button_clicked_slot(self):
            print("button_clicked_slot")
            
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(3, #GPIO.OUT)
            #GPIO.output(3, #GPIO.HIGH)
            self.ui.pushButton.setVisible(False)
            self.ui.pushButton_11.setVisible(True)
        def button_2clicked_slot(self):
            print("button_2clicked_slot")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(5, #GPIO.OUT)
            #GPIO.output(5, #GPIO.HIGH)

            self.ui.pushButton_2.setVisible(False)
            self.ui.pushButton_7.setVisible(True)

        def button_4clicked_slot(self):
            print("button_4clicked_slot")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(11, #GPIO.OUT)
            #GPIO.output(11, #GPIO.HIGH)


            self.ui.pushButton_4.setVisible(False)
            self.ui.pushButton_9.setVisible(True)
        def button_5clicked_slot(self):
            print("button_5clicked_slot")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(13, #GPIO.OUT)
            #GPIO.output(13, #GPIO.HIGH)


            self.ui.pushButton_5.setVisible(False)
            self.ui.pushButton_10.setVisible(True)
        def button_6clicked_slot(self):
            print("button_6clicked_slot")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(15, #GPIO.OUT)
            #GPIO.output(15, #GPIO.HIGH)

            self.ui.pushButton_6.setVisible(False)
            self.ui.pushButton_8.setVisible(True)

        def button_7clicked_slot(self):
            print("hello7")

            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(5, #GPIO.OUT)
            #GPIO.output(5, #GPIO.LOW)

            self.ui.pushButton_7.setVisible(False)
            self.ui.pushButton_2.setVisible(True)
        def button_8clicked_slot(self):
            print("hello8")

            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(7, #GPIO.OUT)
            #GPIO.output(7, #GPIO.LOW)
            self.ui.pushButton_8.setVisible(False)
            self.ui.pushButton_6.setVisible(True)
        def button_9clicked_slot(self):
            print("hello9")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(11, #GPIO.OUT)
            #GPIO.output(11, #GPIO.LOW)
            self.ui.pushButton_9.setVisible(False)
            self.ui.pushButton_4.setVisible(True)
        def button_10clicked_slot(self):
            print("hello10")

            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(13, #GPIO.OUT)
            #GPIO.output(13, #GPIO.LOW)
            self.ui.pushButton_10.setVisible(False)
            self.ui.pushButton_5.setVisible(True)
        def button_11clicked_slot(self):
            print("hello11")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(3, #GPIO.OUT)
            #GPIO.output(3, #GPIO.LOW)
            self.ui.pushButton_11.setVisible(False)
            self.ui.pushButton.setVisible(True)
        def button_12clicked_slot(self):
            print("helloaaa12")
            #GPIO.cleanup()
            #GPIO.setmode(#GPIO.BOARD)
            #GPIO.setup(7, #GPIO.OUT)
            #GPIO.output(7, #GPIO.LOW)
            self.ui.pushButton_12.setVisible(False)
            self.ui.pushButton_3.setVisible(True)
            
    if __name__ == "__main__":
        app = QApplication(sys.argv)

        window = MainWindow()
        window.setWindowTitle("Batuhan ökmen")
        #window.showFullScreen()
        window.show()

        sys.exit(app.exec_())

ceviriProgramim()

Windows için test edebilmeniz için gpıo kütüphanesini kaldırdım isterseniz aktif edebilirsiniz.

Bir cevap yazın