-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain5.1.py
517 lines (427 loc) · 21.4 KB
/
main5.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# Hello
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!
from hashlib import new
import pickle
import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
from msilib.schema import SelfReg
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtPrintSupport import *
import os
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QInputDialog, QLineEdit, QDialog, QToolBar
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!
class BookMarkToolBar(QtWidgets.QToolBar):
bookmarkClicked = QtCore.pyqtSignal(QtCore.QUrl, str)
def __init__(self, parent=None):
super(BookMarkToolBar, self).__init__(parent)
self.actionTriggered.connect(self.onActionTriggered)
self.bookmark_list = []
def setBoorkMarks(self, bookmarks):
for bookmark in bookmarks:
self.addBookMarkAction(bookmark["title"], bookmark["url"])
def addBookMarkAction(self, title, url):
bookmark = {"title": title, "url": url}
fm = QtGui.QFontMetrics(self.font())
if bookmark not in self.bookmark_list:
text = fm.elidedText(title, QtCore.Qt.ElideRight, 150)
action = self.addAction(text)
action.setData(bookmark)
self.bookmark_list.append(bookmark)
@QtCore.pyqtSlot(QtWidgets.QAction)
def onActionTriggered(self, action):
bookmark = action.data()
self.bookmarkClicked.emit(bookmark["url"], bookmark["title"])
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!
class AboutDialog(QDialog):
def __init__(self, *args, **kwargs):
super(AboutDialog, self).__init__(*args, **kwargs)
QBtn = QDialogButtonBox.Ok # No cancel
self.buttonBox = QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
layout = QVBoxLayout()
title = QLabel("Developer")
font = title.font()
font.setPointSize(20)
title.setFont(font)
layout.addWidget(title)
logo = QLabel()
logo.setPixmap(QPixmap(os.path.join('images', 'ma-icon-128.png')))
layout.addWidget(logo)
layout.addWidget(QLabel("Version 5.0"))
layout.addWidget(QLabel("Copyright 2022 Yash Inclusive"))
for i in range(0, layout.count()):
layout.itemAt(i).setAlignment(Qt.AlignHCenter)
layout.addWidget(self.buttonBox)
self.setLayout(layout)
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.tabs = QTabWidget()
self.tabs.setDocumentMode(True)
self.tabs.tabBarDoubleClicked.connect(self.tab_open_doubleclick)
self.tabs.currentChanged.connect(self.current_tab_changed)
self.tabs.setTabsClosable(True)
self.tabs.tabCloseRequested.connect(self.close_current_tab)
self.setCentralWidget(self.tabs)
self.status = QStatusBar()
self.setStatusBar(self.status)
navtb = QToolBar("Navigation")
navtb.setIconSize(QSize(16, 16))
self.addToolBar(navtb)
navbar2 = QToolBar()
self.addToolBar(navbar2)
back_btn = QAction('⬅', self)
back_btn.setStatusTip("Back to previous page")
back_btn.triggered.connect(lambda: self.tabs.currentWidget().back())
navtb.addAction(back_btn)
next_btn = QAction('➡', self)
next_btn.setStatusTip("Forward to next page")
next_btn.triggered.connect(lambda: self.tabs.currentWidget().forward())
navtb.addAction(next_btn)
reload_btn = QAction(' 🔃 ', self)
reload_btn.setStatusTip("Reload page")
reload_btn.triggered.connect(lambda: self.tabs.currentWidget().reload())
navtb.addAction(reload_btn)
home_btn = QAction(' 📘 ', self)
home_btn.setStatusTip("Go home")
home_btn.triggered.connect(self.navigate_home)
navtb.addAction(home_btn)
navtb.addSeparator()
self.httpsicon = QLabel() # Yes, really!
self.httpsicon.setPixmap(QPixmap(os.path.join('images', 'lock-nossl.png')))
navtb.addWidget(self.httpsicon)
self.urlbar = QLineEdit()
self.urlbar.returnPressed.connect(self.navigate_to_url)
navtb.addWidget(self.urlbar)
stop_btn = QAction(QIcon(os.path.join('images', 'cross-circle.png')), "Stop", self)
stop_btn.setStatusTip("Stop loading current page")
stop_btn.triggered.connect(lambda: self.tabs.currentWidget().stop())
navtb.addAction(stop_btn)
credits = "Credits To Developer Yash"
# Uncomment to disable native menubar on Mac
# self.menuBar().setNativeMenuBar(False)
file_menu = self.menuBar().addMenu("&File")
new_tab_action = QAction(QIcon(os.path.join('images', 'ui-tab--plus.png')), "New Tab", self)
new_tab_action.setStatusTip("Open a new tab")
new_tab_action.triggered.connect(lambda _: self.add_new_tab())
file_menu.addAction(new_tab_action)
open_file_action = QAction(QIcon(os.path.join('images', 'disk--arrow.png')), "Open file...", self)
open_file_action.setStatusTip("Open from file")
open_file_action.triggered.connect(self.open_file)
file_menu.addAction(open_file_action)
save_file_action = QAction(QIcon(os.path.join('images', 'disk--pencil.png')), "Save Page As...", self)
save_file_action.setStatusTip("Save current page to file")
save_file_action.triggered.connect(self.save_file)
file_menu.addAction(save_file_action)
print_action = QAction(QIcon(os.path.join('images', 'printer.png')), "Print...", self)
print_action.setStatusTip("Print current page")
print_action.triggered.connect(self.print_page)
file_menu.addAction(print_action)
help_menu = self.menuBar().addMenu("&Help")
about_action = QAction(QIcon(os.path.join('images', 'question.png')), "About Our Team", self)
about_action.setStatusTip("Find out more about Yash Here!") # Hungry!
about_action.triggered.connect(self.about)
help_menu.addAction(about_action)
navigate_mozarella_action = QAction(QIcon(os.path.join('images', 'lifebuoy.png')),
"About Project", self)
navigate_mozarella_action.setStatusTip("About Developer")
navigate_mozarella_action.triggered.connect(self.navigate_mozarella)
help_menu.addAction(navigate_mozarella_action)
# don't edit these we are watching you! ,As this browser Uses Internet So Be Alerted !!!!
# All Developing Credit Goes
# ============================================================================================
self.add_new_tab(QUrl('https://www.bing.com/?toWww=1&redig=375257EAD25C4BF5AA82551D2405763A'), 'Homepage')
if credits == "Credits To Developer Yash":
print("\n==================================================================================\nDon't Edit This Line! This Line Is Reserved For The Developer Otherwise You May Need To Face Consequences As This Project Use Internet, We can Find You Easily So Don't Change These Lines.\n\n\n\n\n\n\n===============================================================\n")
self.showMaximized()
self.bookmarks_load()
self.setWindowTitle("A Simple Browser")
self.setWindowIcon(QIcon(os.path.join('images', 'ma-icon-64.png')))
# NavBar 2 ==========================================================================================================
new_tab_op = QAction('New Tab➕', self)
new_tab_op.triggered.connect(lambda _: self.add_new_tab())
navbar2.addAction(new_tab_op)
tab2 = QAction('Incognito', self)
tab2.triggered.connect(self.main_tab2)
navbar2.addAction(tab2)
tab1 = QAction('Google', self)
tab1.triggered.connect(self.main_tab1)
navbar2.addAction(tab1)
main4 = QAction('Yandex', self)
main4.triggered.connect(self.main_tab4)
navbar2.addAction(main4)
main5 = QAction('Yahoo', self)
main5.triggered.connect(self.main_tab5)
navbar2.addAction(main5)
new_btn = QAction('Brave', self)
new_btn.triggered.connect(self.navigate_tab)
navbar2.addAction(new_btn)
# =================================================================================================================
# nav bar 2 games and other stuffs
snake_game = QAction('SnakeGame', self)
snake_game.triggered.connect(self.snake_gameop)
navbar2.addAction(snake_game)
main3 = QAction('MusicPlayer', self)
main3.triggered.connect(self.main_tab3)
navbar2.addAction(main3)
new_btn1 = QAction('TicTacToe', self)
new_btn1.triggered.connect(self.navigate_tab1)
navbar2.addAction(new_btn1)
aboutproject1 = QAction('DrawingPad', self)
aboutproject1.triggered.connect(self.aboutproject)
navbar2.addAction(aboutproject1)
ninjagame = QAction('Knife Master', self)
ninjagame.triggered.connect(self.ninjagamebtn)
navbar2.addAction(ninjagame)
bullseye = QAction('Bow Master', self)
bullseye.triggered.connect(self.bullseyef)
navbar2.addAction(bullseye)
flipgame = QAction('Flip Game', self)
flipgame.triggered.connect(self.flipgamef)
navbar2.addAction(flipgame)
rimage = QAction('RandomImage', self)
rimage.triggered.connect(self.randomimagef)
navbar2.addAction(rimage)
welcomepg = QAction('Wlcm. Pg.', self)
welcomepg.triggered.connect(self.welcomepg)
navbar2.addAction(welcomepg)
# ==============================================================================================================
def add_new_tab(self, qurl=None, label="New Tab"):
if qurl is None:
qurl = QUrl('https://www.bing.com/?toWww=1&redig=375257EAD25C4BF5AA82551D2405763A')
browser = QWebEngineView()
browser.setUrl(qurl)
browser.adjustSize()
i = self.tabs.addTab(browser, label)
self.tabs.setCurrentIndex(i)
# More difficult! We only want to update the url when it's from the
# correct tab
browser.urlChanged.connect(lambda qurl, browser=browser:
self.update_urlbar(qurl, browser))
browser.loadFinished.connect(lambda _, i=i, browser=browser:
self.tabs.setTabText(i, browser.page().title()))
def tab_open_doubleclick(self, i):
if i == -1: # No tab under the click
self.add_new_tab()
def current_tab_changed(self, i):
qurl = self.tabs.currentWidget().url()
self.update_urlbar(qurl, self.tabs.currentWidget())
self.update_title(self.tabs.currentWidget())
def close_current_tab(self, i):
if self.tabs.count() < 2:
return
self.tabs.removeTab(i)
def update_title(self, browser):
if browser != self.tabs.currentWidget():
# If this signal is not from the current tab, ignore
return
title = self.tabs.currentWidget().page().title()
self.setWindowTitle("%s - A Simple Browser" % title)
def navigate_mozarella(self):
self.tabs.currentWidget().setUrl(QUrl("https://yash.brizy.site/"))
def about(self):
dlg = AboutDialog()
dlg.exec_()
def open_file(self):
filename, _ = QFileDialog.getOpenFileName(self, "Open file", "",
"Hypertext Markup Language (*.htm *.html);;"
"All files (*.*)")
if filename:
with open(filename, 'r') as f:
html = f.read()
self.tabs.currentWidget().setHtml(html)
self.urlbar.setText(filename)
def save_file(self):
filename, _ = QFileDialog.getSaveFileName(self, "Save Page As", "",
"Hypertext Markup Language (*.htm *html);;"
"All files (*.*)")
if filename:
html = self.tabs.currentWidget().page().toHtml()
with open(filename, 'w') as f:
f.write(html.encode('utf8'))
def print_page(self):
dlg = QPrintPreviewDialog()
dlg.paintRequested.connect(self.browser.print_)
dlg.exec_()
def navigate_home(self):
self.tabs.currentWidget().setUrl(QUrl("https://www.bing.com/?toWww=1&redig=375257EAD25C4BF5AA82551D2405763A"))
def navigate_to_url(self): # Does not receive the Url
q = QUrl(self.urlbar.text())
if q.scheme() == "":
q.setScheme("http")
self.tabs.currentWidget().setUrl(q)
def update_urlbar(self, q, browser=None):
if browser != self.tabs.currentWidget():
# If this signal is not from the current tab, ignore
return
if q.scheme() == 'https':
# Secure padlock icon
self.httpsicon.setPixmap(QPixmap(os.path.join('images', 'lock-ssl.png')))
else:
# Insecure padlock icon
self.httpsicon.setPixmap(QPixmap(os.path.join('images', 'lock-nossl.png')))
self.urlbar.setText(q.toString())
self.urlbar.setCursorPosition(0)
# =================================================================================================================
# navbar2 functions ===============================================================================================
def navigate_home(self):
self.tabs.currentWidget().setUrl(QUrl('https://google.com'))
def navigate_tab(self):
self.tabs.currentWidget().setUrl(QUrl('https://search.brave.com'))
def navigate_tab1(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/tictactoeop'))
def main_tab1(self):
self.tabs.currentWidget().setUrl(QUrl('https://google.com'))
def main_tab2(self):
self.tabs.currentWidget().setUrl(QUrl('https://duckduckgo.com'))
def main_tab3(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/musicplayeropyash'))
def main_tab4(self):
self.tabs.currentWidget().setUrl(QUrl('https://yandex.com/'))
def main_tab5(self):
self.tabs.currentWidget().setUrl(QUrl('https://in.search.yahoo.com/?fr2=inr'))
def aboutproject(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/drawingpadbyyash'))
def ninjagamebtn(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/ninjagamebtn'))
def bullseyef(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/bullseyegameop'))
def flipgamef(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/flipgameop'))
def randomimagef(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/randomimagebyyash'))
def snake_gameop(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/snakegameopbyyash'))
def welcomepg(self):
self.tabs.currentWidget().setUrl(QUrl('https://bit.ly/bgwithclock'))
# =========================================================================================
def Bookmark(self):
try:
qurl = QUrl(self.urlbar.text())
print('Here we are using the QUrl toString method: %s ---> Type: %s' % (qurl.toString(), type(qurl)))
url = qurl.toString()
print('Here we are storing the new string to a new variable: %s ---> Type: %s' % (url, type(url)))
b = open(os.path.join('bookmarks', 'bookmarks.txt'), "wb")
self.bookmarks_write = pickle.dump(url, b)
b.close()
except:
print("Crash - Bookmarks not stored")
self.bookmark_btn.setText("★")
def bookmarks_load(self):
try:
bookmarks_open = open(os.path.join('bookmarks', 'bookmarks.txt'), 'rb')
self.bookmarks_write = pickle.load(bookmarks_open)
bookmarks_open.close()
self.create_bookmarks()
except:
bookmarks_open = open(os.path.join('bookmarks', 'bookmarks.txt'), 'wb')
bookmarks = ''
self.bookmarks_write = pickle.dump(bookmarks, bookmarks_open)
bookmarks_open.close()
self.create_bookmarks()
print('Crash - Did not load bookmarks')
def create_bookmarks(self):
bookmark_list = []
try:
for book in self.bookmarks_write.split():
print(book)
bookmark_list.append(book)
print(bookmark_list)
except:
print("Something went wrong with the list")
try:
button = QAction(QIcon(os.path.join('images', 'tab_icon.PNG')), 'Open bookmark', self)
button.triggered.connect(self.add_new_tab(QUrl(bookmark_list[0]), 'New'))
self.bookmark_bar.addAction(button)
except:
print('Button is causing the error')
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!
# dark theme============================================
# Now use a palette to switch to dark colors:
palette = QPalette()
palette.setColor(QPalette.Window, QColor(53, 53, 53))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(25, 25, 25))
palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
palette.setColor(QPalette.ToolTipBase, Qt.black)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(53, 53, 53))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Link, QColor(42, 130, 218))
palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
palette.setColor(QPalette.HighlightedText, Qt.black)
# For Dark Theme=======================================
app = QApplication(sys.argv)
app.setStyle("Fusion") #for dark theme
app.setPalette(palette) #for dark theme
app.setApplicationName("Browser For Coders")
app.setOrganizationName("Yash IS OP")
app.setOrganizationDomain("https://yash.brizy.site/")
window = MainWindow()
app.exec_()
'''
Thanks This Is Yash "The One And Only Developer Of This Python Project
Credits:-
1st Thanks @Programming Hero For The GUI Of PyQt5
2nd Thanks To All Of The Creators Of Games And Other Stuff Like Music Player,Game, etc .. For Letting Me Use This
3rd All The Songs That Is Used In Music Player By [CWH] Credit Goers To Their Respective Singers.
================== Modified By {IF U DO ANY MODIFICATIONS WRITE YOUR NAME HERE } =========Thanks For Mod.
'''
# Don't Delete this Line This Is Just A Commnet If U Delete This Lines U Have No Longer Rights To Use This Project Anywhere
# Thank You!