1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| import urllib2
import sys
from PyQt4 import QtGui, QtCore
class Popup(QtGui.QApplication):
def __init__(self, arg):
QtGui.QApplication.__init__(self, arg)
self.main = QtGui.QMainWindow()
self.main.resize(QtCore.QSize(500, 150))
self.main.setMaximumSize(300, 150)
self.label = QtGui.QLabel("ERREUR : Serveur indisponible", self.main)
self.label.setGeometry(20, 30, 200, 35)
self.bouton = QtGui.QPushButton(QtCore.QString('OK'), self.main)
self.bouton.setGeometry(50, 80, 100, 35)
self.bouton.connect(self.bouton, QtCore.SIGNAL("clicked()"), self.ok)
self.bouton.show()
self.main.show()
def ok(self):
self.main.destroy()
class Connect(object):
def __init__(self, url):
self.url = url
self.connecter()
def connecter(self):
try:
url = urllib2.urlopen(self.url)
return True
except urllib2.URLError:
return False
if __name__ == '__main__':
c = Connect('http://www.jfdljfdl.html')
if not c.connecter():
app = Popup(sys.argv)
app.exec_() |
Partager