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
  Problems trying to position images with Tkinter emont 3 676 Dec-12-2023, 07:20 AM
Last Post: menator01
  Trouble with Tkinter labels Raysz 6 1,468 Sep-11-2023, 02:58 PM
Last Post: deanhystad
  [TKINTER] Problems creating directories in a selected path Vulera 2 2,732 Aug-10-2021, 06:38 PM
Last Post: Vulera
  [Tkinter] modify the html table to include data from tkinter labels rwahdan 0 1,590 Jun-20-2021, 10:33 AM
Last Post: rwahdan
  [Tkinter] Problems to display Web Scraping values in Tkinter Lucas_Ribeiro 0 1,539 May-07-2020, 12:36 AM
Last Post: Lucas_Ribeiro
  Creating and destroying dynamic labels in Tkinter MarcusRoberts 1 4,245 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 7,006 Jul-30-2019, 10:49 AM
Last Post: wuf
  tkinter frame sizing problems Lux 0 4,871 Aug-26-2017, 06:09 PM
Last Post: Lux
  tkinter import problems on mac Lux 2 6,157 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