Lo mismo, pero en PyQt4 (probado sólo en Windoze):

-aah

# -*- coding: utf-8 -*-

from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui  import *

import sys

# define a custom widget
class MyWidget(QWidget):

        def __init__(self, parent=None):
                QWidget.__init__(self, parent)

                button = QPushButton("Which screen?", self)
                button.clicked.connect(self.onClick)

        def onClick(self):
                print '"%s" is running on screen: %d' % \
                        (self.windowTitle(), qApp.desktop().screenNumber(self))

# create a first widget
a = QApplication(sys.argv)
w = MyWidget()
w.setWindowTitle("Hello, world!")
w.resize(320, 240)
w.show()

d = a.desktop()

screen_nr = d.screenCount()
if screen_nr > 1:
        # create a second widget
        w2 = MyWidget()
        w2.setWindowTitle("Goodbye, cruel world...")
        w2.resize(300, 200)
        w2.show()
        # move to the secondary screen
        p = d.screenGeometry(1).topLeft()
        w2.move(p + w2.pos())

print "Number of screens:", screen_nr

sys.exit(a.exec_())

# EOF
_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a