tags:

views:

233

answers:

1

In Python and Pyqt - I've got a simple class which instantiates a Label class and a GroupBox class.

According to docs, passing the Groupbox to the Label upon creation should make the Groupbox the parent of Label. However, I must be missing something simple here. When I create the GroupBox it's fine, when I create the Label however - it appears distorted (or perhaps behind the GroupBox?)

Cheers -

from PyQt4.QtCore import * 
from PyQt4.QtGui import *
import sys


class FileBrowser(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setGeometry(0, 0, 920, 780)
        self.initClasses()

    def initClasses(self):
        # GroupBox
        self.groupBox1 = GroupBox(self, QRect(20, 10, 191, 131),  'Shot Info')

        # Label
        self.labelGroup1_ShotInfo = Label(self, QRect(10, 26, 52, 15),  'Film')


class GroupBox(QWidget): 
    def __init__(self, parent,  geo,  title): 
        QWidget.__init__(self, parent)
        obj = QGroupBox(parent)
        obj.setGeometry(geo)
        obj.setTitle(title)

class Label(QWidget): 
    def __init__(self, parent,  geo,  text): 
        QWidget.__init__(self, parent)
        obj = QLabel(parent)
        obj.setGeometry(geo)
        obj.setText(text)



def main(): 
    app = QApplication(sys.argv) 
    w = FileBrowser() 
    w.show() 
    sys.exit(app.exec_()) 

if __name__ == "__main__": 
    main()
+1  A: 
mandel