Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New frames for modify url and delete url #26

Merged
merged 2 commits into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 45 additions & 24 deletions modules/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def main(self):
self.home()
self.add_url()
self.modify_url()
self.create_radio_button()
self.delete_url_tab()
self.create_check_button()

def terminate(self):
close_program = tkinter.Button(self, fg='red', command=self.master.destroy)
Expand All @@ -58,15 +60,14 @@ def home(self):
label_github.pack(side='bottom')

def refresh(self):
self.tab_modify_url.destroy()
self.tab_delete_url.destroy()
self.tab_modify_url = ttk.Frame(self.tab_control)
self.tab_delete_url = ttk.Frame(self.tab_control)
self.tab_control.add(self.tab_modify_url, text='Modify url')
self.tab_control.add(self.tab_delete_url, text='Delete url')
self.tab_control.pack(expand=1, fill='both')
self.modify_url()
self.delete_url_tab()
self.modify_frame.destroy()
self.delete_frame.destroy()
self.modify_frame = tkinter.Frame(self.tab_modify_url)
self.modify_frame.pack(expand=1, fill='both')
self.delete_frame = tkinter.Frame(self.tab_delete_url)
self.delete_frame.pack(expand=1, fill='both')
self.create_radio_button()
self.create_check_button()

def run_script(self):
if len(self.list_of_saved_url) > 0:
Expand Down Expand Up @@ -119,44 +120,64 @@ def modify_url(self):
self.entry_new_css["textvariable"] = self.modify_css
label_modify_css = tkinter.Label(self.tab_modify_url, text='Click url to modify:')
label_modify_css.pack(side='top', anchor='w')
self.button = []
self.modify_frame = tkinter.Frame(self.tab_modify_url)
self.modify_frame.pack(expand=1, fill='both')
button_submit = tkinter.Button(self.tab_modify_url, text='Submit')
button_submit.pack(side='bottom', anchor='s')
button_submit['command'] = self.modify_this_url

def create_radio_button(self):
self.for_modify = []
order = sorted(self.list_of_saved_url)
pos = 1
for index in range(len(order)):
self.button.append(
tkinter.Button(self.tab_modify_url, text=order[index], command=lambda i=index: self.mod_this(order[i])))
self.button[index].pack(anchor='w', fill=tkinter.X)
self.check_var = tkinter.StringVar()
self.for_modify.append(self.check_var)
rb = tkinter.Radiobutton(self.modify_frame, text=f"{pos:02}. {order[index]}",
command=lambda i=index: self.mod_this(order[i]), value=order[index])
rb.pack(anchor='w')
pos += 1

def mod_this(self, url):
box = messagebox.askokcancel(title=None, message=f'Do you want to modify {url}')
if box:
ModifyCssGUI(self.root, self.list_of_saved_url, url, self.modify_css.get())
messagebox.showinfo(title=None, message='Done')
self.mod_this_url = url

def modify_this_url(self):
ModifyCssGUI(self.root, self.list_of_saved_url, self.mod_this_url, self.modify_css.get())
messagebox.showinfo(title='Done', message=f'{self.mod_this_url}\nNew css selected.')

def delete_url_tab(self):
self.delete_frame = tkinter.Frame(self.tab_delete_url)
self.delete_frame.pack(expand=1, fill='both')
submit_button = tkinter.Button(self.tab_delete_url, text='Delete')
submit_button.pack(side='bottom', anchor='s', ipadx=50, ipady=5)
submit_button['command'] = self.delete_only
submit_button = tkinter.Button(self.tab_delete_url, text='Delete all')
submit_button.pack(side='bottom', anchor='s', ipadx=43, ipady=5)
submit_button['command'] = self.delete_all

def create_check_button(self):
self.true_false = []
order = sorted(self.list_of_saved_url)
pos = 1
for index in range(len(order)):
self.true_false.append(tkinter.BooleanVar())
self.true_false[-1].set(False)
c = tkinter.Checkbutton(self.tab_delete_url, text=order[index], variable=self.true_false[-1],
c = tkinter.Checkbutton(self.delete_frame, text=f"{pos:02}. {order[index]}", variable=self.true_false[-1],
command=lambda i=index: self.del_this(i))
c.pack(anchor='w')
submit_button = tkinter.Button(self.tab_delete_url, text='Delete')
submit_button.pack(side='bottom', anchor='s', ipadx=50, ipady=5)
submit_button['command'] = self.delete_only
submit_button = tkinter.Button(self.tab_delete_url, text='Delete all')
submit_button.pack(side='bottom', anchor='s', ipadx=43, ipady=5)
submit_button['command'] = self.delete_all
pos += 1

def delete_only(self):
DeleteUrlGUI(self.root, self.list_of_saved_url, self.for_delete)
self.refresh()
messagebox.showinfo(title='Delete', message='Done')

def delete_all(self):
for url in self.list_of_saved_url:
self.for_delete.append(url)
DeleteUrlGUI(self.root, self.list_of_saved_url, self.for_delete)
self.refresh()
messagebox.showinfo(title='Delete', message='List clear')

def del_this(self, i):
order = sorted(self.list_of_saved_url)
Expand Down