Skip to content

Commit e68de06

Browse files
Merge pull request #2 from Geoffrey-Hash/ChangeReadme
Added Bookmarks and User Manuel.
2 parents 5ffb768 + 920016d commit e68de06

File tree

7 files changed

+223
-54
lines changed

7 files changed

+223
-54
lines changed

Python_Browser/Readme.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Simple Web Browser Using Python
2+
- This is a GUI Based Web Browser Using PyQt5 & PyQtWebEngine Modules.
3+
4+
## Install Dependencies:
5+
```
6+
pip install PyQt5
7+
```
8+
```
9+
pip install PyQtWebEngine
10+
```
11+
12+
User Manual:
13+
14+
the recommended installation procedure is to copy the "Python Browser" folder to wherever you desire, documents is recommended
15+
and then make a shortcut to "Web_Broswer.py" and place the Shortcut into you Desktop folder.
16+
17+
opening the program presents you with a website, a search bar, and two menus.
18+
19+
1. The website the browser opens to is your Start page.
20+
21+
2. the search bar is not google, use it only when you have the FULL address of the web page you are looking for
22+
23+
3. the top and white menu contains your bookmarked pages as well as the ability to change your preferred Start and Search pages
24+
25+
4. the bottom gray menu contains many basic function like Forward, Back, and Reload but also links to your Start and Search pages
26+
as well as a link to the github of this programs original creator
27+
28+
5. Start, Search, and all Bookmarked pages default to the google homepage
29+
30+
Creator: sagargoswami2001
31+
Contributors: Geoffrey_Hash

Python_Browser/Readme.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Requirements and Installation:
2+
1. pip install PyQt5
3+
2. pip install PyQtWebEngine
4+
the recommended installation procedure is to copy the "Python Browser" folder to wherever you desire, documents is recommended
5+
and then make a shortcut to "Web_Broswer.py" and place the Shortcut into you Desktop folder.
6+
7+
User Manual:
8+
opening the program presents you with a website, a search bar, and two menus.
9+
10+
1. The website the browser opens to is your Start page.
11+
12+
2. the search bar is not google, use it only when you have the FULL address of the web page you are looking for
13+
14+
3. the top and white menu contains your bookmarked pages as well as the ability to change your preferred Start and Search pages
15+
16+
4. the bottom gray menu contains many basic function like Forward, Back, and Reload but also links to your Start and Search pages
17+
as well as a link to the github of this programs original creator
18+
19+
5. Start, Search, and all Bookmarked pages default to the google homepage

Python_Browser/Web_Browser.py

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import sys
2+
from PyQt5.QtCore import *
3+
from PyQt5.QtWidgets import *
4+
from PyQt5.QtWebEngineWidgets import *
5+
import os
6+
7+
8+
class MainWindow(QMainWindow):
9+
def __init__(self):
10+
#init browser and window
11+
super(MainWindow, self).__init__()
12+
self.browser = QWebEngineView()
13+
self.browser.setUrl(QUrl('http://google.com'))
14+
self.setCentralWidget(self.browser)
15+
self.showMaximized()
16+
17+
#get current directory
18+
self.savedurl = 'http://google.com'
19+
self.dir = os.getcwd()
20+
self.savepath = os.path.join(self.dir, 'Web_saves\\Full_Settings.txt')
21+
22+
#add toolbar
23+
navbar = QToolBar()
24+
self.addToolBar(navbar)
25+
26+
#make buttons
27+
back_btn = QAction('Back', self)
28+
back_btn.triggered.connect(self.browser.back)
29+
navbar.addAction(back_btn)
30+
31+
forward_btn = QAction('Forward', self)
32+
forward_btn.triggered.connect(self.browser.forward)
33+
navbar.addAction(forward_btn)
34+
35+
reload_btn = QAction('Reload', self)
36+
reload_btn.triggered.connect(self.browser.reload)
37+
navbar.addAction(reload_btn)
38+
39+
start_btn = QAction('Start', self)
40+
start_btn.triggered.connect(lambda: self.load_url(c=4))
41+
navbar.addAction(start_btn)
42+
43+
search_btn = QAction('Search', self)
44+
search_btn.triggered.connect(lambda: self.load_url(c=5))
45+
navbar.addAction(search_btn)
46+
47+
home_btn = QAction('Creator', self)
48+
home_btn.triggered.connect(self.navigate_home)
49+
navbar.addAction(home_btn)
50+
51+
save_btn_1 = QAction('As Bookmark 1', self)
52+
save_btn_1.triggered.connect(lambda: self.save_url(c=1))
53+
save_btn_2 = QAction('As Bookmark 2', self)
54+
save_btn_2.triggered.connect(lambda: self.save_url(c=2))
55+
save_btn_3 = QAction('As Bookmark 3', self)
56+
save_btn_3.triggered.connect(lambda: self.save_url(c=3))
57+
startset_btn = QAction('As Start', self)
58+
startset_btn.triggered.connect(lambda: self.save_url(c=4))
59+
searchset_btn = QAction('As Search', self)
60+
searchset_btn.triggered.connect(lambda: self.save_url(c=5))
61+
62+
load_btn_1 = QAction('Load Bookmark 1', self)
63+
load_btn_1.triggered.connect(lambda: self.load_url(c=1))
64+
load_btn_2 = QAction('Load Bookmark 2', self)
65+
load_btn_2.triggered.connect(lambda: self.load_url(c=2))
66+
load_btn_3 = QAction('Load Bookmark 3', self)
67+
load_btn_3.triggered.connect(lambda: self.load_url(c=3))
68+
69+
#add bookmark menu
70+
Save_File_Menu = self.menuBar()
71+
Save_File_Save = Save_File_Menu.addMenu("Save Page")
72+
Save_File_Save.addAction(save_btn_1)
73+
Save_File_Save.addAction(save_btn_2)
74+
Save_File_Save.addAction(save_btn_3)
75+
Save_File_Save.addAction(startset_btn)
76+
Save_File_Save.addAction(searchset_btn)
77+
78+
Save_File_Load = Save_File_Menu.addMenu("Load Bookmark")
79+
Save_File_Load.addAction(load_btn_1)
80+
Save_File_Load.addAction(load_btn_2)
81+
Save_File_Load.addAction(load_btn_3)
82+
83+
#add the search bar
84+
self.url_bar = QLineEdit()
85+
self.url_bar.returnPressed.connect(self.navigate_to_url)
86+
navbar.addWidget(self.url_bar)
87+
88+
#setup browser for start
89+
self.browser.urlChanged.connect(self.update_url)
90+
self.load_url(c=4, seturl=True)
91+
92+
93+
def navigate_home(self):
94+
"""Sets Url to Creators GitHub"""
95+
self.browser.setUrl(QUrl('https://github.com/sagargoswami2001'))
96+
97+
def navigate_to_url(self):
98+
"""Sets Url to the clicked link"""
99+
url = self.url_bar.text()
100+
self.savedurl = url
101+
self.browser.setUrl(QUrl(url))
102+
103+
def update_url(self, q):
104+
"""Sets Url to the entered text string"""
105+
self.savedurl = q.toString()
106+
self.url_bar.setText(q.toString())
107+
108+
def save_url(self, c=3):
109+
"""Saves Url to txt file"""
110+
with open(self.savepath, "r") as f:
111+
lines = f.readlines()
112+
with open(self.savepath, "w") as f:
113+
for number, line in enumerate(lines):
114+
if number ==(c):
115+
f.write(self.savedurl + '\n')
116+
else:
117+
f.write(line)
118+
119+
120+
def load_url(self, c=3, seturl=False):
121+
"""Loads Url from txt file"""
122+
with open(self.savepath, 'r') as f:
123+
for i in range(c):
124+
f.readline()
125+
c=f.readline()
126+
c=c.rstrip('\n')
127+
self.browser.setUrl(QUrl(c))
128+
if seturl:
129+
self.savedurl = c
130+
131+
132+
133+
134+
135+
136+
137+
app = QApplication(sys.argv)
138+
QApplication.setApplicationName("Sagar's Browser")
139+
window = MainWindow()
140+
app.exec_()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
https://www.google.com/
3+
https://www.google.com/
4+
https://www.google.com/
5+
https://www.google.com/
6+
https://www.google.com/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
https://www.google.com/
3+
https://www.google.com/
4+
https://www.google.com/
5+
https://www.google.com/
6+
https://www.google.com/

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,24 @@ pip install PyQt5
88
```
99
pip install PyQtWebEngine
1010
```
11+
12+
User Manual:
13+
14+
the recommended installation procedure is to copy the "Python Browser" folder to wherever you desire, documents is recommended
15+
and then make a shortcut to "Web_Broswer.py" and place the Shortcut into you Desktop folder.
16+
17+
opening the program presents you with a website, a search bar, and two menus.
18+
19+
1. The website the browser opens to is your Start page.
20+
21+
2. the search bar is not google, use it only when you have the FULL address of the web page you are looking for
22+
23+
3. the top and white menu contains your bookmarked pages as well as the ability to change your preferred Start and Search pages
24+
25+
4. the bottom gray menu contains many basic function like Forward, Back, and Reload but also links to your Start and Search pages
26+
as well as a link to the github of this programs original creator
27+
28+
5. Start, Search, and all Bookmarked pages default to the google homepage
29+
30+
Creator: sagargoswami2001
31+
Contributors: Geoffrey_Hash

Web_Browser.py

-54
This file was deleted.

0 commit comments

Comments
 (0)