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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# -*- coding: utf-8 -*-
from PyQt4 import QtGui, QtCore, QtSql, QtWebKit
class WClient(QtGui.QWidget):
def __init__(self, parent=None):
super(WClient,self).__init__(parent)
self.setLayout(QtGui.QGridLayout())
self.gBox = QtGui.QGroupBox()
self.gBox.setLayout(QtGui.QGridLayout())
self.labNom1 = QtGui.QLabel(u"Nom1 :")
self.labNom2 = QtGui.QLabel(u"Nom2 :")
self.labAdresse = QtGui.QLabel(u"Adresse :")
self.labCP = QtGui.QLabel(u"Code Postal :")
self.labVille = QtGui.QLabel(u"Localité :")
self.linNom1 = QtGui.QLineEdit()
self.linNom2 = QtGui.QLineEdit()
self.linAdresse = QtGui.QLineEdit()
self.linCP = QtGui.QLineEdit()
self.linCP.setFixedWidth(50)
self.linVille = QtGui.QLineEdit()
#self.linNom1.setReadOnly(True)
#self.linNom2.setReadOnly(True)
#self.linAdresse.setReadOnly(True)
#self.linCP.setReadOnly(True)
#self.linVille.setReadOnly(True)
self.gBox.layout().addWidget(self.labNom1,0,0,1,1)
self.gBox.layout().addWidget(self.linNom1,0,1,1,3)
self.gBox.layout().addWidget(self.labNom2,1,0,1,1)
self.gBox.layout().addWidget(self.linNom2,1,1,1,3)
self.gBox.layout().addWidget(self.labAdresse,2,0,1,1)
self.gBox.layout().addWidget(self.linAdresse,2,1,1,3)
self.gBox.layout().addWidget(self.labCP,3,0,1,1)
self.gBox.layout().addWidget(self.linCP,3,1,1,1)
self.gBox.layout().addWidget(self.labVille,3,2,1,1)
self.gBox.layout().addWidget(self.linVille,3,3,1,1)
self.gBox.layout().setRowStretch(4,2)
self.gBox.layout().setSpacing(15)
self.butUrl = QtGui.QPushButton(u"Go!")
self.webView = QtWebKit.QWebView()
# configure viewhtml (interdire 'JavaEnabled' => plante le programme!))
reglage = self.webView.settings()
# activer javascript
reglage.setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True)
reglage.setAttribute(QtWebKit.QWebSettings.JavascriptCanOpenWindows, True)
reglage.setAttribute(QtWebKit.QWebSettings.JavascriptCanAccessClipboard, True)
# activer les plugins
reglage.setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True)
# fait que les couleurs et motifs de fond de page ne seront pas imprimés
reglage.setAttribute(QtWebKit.QWebSettings.PrintElementBackgrounds, False)
self.layout().addWidget(self.gBox)
self.layout().addWidget(self.butUrl)
self.layout().addWidget(self.webView)
html= '<div style="width:425px;height:350px"><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=Tournai&ie=UTF8&z=12&t=m&iwloc=near&output=embed"></iframe><br><table width="425" cellpadding="0" cellspacing="0" border="0"><tr><td align="left"><small><a href="http://maps.google.com/maps?f=q&source=s_q&hl=fr&geocode=&q=Tournai&ie=UTF8&z=12&t=m&iwloc=near">Agrandir le plan</a></small></td><td align="right"><small><a href="http://www.embedgooglemap.com">embed google map</a></small></td></tr></table></div>'
self.webView.setHtml(html)
if __name__=='__main__':
import sys
app=QtGui.QApplication(sys.argv)
fen = WClient()
fen.show()
sys.exit(app.exec_()) |
Partager