将图像添加到选项卡
adding Image to tab
我遇到了另一个问题,也许你们都可以帮忙解决我似乎无法在我的任何标签页中添加照片,你们能帮忙吗?
这是我的代码
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)
这里是主窗口
def startUICreatorTab(self):
self.Creator = UICreator(self)
self.setWindowTitle("Kliffy's SS Tool V2.0 | Creator Tab")
self.setCentralWidget(self.Creator)
self.Creator.Back.clicked.connect(self.startUIWindow)
self.Creator.Creator.clicked.connect(self.Kliffy)
self.Creator.CreatorB2.clicked.connect(self.Kliffy2)
self.show()
你必须被覆盖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_())
background.png:
输出:
我遇到了另一个问题,也许你们都可以帮忙解决我似乎无法在我的任何标签页中添加照片,你们能帮忙吗?
这是我的代码
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)
这里是主窗口
def startUICreatorTab(self):
self.Creator = UICreator(self)
self.setWindowTitle("Kliffy's SS Tool V2.0 | Creator Tab")
self.setCentralWidget(self.Creator)
self.Creator.Back.clicked.connect(self.startUIWindow)
self.Creator.Creator.clicked.connect(self.Kliffy)
self.Creator.CreatorB2.clicked.connect(self.Kliffy2)
self.show()
你必须被覆盖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_())
background.png:
输出: