Skip to content

Commit

Permalink
Add right click to add to exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
nekooooooooo committed Apr 4, 2023
1 parent 888be45 commit 32aea27
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions utils/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(self, master, **kwargs):
self.steamid_entry = ctk.CTkEntry(self.tab("SteamID"), placeholder_text="SteamID32, URL, or Custom URL")
self.steamid_entry.grid(row=1, column=1, padx=10, pady=10, sticky="nsew")


def select_file(self):
# Open a file dialog to select a file
filepath = filedialog.askopenfilename()
Expand All @@ -49,6 +48,7 @@ def select_file(self):
self.filepath_entry.delete(0, ctk.END)
self.filepath_entry.insert(0, filepath)


class InputsFrame(ctk.CTkFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
Expand Down Expand Up @@ -83,13 +83,13 @@ def __init__(self, master, **kwargs):
self.exclusions_entry = ctk.CTkEntry(self, placeholder_text="Use game app id, separate with comma")
self.exclusions_entry.grid(row=4, column=0, columnspan=3, padx=10, pady=(0, 10), sticky="nsew")


def callback(self, P):
if str.isdigit(P) or P == "":
return True
else:
return False


class OutputsFrame(ctk.CTkScrollableFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
Expand All @@ -111,7 +111,7 @@ def __init__(self, master, **kwargs):
self.output_tree = ttk.Treeview(self, columns=self.columns, show='tree', style="wishlist.Treeview")
self.output_tree.tag_configure('odd', background='#212121')
self.output_tree.tag_configure('even', background='#181818')
ToolTip(self.output_tree, msg="Double click to open link", delay=0.5) # True by default
ToolTip(self.output_tree, msg="Double click to open link\nRight click to add to exclusions", delay=1.0) # True by default

# Define the columns
self.output_tree.heading('appid', text='AppID')
Expand All @@ -128,16 +128,17 @@ def __init__(self, master, **kwargs):
self.output_tree.column("url", width=0, stretch="no")

self.output_tree.bind("<Double-1>", self.open_link)


def open_link(self, event):
item = self.output_tree.focus()
if item:
name = self.output_tree.item(item)['values'][1]
url = self.output_tree.item(item)['values'][4]
answer = messagebox.askyesno("Open Link", f"Do you want to open the link in a browser?\n{name}\n{url}")
if answer:
webbrowser.open(url)
if not item:
return

name = self.output_tree.item(item)['values'][1]
url = self.output_tree.item(item)['values'][4]
answer = messagebox.askyesno("Open Link", f"Do you want to open the link in a browser?\n{name}\n{url}")
if answer:
webbrowser.open(url)


class WishlistGeneratorUI(ctk.CTk):
Expand Down Expand Up @@ -173,6 +174,18 @@ def __init__(self):
# self.theme_button = ctk.CTkButton(self, text="Toggle Theme", command=self.theme_toggle)
# self.theme_button.grid(row=6, column=0, padx=10, pady=10)

self.output_frame.output_tree.bind("<Button-3>", self.add_to_exclusions)

def add_to_exclusions(self, event):
item = self.output_frame.output_tree.identify_row(event.y)
if not item:
return

appid = self.output_frame.output_tree.item(item)['values'][0]
exclusions = self.input_frame.exclusions_entry.get().replace(" ", "").split(",")
if str(appid) not in exclusions:
self.input_frame.exclusions_entry.insert(ctk.END, f"{appid}, ")

def get_button_callback(self):

if self.method_tab.get() == "File":
Expand Down

0 comments on commit 32aea27

Please sign in to comment.