Created
February 8, 2025 21:14
-
-
Save ByteBlendify/98022d383aa636b01ad5009826a29c0f to your computer and use it in GitHub Desktop.
(BETA TEST) Veloce - PyBrowser — простий браузер на PyQt6 з підтримкою WebEngine. Основні функції: адресний рядок, кнопки "Назад", "Вперед", "Перезавантажити", популярні сайти для швидкого доступу, збереження історії та налаштування інформації про програму.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(BETA TEST) Veloce - PyBrowser — це простий, але потужний браузер, створений за допомогою PyQt6 та PyQtWebEngine. | |
Його основна мета — надати користувачам зручний і легкий у використанні браузер з мінімалістичним інтерфейсом, | |
що включає корисні функції для швидкого доступу до популярних сайтів, перегляду історії та налаштувань. | |
_________________________________________________________________________________________________________________________________ | |
Основні функції включають вбудовану підтримку WebEngine для перегляду веб-сторінок, адресний рядок для введення URL, | |
а також кнопки навігації: "Назад", "Вперед", "Перезавантажити". | |
Користувачі можуть легко переходити між популярними сайтами завдяки списку швидкого доступу, що включає такі сайти, як YouTube, | |
Google, Facebook та інші. | |
_________________________________________________________________________________________________________________________________ | |
Додатково, браузер дозволяє користувачам зберігати історію переглядів та надає налаштування для керування нею. | |
Завдяки налаштуванням можна також отримати інформацію про програму. Veloce - PyBrowser — ідеальний вибір для тих, | |
хто шукає простоту і функціональність в одному додатку. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt6.QtWidgets import ( | |
QApplication, QMainWindow, QVBoxLayout, QHBoxLayout, QWidget, | |
QLineEdit, QPushButton, QListWidget, QDialog, QLabel, QTabWidget | |
) | |
from PyQt6.QtWebEngineWidgets import QWebEngineView | |
from PyQt6.QtCore import QUrl | |
page_1 = "" | |
page_2 = "" | |
page_3 = "" | |
page_4 = "" | |
page_5 = "" | |
page_6 = "" | |
page_7 = "" | |
page_8 = "" | |
page_9 = "" | |
page_10 = "" | |
history = [] | |
historys = "on" | |
def status_history(): | |
global historys | |
if historys == "on": | |
historys = "off" | |
else: | |
historys = "on" | |
other = [ | |
"Анонімний режим", | |
"1" | |
] | |
popular_sites = [ | |
"https://www.youtube.com/", | |
"https://www.google.com/", | |
"https://www.facebook.com/", | |
"https://www.instagram.com/", | |
"https://www.twitter.com/", | |
"https://www.linkedin.com/", | |
"https://www.tiktok.com/", | |
"https://www.reddit.com/", | |
"https://www.pinterest.com/", | |
"https://www.wikipedia.org/", | |
"https://www.amazon.com/", | |
"https://www.ebay.com/", | |
"https://www.etsy.com/", | |
"https://www.aliexpress.com/", | |
"https://www.microsoft.com/" | |
] | |
settings_options = { | |
"Історія": ["history"], | |
"Про програму": ["", "", "0b.3u.12"] | |
} | |
class SettingsDialog(QDialog): | |
def __init__(self, parent=None): | |
super().__init__(parent) | |
self.setWindowTitle("Налаштування") | |
layout = QVBoxLayout() | |
self.settings_list = QListWidget() | |
self.settings_list.addItems(settings_options.keys()) | |
self.settings_list.itemClicked.connect(self.show_option_list) | |
layout.addWidget(self.settings_list) | |
self.setLayout(layout) | |
self.option_list_dialog = QDialog(self) | |
self.option_list = QListWidget() | |
option_list_layout = QVBoxLayout() | |
option_list_layout.addWidget(self.option_list) | |
self.option_list_dialog.setLayout(option_list_layout) | |
def show_option_list(self, item): | |
option_name = item.text() | |
if option_name in settings_options: | |
self.option_list.clear() | |
self.option_list.addItems(settings_options[option_name]) | |
self.option_list_dialog.setWindowTitle(option_name) | |
self.option_list_dialog.show() | |
class SimpleBrowser(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.setWindowTitle("Veloce - PyBrowser") | |
self.setGeometry(100, 100, 800, 600) | |
self.browser = QWebEngineView() | |
#self.browser.setUrl(QUrl("https://www.google.com")) | |
self.url_bar = QLineEdit() | |
self.url_bar.setStyleSheet("padding: 5px; border: 1px solid #ccc;") | |
self.url_bar.returnPressed.connect(self.load_url) | |
self.go_button = QPushButton("Go") | |
self.go_button.setStyleSheet(""" | |
background-color: #4CAF50; | |
color: white; | |
padding: 5px 10px; | |
border: none; | |
border-radius: 3px; | |
""") | |
self.go_button.clicked.connect(self.load_url) | |
self.popular_sites_button_toggle = QPushButton("Популярні сайти") | |
self.popular_sites_button_toggle.setStyleSheet(""" | |
background-color: #2196F3; | |
color: white; | |
padding: 5px 10px; | |
border: none; | |
border-radius: 3px; | |
""") | |
self.popular_sites_button_toggle.clicked.connect(self.toggle_popular_sites) | |
self.other_button = QPushButton("...") | |
self.other_button.setStyleSheet(""" | |
background-color: #5D8AA8; | |
color: white; | |
padding: 5px 10px; | |
border: none; | |
border-radius: 3px; | |
""") | |
self.other_button.clicked.connect(self.other) | |
self.popular_sites_list = QListWidget() | |
self.popular_sites_list.addItems(popular_sites) | |
self.popular_sites_list.setStyleSheet("padding: 5px; border: 1px solid #ccc;") | |
self.popular_sites_list.itemClicked.connect(self.load_popular_site) | |
self.popular_sites_list.setVisible(False) | |
self.settings_button = QPushButton("⚙️") | |
self.settings_button.setStyleSheet(""" | |
background-color: #ddd; | |
border: none; | |
padding: 5px; | |
border-radius: 3px; | |
""") | |
self.settings_button.clicked.connect(self.open_settings) | |
self.reload_button = QPushButton("🔄") | |
self.reload_button.setStyleSheet(""" | |
background-color: #ddd; | |
border: none; | |
padding: 5px; | |
border-radius: 3px; | |
""") | |
#self.reload_button.clicked.connect(self.browser.reload) | |
self.back_button = QPushButton("⬅️") | |
self.back_button.setStyleSheet(""" | |
background-color: #ddd; | |
border: none; | |
padding: 5px; | |
border-radius: 3px; | |
""") | |
self.back_button.clicked.connect(self.browser.back) | |
self.forward_button = QPushButton("➡️") | |
self.forward_button.setStyleSheet(""" | |
background-color: #ddd; | |
border: none; | |
padding: 5px; | |
border-radius: 3px; | |
""") | |
self.forward_button.clicked.connect(self.browser.forward) | |
url_layout = QHBoxLayout() | |
url_layout.addWidget(self.back_button) | |
url_layout.addWidget(self.forward_button) | |
url_layout.addWidget(self.reload_button) | |
url_layout.addWidget(self.url_bar) | |
url_layout.addWidget(self.go_button) | |
url_layout.addWidget(self.popular_sites_button_toggle) | |
url_layout.addWidget(self.other_button) | |
url_layout.addWidget(self.settings_button) | |
main_layout = QVBoxLayout() | |
main_layout.addLayout(url_layout) | |
main_layout.addWidget(self.popular_sites_list) | |
main_layout.addWidget(self.browser) | |
central_widget = QWidget() | |
central_widget.setLayout(main_layout) | |
self.setCentralWidget(central_widget) | |
self.settings_dialog = SettingsDialog(self) | |
def update_url(self, url): | |
self.url_bar.setText(url.toString()) | |
def load_url(self): | |
url = self.url_bar.text() | |
if not url.startswith("http"): | |
url = "https://" + url | |
self.browser.setUrl(QUrl(url)) | |
history.append(url) | |
def toggle_popular_sites(self): | |
self.popular_sites_list.setVisible(not self.popular_sites_list.isVisible()) | |
def load_popular_site(self, item): | |
url = item.text() | |
self.browser.setUrl(QUrl(url)) | |
def other(self): | |
print("...") | |
def open_settings(self): | |
self.settings_dialog.exec() | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
window = SimpleBrowser() | |
window.show() | |
sys.exit(app.exec()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment