import sys
from PyQt5.QtWidgets import (QApplication,
                             QMainWindow,
                             QPushButton,
                             QToolTip,
                             QLabel,
                             QLineEdit)

from PyQt5 import QtGui


class Janela(QMainWindow):
    def __init__(self):
        super().__init__()
        self.topo = 50
        self.esquerda = 50
        self.largura = 800
        self.altura = 600
        self.titulo = 'Primeira janela'
        self.gera_labels()
        self.gera_botoes()
        self.gera_imagens()
        self.gera_caixas_de_texto()

    def carregar_janela(self):
        self.setGeometry(self.esquerda, self.topo, self.largura, self.altura)
        self.setWindowTitle(self.titulo)
        self.show()

    def gera_botoes(self):
        # botoes
        botao1 = QPushButton('Botao 1', self)
        botao1.move(100, 100)
        botao1.resize(100, 50)
        botao1.setStyleSheet(
            'QPushButton{background-color: white; color: black;} QPushButton:hover{ background: orange; font-weight: 600;}')
        botao1.clicked.connect(self.b1)

        botao2 = QPushButton('Botao 2', self)
        botao2.move(300, 100)
        botao2.resize(100, 50)
        botao2.setStyleSheet(
            'QPushButton{background-color: blue; color: white;} QPushButton:hover{ background: orange; font-weight: 600}')
        botao2.clicked.connect(self.b2)

        botao3 = QPushButton('Texto', self)
        botao3.move(500, 100)
        botao3.resize(100, 50)
        botao3.setStyleSheet('QPushButton{background-color: black; color: white;} QPushButton:hover{ background: orange; font-weight: 600}')
        botao3.clicked.connect(self.b3)

    def gera_labels(self):
        self.l1 = QLabel(self)
        self.l1.setText('Clique em um botao')
        self.l1.move(50, 50)
        self.l1.setStyleSheet('QLabel{font: bold; font-size: 20px;}')
        self.l1.resize(250, 50)

        self.l2 = QLabel(self)
        self.l2.setText('Digitou: ')
        self.l2.move(300, 30)
        self.l2.resize(260, 50)
        self.l2.setStyleSheet('QLabel{font: bold; font-size: 30px;}')

    def gera_imagens(self):
        self.carro = QLabel(self)
        self.carro.move(25, 200)
        self.carro.resize(450, 337)
        self.carro.setPixmap(QtGui.QPixmap('carro.jpg'))

    def gera_caixas_de_texto(self):
        self.caixa_texto = QLineEdit(self)
        self.caixa_texto.move(25, 10)
        self.caixa_texto.resize(150, 50)


    def b1(self):
        # forma 1
        self.carro.setPixmap(QtGui.QPixmap('carro.jpg'))


    def b2(self, l):
        # forma 2
        self.carro.setPixmap(QtGui.QPixmap('carro2.jpg'))

    def b3(self):
        conteudo = self.caixa_texto.text()
        self.l2.setText('Digitou: {}'.format(conteudo))

if __name__ == '__main__':
    app = QApplication(sys.argv)
    janela = Janela()
    janela.carregar_janela()
    sys.exit(app.exec_())
[((91, 10, 91, 32), 'PyQt5.QtWidgets.QApplication', 'QApplication', ({(91, 23, 91, 31): 'sys.argv'}, {}), '(sys.argv)', False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((32, 17, 32, 45), 'PyQt5.QtWidgets.QPushButton', 'QPushButton', ({(32, 29, 32, 38): '"""Botao 1"""', (32, 40, 32, 44): 'self'}, {}), "('Botao 1', self)", False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((39, 17, 39, 45), 'PyQt5.QtWidgets.QPushButton', 'QPushButton', ({(39, 29, 39, 38): '"""Botao 2"""', (39, 40, 39, 44): 'self'}, {}), "('Botao 2', self)", False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((46, 17, 46, 43), 'PyQt5.QtWidgets.QPushButton', 'QPushButton', ({(46, 29, 46, 36): '"""Texto"""', (46, 38, 46, 42): 'self'}, {}), "('Texto', self)", False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((53, 18, 53, 30), 'PyQt5.QtWidgets.QLabel', 'QLabel', ({(53, 25, 53, 29): 'self'}, {}), '(self)', False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((59, 18, 59, 30), 'PyQt5.QtWidgets.QLabel', 'QLabel', ({(59, 25, 59, 29): 'self'}, {}), '(self)', False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((66, 21, 66, 33), 'PyQt5.QtWidgets.QLabel', 'QLabel', ({(66, 28, 66, 32): 'self'}, {}), '(self)', False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((72, 27, 72, 42), 'PyQt5.QtWidgets.QLineEdit', 'QLineEdit', ({(72, 37, 72, 41): 'self'}, {}), '(self)', False, 'from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QToolTip, QLabel, QLineEdit\n'), ((69, 29, 69, 55), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(69, 43, 69, 54): '"""carro.jpg"""'}, {}), "('carro.jpg')", False, 'from PyQt5 import QtGui\n'), ((79, 29, 79, 55), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(79, 43, 79, 54): '"""carro.jpg"""'}, {}), "('carro.jpg')", False, 'from PyQt5 import QtGui\n'), ((84, 29, 84, 56), 'PyQt5.QtGui.QPixmap', 'QtGui.QPixmap', ({(84, 43, 84, 55): '"""carro2.jpg"""'}, {}), "('carro2.jpg')", False, 'from PyQt5 import QtGui\n')]