Python 将图像添加到选项卡

Python 将图像添加到选项卡,python,pyqt,pyqt4,qimage,Python,Pyqt,Pyqt4,Qimage,我遇到了另一个问题,也许你们都能帮我,我似乎不能在我的任何标签上添加照片,你们能帮我吗 这是我的密码 import sys import webbrowser import random import time import os from PyQt4.QtGui import QApplication, QMainWindow, QPushButton, QWidget, QIcon, QLabel, QPixmap class UICreator(QWidget): # |||| CR

我遇到了另一个问题,也许你们都能帮我,我似乎不能在我的任何标签上添加照片,你们能帮我吗

这是我的密码

import sys
import webbrowser
import random
import time
import os
from PyQt4.QtGui import QApplication, QMainWindow, QPushButton, QWidget, QIcon, QLabel, QPixmap


class UICreator(QWidget):  # |||| CREATOR TAB |||
    def __init__(self, parent=None):
        super(UICreator, self).__init__(parent)

        self.Back = QPushButton("<- Back", self)
        self.Back.resize(50, 25)
        self.Back.move(0, 425)
        self.Creator = QPushButton("YouTube", self)
        self.Creator.resize(100, 40)
        self.Creator.move(25, 50)
        self.CreatorB2 = QPushButton("Twitter", self)
        self.CreatorB2.resize(100, 40)
        self.CreatorB2.move(275, 50)
        self.CreatorL = QLabel("Created By: PapaKliffy", self)
        self.CreatorL.move(20, 350)

您必须被覆盖
paintEvent

import sys

from PyQt4.QtCore import QSize
from PyQt4.QtGui import QApplication, QPainter, QPixmap, QPushButton, QWidget, QLabel


class UICreator(QWidget):  # |||| CREATOR TAB |||
    def __init__(self, parent=None):
        super(UICreator, self).__init__(parent)
        self.resize(QSize(450, 450))
        self.Back = QPushButton("<- Back", self)
        self.Back.resize(50, 25)
        self.Back.move(0, 425)
        self.Creator = QPushButton("Youtube", self)
        self.Creator.resize(100, 40)
        self.Creator.move(50, 50)
        self.CreatorB2 = QPushButton("Twitter", self)
        self.CreatorB2.resize(100, 40)
        self.CreatorB2.move(275, 50)
        self.CreatorL = QLabel("Created By: PapaKliffy", self)
        self.CreatorL.move(20, 350)

    def paintEvent(self, event):
        painter = QPainter(self)
        painter.drawPixmap(self.rect(), QPixmap("background.jpg"))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = UICreator()
    w.show()
    sys.exit(app.exec_())
导入系统 从PyQt4.QtCore导入QSize 从PyQt4.QtGui导入QApplication、QPaint、QPixmap、QPushButton、QWidget、QLabel 类UICreator(QWidget):#| | | | CREATOR选项卡||| def uuu init uuu(self,parent=None): 超级(UICreator,self)。\uuuu init\uuuuu(父级) 自我调整大小(QSize(450450))
self.Back=QPushButton(“你想把图片放到按钮上吗?因为我看不到任何选项卡。请解释更多信息这就是我所拥有的,我只想在它的后面添加一张图片,不知道怎么做,所以你想添加背景图像吗?”?
import sys

from PyQt4.QtCore import QSize
from PyQt4.QtGui import QApplication, QPainter, QPixmap, QPushButton, QWidget, QLabel


class UICreator(QWidget):  # |||| CREATOR TAB |||
    def __init__(self, parent=None):
        super(UICreator, self).__init__(parent)
        self.resize(QSize(450, 450))
        self.Back = QPushButton("<- Back", self)
        self.Back.resize(50, 25)
        self.Back.move(0, 425)
        self.Creator = QPushButton("Youtube", self)
        self.Creator.resize(100, 40)
        self.Creator.move(50, 50)
        self.CreatorB2 = QPushButton("Twitter", self)
        self.CreatorB2.resize(100, 40)
        self.CreatorB2.move(275, 50)
        self.CreatorL = QLabel("Created By: PapaKliffy", self)
        self.CreatorL.move(20, 350)

    def paintEvent(self, event):
        painter = QPainter(self)
        painter.drawPixmap(self.rect(), QPixmap("background.jpg"))


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = UICreator()
    w.show()
    sys.exit(app.exec_())