Python Forum
tkinter label error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter label error
#1
import tkinter
import random
import time
from tkinter import *
r = tkinter.Tk()
tk = Tk()
f = Frame(tk)
r.title("userinterface")
r.minsize(width=400, height=400)
# r.configure(background='gray49')

def viderfunction():
    navnlab.pack_forget()



# def b(Event):
#     def destroy():
#         f.destroy()

b = Button(r, text="vider", command=viderfunction, compound=CENTER)
b.place(relx=0.5, rely=0.5, anchor=CENTER)
b.pack()
navnlab = Label(r, text="navn?").grid(row=1)

alderlab = Label(r, text="alder?").grid(row=2)
alderlab.pack()
navnlab.pack()
navn = Entry(r)
alder = Entry(r)

navn.grid(row=0, column=10)
alder.grid(row=1, column=10)

r.mainloop()
on the label names it says Assigning result of a function call, where the function has no returnpylint(assignment-from-no-return)
Reply
#2
You have many things wrong.
  • Change all single letter variables to meaningful names. Though not strictly required,
    it's better code, and will make debugging much easier as the program grows. (r and f)
  • line 6 - you have already instantiated Tk, only one allowed per tkinter script remove this one
  • line 7 - frame is never used
  • line 12 - function never used, and wouldn't work at any rate
  • line 13 - what is pack_forget??
  • line 21 - what is compound? there is no such attribute for Button widget
  • line 22 - cannot use grid, place and pack in same widget choose one and use throughout
  • line 23 - same as 22
  • ... more apply fixes above to rest of code.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter destroy label inside labelFrame Nick_tkinter 2 1,279 Feb-24-2021, 03:31 AM
Last Post: deanhystad
  tkinter: Image to Label Maryan 10 1,741 Oct-29-2020, 01:48 PM
Last Post: joe_momma
  Tkinter - How can I extend a label widget? TurboC 2 978 Oct-13-2020, 12:15 PM
Last Post: zazas321
  Tkinter: How to assign calculated value to a Label LoneStar 7 1,170 Sep-03-2020, 08:19 PM
Last Post: LoneStar
  changing tkinter label from thread nanok66 3 2,728 Jun-07-2020, 01:37 AM
Last Post: nanok66
  [Tkinter] tkinter How to pass label fiilename to another module? johnjh 0 923 Apr-17-2020, 11:34 PM
Last Post: johnjh
  Make Label Text background (default color) transparent using tkinter in python barry76 1 14,889 Nov-28-2019, 10:19 AM
Last Post: Larz60+
  Spacing Between two labels are very far and Top label is not in Center using Tkinter barry76 2 3,776 Jul-30-2019, 10:49 AM
Last Post: wuf
  Unable to update or refresh label text in tkinter jenkins43 3 3,928 Jul-24-2019, 02:09 PM
Last Post: Friend
  [Tkinter] TkInter toggle Label on/off MTom5 2 3,707 Aug-15-2018, 12:35 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

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