如何将标签从另一个脚本类显示到主脚本类

时间:2018-12-26 16:32:24

标签: python pyqt5

我有创建窗口的主脚本。我还有另一个脚本需要创建球(导入的图片)并将其放置在创建的窗口中。当我将“ bubble”类导入主脚本并调用show时,没有创建ball。

我尝试继承QWidget和QLabel类并将其调用为主类,但仍然没有任何反应

-主脚本类-

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

    self.__init_ui__()

def __init_ui__(self):
    self.setGeometry(400, 200, 1050, 700)
    self.setWindowTitle('Bubble trouble')
    self.bubble = Bubble()
    self.show()

-气泡脚本类-

class Bubble(QLabel):
def __init__(self):
    super().__init__()

    self.pix1 = QPixmap('rball6.bmp')
    self.label = QLabel()
    self.label.setPixmap(self.pix1)
    self.label.setGeometry(850, 40, 50, 50)

我要在创建的窗口中显示气泡(气泡的图片)

0 个答案:

没有答案