Tkinter having problems with packing labels? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Tkinter having problems with packing labels? (/thread-28753.html) |
Tkinter having problems with packing labels? - wallgraffiti - Aug-02-2020 Code: import tkinter as tk from urllib.request import urlopen root=tk.Tk() pagestuff=[] pagestuff.append(tk.Label(root, text="This is a test.")) for i in pagestuff: i.pack(anchor=tk.NW) def goto(): global pagestuff for i in pagestuff: i.pack_forget() i.destroy() del i for i in str(urlopen(address.get()).read()).split("\n"): if i.startswith("h1>"): pagestuff.append(tk.Label(root, text=i[2:], font="Helvetica 15")) elif i.startswith("p>"): pagestuff.append(tk.Label(root, text=i[1:])) for i in pagestuff: i.pack() address=tk.Entry(root) goto=tk.Button(root, text="Go To", command=goto) address.pack() goto.pack() tk.mainloop()Shell Error(once address is inputed): For context, I'm making my own little website format and browser/engine for said format.
|