Python Forum
Tkinter having problems with packing labels?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter having problems with packing labels?
#1
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):
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\mjmin\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__ return self.func(*args) File "D:\browse\actualthing.py", line 25, in goto i.pack() File "C:\Users\mjmin\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2387, in pack_configure self.tk.call( _tkinter.TclError: bad window path name ".!label"
For context, I'm making my own little website format and browser/engine for said format.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [TKINTER] Problems creating directories in a selected path Vulera 2 787 Aug-10-2021, 06:38 PM
Last Post: Vulera
  [Tkinter] modify the html table to include data from tkinter labels rwahdan 0 520 Jun-20-2021, 10:33 AM
Last Post: rwahdan
  [Tkinter] Problems to display Web Scraping values in Tkinter Lucas_Ribeiro 0 804 May-07-2020, 12:36 AM
Last Post: Lucas_Ribeiro
  Creating and destroying dynamic labels in Tkinter MarcusRoberts 1 2,051 May-02-2020, 06:49 PM
Last Post: Yoriz
  Spacing Between two labels are very far and Top label is not in Center using Tkinter barry76 2 4,312 Jul-30-2019, 10:49 AM
Last Post: wuf
  tkinter frame sizing problems Lux 0 3,696 Aug-26-2017, 06:09 PM
Last Post: Lux
  tkinter import problems on mac Lux 2 4,809 Jul-30-2017, 07:14 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020