You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
826 B
30 lines
826 B
import sys |
|
from PyQt5.QtCore import QUrl |
|
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget |
|
from PyQt5.QtWebEngineWidgets import QWebEngineView |
|
|
|
class WebBrowserWindow(QMainWindow): |
|
def __init__(self): |
|
super().__init__() |
|
|
|
self.browser = QWebEngineView() |
|
self.browser.setUrl(QUrl("https://www.qq.com")) # 设置要打开的网页 |
|
|
|
layout = QVBoxLayout() |
|
layout.addWidget(self.browser) |
|
|
|
central_widget = QWidget() |
|
central_widget.setLayout(layout) |
|
|
|
self.setCentralWidget(central_widget) |
|
self.setWindowTitle("Web Browser") |
|
self.setGeometry(100, 100, 800, 600) |
|
|
|
def main(): |
|
app = QApplication(sys.argv) |
|
window = WebBrowserWindow() |
|
window.show() |
|
sys.exit(app.exec_()) |
|
|
|
if __name__ == "__main__": |
|
main() |