Skip to content

Instantly share code, notes, and snippets.

@Janderson
Created March 24, 2012 06:34
Show Gist options
  • Select an option

  • Save Janderson/2179082 to your computer and use it in GitHub Desktop.

Select an option

Save Janderson/2179082 to your computer and use it in GitHub Desktop.
Simples WebBrowser python QT
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.ui'
#
# Created: Sat Mar 24 03:20:20 2012
# by: pyside-uic 0.2.11 running on PySide 1.1.0
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui, QtWebKit
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.extra_ui()
self.connectores()
# elementos que não estão presentes no designer mas são elementos visuais
# para nao ser sobreescrito toda vez que voce import o .ui ele está aqui
def extra_ui(self):
self.ui.webview = QtWebKit.QWebView(self.ui.centralWidget)
self.ui.webview.setObjectName("WebView")
self.ui.verticalLayout.addWidget(self.ui.webview)
def connectores(self):
self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.message)
def message(self):
self.ui.webview.load("http://www.google.com.br")
self.ui.webview.show()
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(399, 286)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.gridLayout = QtGui.QGridLayout(self.centralWidget)
self.gridLayout.setObjectName("gridLayout")
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton = QtGui.QPushButton(self.centralWidget)
self.pushButton.setObjectName("pushButton")
self.verticalLayout.addWidget(self.pushButton)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralWidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Abrir Google", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = MainWindow()
MainWindow.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment