Dual Screen

2008-11-24
2013-04-26
  • Jochen Weiss
    Jochen Weiss
    2008-11-24

    Has anyone of you tried to write a small multi-head application ? Just something like typing a text in on screen 0 and display it in fullscreen on screen 1.

    If yes, can you provide the sample code ?

     
    • Speaking for myself, I haven't tried it yet. I wanted to do it but there are some other issues at the moment.

      I also would love to see any sample code ;-)

       
    • celsowm
      celsowm
      2008-11-24

      A good begin is:
         
      import sys,os
      from PyQt4.QtGui  import *
      from PyQt4.QtCore import *

      app = QApplication(sys.argv)

      desktop_widget = QDesktopWidget()
      num_screens = desktop_widget.numScreens()
      print num_screens

       
      • The class  'QDesktopWidget' is responsible for accessing screen information.

        http://doc.trolltech.com/4.4/qdesktopwidget.html

        I haven't the possibility to test dual screen, but this could work:
        --------------------------------------------------------------------------------

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

        secondary_screen_id = 1

        app = QApplication(sys.argv)
        desktop_widget = QDesktopWidget()
        label = QLabel("Hello")

        geometry = desktop_widget.screenGeometry(secondary_screen_id)
        label.setGeometry(geometry)
        label.showMaximized()

         
        • This code works for me in winxp but it's a good idea to add these lines not to see only blinking on the second screen:

          to the imports:

          from time import sleep

          at the end:

          sleep(15)

           
    • Jochen Weiss
      Jochen Weiss
      2008-11-25

      Thanks for your quick answers.

      I hope to find some time during the next days to try this.
      I will post my results, when I was successful

       
    • Jochen Weiss
      Jochen Weiss
      2008-11-26

      Hey, it really works that way ;-)
      I only changed label.showMaximized() to label.showFullScreen ()

      Gonna write a small application with to screens to learn how you can use it for presentations :-)

       
      • When you are done with the small application, are you considering to commit that application into SVN?
        If yes, could you  use in svn directory, which I created?

        /trunk/samples/qt4/multiscreen

        Could you, please, have a look at coding style recomendations?

        http://changingsong.sourceforge.net/wiki/Coding_Style

        Thanks