[PyQt] QLabel is visible but isVisible() is always false

Katja Wegner k.wegner at herts.ac.uk
Mon Jul 16 19:35:55 BST 2007


sorry, didn't know that.

import sys
from PyQt4.QtGui import *


class Window(QMainWindow):

    def __init__(self, parent):
        QMainWindow.__init__(self)

        gen = General(self)
        gen.addLabel()
        gen.update(1)
        gen.show()

class General(QDialog):
  
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.layout = QVBoxLayout(self)
        self.layout.setMargin(20)
        self.addLabel()
    print "vis=", self.label.isVisible()
   
    def addLabel(self):
        self.label = QLabel("Arc types in the module:")
        self.label.setVisible(0)
    print  "vis=", sself.label.isVisible()
        self.layout.addWidget(self.label)
      
    def update(self, isInModule):
        if isInModule:
          self.label.show()
      print "vis=", s self.label.isVisible()


def main():
    application = QApplication(sys.argv)
    nbWindow = Window(application)
    application.setActiveWindow(nbWindow)
    nbWindow.resize(100, 100)
    nbWindow.show()
    sys.exit(application.exec_())
   
if __name__ == "__main__":
    main()



Andreas Pakulat wrote:
> On 16.07.07 18:05:28, Katja Wegner wrote:
>   
>> First the objects are created with visible = false:
>>     
>
> Thats not a minimal example code that demonstrates the problem. You're
> supposed to post code that can be taken put into a .py file and then
> runs. Often by reducing your code you find a mistake you overlooked, and
> even if not its possible for other people (read: us) to reproduce and
> help you. With just some snippets this is impossible, because we don't
> know what other conditions are met on your system...
>
> Andreas
>
>   


More information about the PyQt mailing list