It basically just only make a button for one URL (https://github.com/explore) when it has all the other links on the github homepage to open. It should make a button for the individual links.
webbrowser.open(url)
def convert_to_tk(self, parent):
converted_html = []
tk_elements = {}
for x in self.tags:
tk_elements[x] = []
for x in self.filtered_html:
if not f"<{x['tag']}" in x["value"] and not "<" in x["value"] and ((x["value"] != "" and x["value"] != "'") or x["attrs"] != {}):
converted_html.append({
"tag": x["tag"],
"attrs": x["attrs"],
'value': x["value"]
})
for x in converted_html:
tag = x["tag"]
value = x["value"]
attrs = x["attrs"]
if "href" in attrs:
href = urljoin(self.url, attrs["href"])
if tag == "h1":
tk_elements["h1"].append(Label(parent, text=value, font=("Arial", 60)))
elif tag == "h2":
tk_elements["h2"].append(Label(parent, text=value, font=("Arial", 50)))
elif tag == "h3":
tk_elements["h3"].append(Label(parent, text=value, font=("Arial", 40)))
elif tag == "h4":
tk_elements["h4"].append(Label(parent, text=value, font=("Arial", 30)))
elif tag == "h5":
tk_elements["h5"].append(Label(parent, text=value, font=("Arial", 20)))
elif tag == "h6":
tk_elements["h6"].append(Label(parent, text=value, font=("Arial", 10)))
elif tag == "a":
tk_elements["a"].append(Button(parent, text=value, command=lambda: os.system(f"start \"\" {href}")))
# print(f"Used the link: {href}")
return tk_elements