mirror of
https://github.com/sloumdrone/burrow
synced 2024-06-14 04:56:37 +00:00
Working search has been added
This commit is contained in:
parent
55ae2da06b
commit
6e59a58777
39
gui.py
39
gui.py
|
@ -11,6 +11,7 @@ import os.path
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
import webbrowser as wb
|
import webbrowser as wb
|
||||||
|
from urllib import parse as url_encode
|
||||||
|
|
||||||
class GUI:
|
class GUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -21,6 +22,7 @@ class GUI:
|
||||||
self.read_config()
|
self.read_config()
|
||||||
self.conn = conn()
|
self.conn = conn()
|
||||||
self.parser = parser()
|
self.parser = parser()
|
||||||
|
self.search = None
|
||||||
|
|
||||||
#colors
|
#colors
|
||||||
self.FG = '#E0E2E4'
|
self.FG = '#E0E2E4'
|
||||||
|
@ -148,18 +150,19 @@ class GUI:
|
||||||
else:
|
else:
|
||||||
return False #error handling goes here
|
return False #error handling goes here
|
||||||
|
|
||||||
if parsed_url['type'] == 7:
|
self.populate_url_bar(url)
|
||||||
|
|
||||||
|
if history:
|
||||||
|
self.add_to_history(url)
|
||||||
|
|
||||||
|
if parsed_url['type'] == '7':
|
||||||
|
self.show_search()
|
||||||
return False # display search
|
return False # display search
|
||||||
else:
|
else:
|
||||||
data = self.execute_address(parsed_url)
|
data = self.execute_address(parsed_url)
|
||||||
if not data:
|
if not data:
|
||||||
return False #error handling goes here
|
return False #error handling goes here
|
||||||
|
|
||||||
self.populate_url_bar(url)
|
|
||||||
|
|
||||||
if history:
|
|
||||||
self.add_to_history(url)
|
|
||||||
|
|
||||||
self.send_to_screen(self.conn.raw_response,self.conn.filetype)
|
self.send_to_screen(self.conn.raw_response,self.conn.filetype)
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,7 +230,7 @@ class GUI:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
self.entry_url.delete(0, tk.END)
|
self.entry_url.delete(0, tk.END)
|
||||||
self.entry_url.insert(tk.END, 'home')
|
self.entry_url.insert(tk.END, 'home')
|
||||||
if event is not False:
|
if event:
|
||||||
self.add_to_history('home')
|
self.add_to_history('home')
|
||||||
self.send_to_screen(data, '1')
|
self.send_to_screen(data, '1')
|
||||||
|
|
||||||
|
@ -258,6 +261,28 @@ class GUI:
|
||||||
#soon add code to load in favorites here
|
#soon add code to load in favorites here
|
||||||
self.send_to_screen(data=header, clear=False)
|
self.send_to_screen(data=header, clear=False)
|
||||||
|
|
||||||
|
def show_search(self):
|
||||||
|
text1 = ' __ ___ __ __\n/__` |__ /\ |__) / ` |__|\n.__/ |___ /~~\ | \ \__, | |\n\n\nPlease enter your search terms and press the enter key:\n\n'
|
||||||
|
self.search = tk.Entry(width='50')
|
||||||
|
self.search.bind('<Return>', self.query_search_engine)
|
||||||
|
self.site_display.config(state=tk.NORMAL)
|
||||||
|
self.site_display.delete(1.0, tk.END)
|
||||||
|
self.site_display.insert(tk.END,text1)
|
||||||
|
self.site_display.window_create(tk.END,window=self.search)
|
||||||
|
self.site_display.config(state=tk.DISABLED)
|
||||||
|
|
||||||
|
|
||||||
|
def query_search_engine(self, event):
|
||||||
|
base_url = self.entry_url.get()
|
||||||
|
base_url = base_url.replace('/7/','/1/',1)
|
||||||
|
query = self.search.get()
|
||||||
|
url = '{}\t{}'.format(base_url,query)
|
||||||
|
self.populate_url_bar(url)
|
||||||
|
self.handle_request(False, url)
|
||||||
|
self.search = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def show_menu(self, data, clear=True):
|
def show_menu(self, data, clear=True):
|
||||||
if not data:
|
if not data:
|
||||||
#error handling will go here
|
#error handling will go here
|
||||||
|
|
Loading…
Reference in New Issue
Block a user