Python Forum
PyQt5 adding image
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt5 adding image
#1
I'm trying to add an image to my login window here and I'm not sure sure how to go about adding it on line 30. addWidget of course doesn't work but not exactly sure what method to use.

import sys
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QLineEdit, QPushButton, QStatusBar, QLabel,
                             QVBoxLayout)
from PyQt5.QtGui import QPixmap


class loginWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.resize(365, 250)
        self.setWindowTitle("Log into Inventory Manager")

        self.windowForm = loginWidget()
        self.setCentralWidget(self.windowForm)


class loginWidget(QWidget):
    def __init__(self):
        super().__init__()

        logoLabel = QLabel(self)
        pixmap = QPixmap('logo.jpg')
        logoLabel.setPixmap(pixmap)

        self.userTexBox = QLineEdit()
        self.passTextBox = QLineEdit()
        self.loginButton = QPushButton("LOGIN")

        layout = QVBoxLayout(self)
        layout.
        layout.addWidget(self.userTexBox)
        layout.addWidget(self.passTextBox)
        layout.addWidget(self.loginButton)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = loginWindow()
    window.show()
    sys.exit(app.exec_())
Reply


Messages In This Thread
PyQt5 adding image - by thewolf - Feb-20-2021, 03:53 PM
RE: PyQt5 adding image - by thewolf - Feb-20-2021, 03:57 PM
RE: PyQt5 adding image - by Axel_Erfurt - Feb-20-2021, 05:26 PM
RE: PyQt5 adding image - by thewolf - Feb-21-2021, 08:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  adding backgroung image ebolisa 4 2,734 Jan-08-2021, 11:45 AM
Last Post: JudyLarose
  Adding an image to a tkinter window djwilson0495 2 8,124 Aug-23-2020, 11:07 AM
Last Post: ebolisa
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,847 Apr-06-2019, 11:15 PM
Last Post: ZenWoR
  Need help adding a sql List to a combo box PyQt5 jimmyvegas29 1 8,637 Jul-20-2018, 07:28 AM
Last Post: Alfalfa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020