Ana Sayfa yazılım Python ile web tarayıcısı yapmak Python ile web tarayıcısı yapmak Author - personEgehan KAHRAMAN Ocak 05, 2023 share Python web browser yapmakResimdeki gibi tarayıcı olacak yeni sekme açabilme vskodlar import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication, QWidget,QTabWidget,QPushButton, QVBoxLayout, QHBoxLayout, QLineEdit, QPushButton from PyQt5.QtWebEngineWidgets import QWebEngineView class Browser(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): i = 0 self.setWindowTitle("VastSea Browser 1.0") self.setStyleSheet("background-color: gray;") # Create the QWebEngineView self.view = QWebEngineView() self.view.load(QUrl("https://www.google.com")) # Create the URL bar self.url_bar = QLineEdit() # Create the back, forward, and refresh buttons self.back_button = QPushButton("Geri") self.forward_button = QPushButton("İleri") self.refresh_button = QPushButton("Sayfa") # Create the tab widget self.tabs = QTabWidget() self.new_tab_button = QPushButton("+") # Connect the new tab button to the addTab slot self.new_tab_button.clicked.connect(self.addTab) # Add an action to the back button self.back_button.clicked.connect(self.view.back) # Add an action to the forward button self.forward_button.clicked.connect(self.view.forward) # Add an action to the refresh button self.refresh_button.clicked.connect(self.view.reload) # Add an action to the URL bar self.url_bar.returnPressed.connect(self.browse) # Create the layout layout = QVBoxLayout() # Create the navigation bar layout nav_bar = QHBoxLayout() nav_bar.addWidget(self.back_button) nav_bar.addWidget(self.forward_button) nav_bar.addWidget(self.refresh_button) nav_bar.addWidget(self.url_bar) nav_bar.addWidget(self.new_tab_button) # Add the navigation bar and the QWebEngineView to the layout layout.addLayout(nav_bar) layout.addWidget(self.tabs) # Set the layout self.setLayout(layout) def addTab(self): # Create a new tab tab = QWidget() view = QWebEngineView() view.load(QUrl("https://www.google.com")) layout = QVBoxLayout() layout.addWidget(view) tab.setLayout(layout) # Add the tab to the tab widget self.tabs.addTab(tab, f"Yeni sekme " ) def browse(self): # Get the URL from the URL bar url = self.url_bar.text() # If the URL doesn't start with "http://" or "https://", add "http://" to the beginning if not url.startswith("http://") and not url.startswith("https://"): url = "http://" + url # Load the URL self.view.load(QUrl(url)) app = QApplication(sys.argv) browser = Browser() browser.show() sys.exit(app.exec_()) Yukarıdaki kodları main.py isimli dosya açıp yapıştıyoruz!Uyarı gerekli kütüphaneler yüklü olması gerekir Tags pyqt5pythonwebyazılım Facebook Twitter Whatsapp Daha yeni Daha eski