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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 3,122 Dec-12-2023, 07:20 AM
Last Post: menator01
  Trouble with Tkinter labels Raysz 6 5,077 Sep-11-2023, 02:58 PM
Last Post: deanhystad
  [TKINTER] Problems creating directories in a selected path Vulera 2 4,101 Aug-10-2021, 06:38 PM
Last Post: Vulera
  [Tkinter] modify the html table to include data from tkinter labels rwahdan 0 2,254 Jun-20-2021, 10:33 AM
Last Post: rwahdan
  [Tkinter] Problems to display Web Scraping values in Tkinter Lucas_Ribeiro 0 2,057 May-07-2020, 12:36 AM
Last Post: Lucas_Ribeiro
  Creating and destroying dynamic labels in Tkinter MarcusRoberts 1 6,367 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 8,869 Jul-30-2019, 10:49 AM
Last Post: wuf
  tkinter frame sizing problems Lux 0 5,819 Aug-26-2017, 06:09 PM
Last Post: Lux
  tkinter import problems on mac Lux 2 7,198 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