pyqt练习x3.14

import sys

from PyQt4.QtCore import *

from PyQt4.QtGui import *

from PyQt4.QtWebKit import *

class MyBrowser(QWidget):

def __init__(self, parent = None):

super(MyBrowser, self).__init__(parent)

self.createLayout()

self.createConnection()

def search(self):

address = str(self.addressBar.text())

if address:

if address.find(‘://‘) == -1:

address = ‘http://‘ + address

url = QUrl(address)

self.webView.load(url)

def createLayout(self):

self.setWindowTitle("keakon‘s browser")

self.addressBar = QLineEdit()

self.goButton = QPushButton("&GO")

bl = QHBoxLayout()

bl.addWidget(self.addressBar)

bl.addWidget(self.goButton)

self.webView = QWebView()

layout = QVBoxLayout()

layout.addLayout(bl)

layout.addWidget(self.webView)

self.setLayout(layout)

def createConnection(self):

self.connect(self.addressBar, SIGNAL(‘returnPressed()‘), self.search)

self.connect(self.addressBar, SIGNAL(‘returnPressed()‘), self.addressBar, SLOT(‘selectAll()‘))

self.connect(self.goButton, SIGNAL(‘clicked()‘), self.search)

self.connect(self.goButton, SIGNAL(‘clicked()‘), self.addressBar, SLOT(‘selectAll()‘))

app = QApplication(sys.argv)

browser = MyBrowser()

browser.show()

sys.exit(app.exec_())

时间: 2024-08-03 16:09:05

pyqt练习x3.14的相关文章

pyqt练习x3

# -*- coding: utf-8 -*- __author__ = 'Administrator' from PyQt4 import QtCore,Qt,QtGui import sys,time,datetime,os,sched,psutil,wmi from tools import Ui_Form class ExTools(QtGui.QDialog): def __init__(self,parent=None): super(ExTools,self).__init__(p

pyqt练习x3.12

import sys from PyQt4.QtGui import * class Browser(QWidget): def __init__(self): super(Browser, self).__init__() self.resize(700, 600) self.setWindowTitle("File Browser") self.treeView = QTreeView() self.fileSystemModel = QFileSystemModel(self.t

pyqt练习x3.20

#_*_ coding: utf-8 _*_ from PyQt4.QtCore import * from PyQt4.QtGui import * import sys QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) class FindDialog(QDialog): def __init__(self,parent = None): super(FindDialog, self).__init__(parent

pyqt练习x3.13

import time import ctypes import ctypes.wintypes SEE_MASK_NOCLOSEPROCESS = 0x00000040 SEE_MASK_INVOKEIDLIST = 0x0000000C class SHELLEXECUTEINFO(ctypes.Structure): _fields_ = ( ("cbSize",ctypes.wintypes.DWORD), ("fMask",ctypes.c_ulong),

pyqt练习x3.21

#!/usr/bin/env python2 "A web browser that will never exceed 128 lines of code. (not counting blanks)" import sys, os, json, tempfile from PyQt4 import QtGui, QtCore, QtWebKit, QtNetwork settings = QtCore.QSettings("ralsina", "dev

pyqt练习x3。1

# -*- coding: cp936 -*- import sys from PyQt4 import QtGui class MessageBox(QtGui.QWidget): def __init__(self,parent=None): QtGui.QWidget.__init__(self,parent) self.setGeometry(300,300,250,150) self.setWindowTitle(u'你想关闭?') def closeEvent(self,event)

pyqt练习x3.3

# -*- coding: cp936 -*- import sys from PyQt4 import QtGui class Tooltip(QtGui.QWidget): def __init__(self,parent=None): QtGui.QWidget.__init__(self,parent) self.setGeometry(300,300,250,150) self.setWindowTitle(u'屏幕提示内容') self.setToolTip(u'这是什么呢?') Q

pyqt练习x3.11

#!/usr/bin/env python # -*- coding: utf-8 -*- ######################################################################################## #                                                                                      # # Copyright (c) 2009 Jakob

pyqt练习x3.7

# -*- coding: cp936 -*- import sys from PyQt4 import QtGui,QtCore class GridLayout(QtGui.QWidget): def __init__(self,parent=None): QtGui.QWidget.__init__(self) self.setWindowTitle('grid layout') title=QtGui.QLabel('Titel:') authot=QtGui.QLabel('Auhot