Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does it return error?
#1
from tkinter import *
root = Tk()
root.title('First stage')
root.geometry('600x400')
Button(root, text = '1', width = 5, height = 3, bg = 'blue', fg = 'red', font = 'arial 14').place(x = 70, y = 32)
Label(text = 'Hallo', bg = 'yellow', fg = 'orange').place(x = 80, y = 10)
searching = Text(root, height = 4, width = 35, font = 'Arial 10').place(x = 90, y = 30)
searching.insert(1.0, 'It is good!\n')
root.mainloop()
Error:
Traceback (most recent call last):   File "C:/Users/Владелец/Desktop/програмирование/Tkinter.py", line 8, in <module>     searching.insert(1.0, 'It is good!\n') AttributeError: 'NoneType' object has no attribute 'insert'
Reply
#2
Because searching is None for some reason, possibly because the place() method of Text doesn't return anything.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#3
You didn't use place, pack or grid on your searching Text widget
nor an any other widgets.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 1,913 Aug-13-2023, 12:16 AM
Last Post: cubangt
  return out of loops syntax error felixf 7 3,355 Nov-03-2020, 01:00 PM
Last Post: perfringo
  SystemError: error return without exception set!!! faryad13 3 3,584 Oct-23-2020, 02:32 PM
Last Post: ATARI_LIVE
  syntax error on return statement l_butler 5 3,028 May-31-2020, 02:26 PM
Last Post: pyzyx3qwerty
  Error with print and return commands TheDark_Knight 2 1,900 Jan-15-2020, 04:59 PM
Last Post: TheDark_Knight
  Python Error 'return self.attrs[key]' Need help! ahmedwaqas92 0 4,367 Oct-13-2019, 03:50 AM
Last Post: ahmedwaqas92

Forum Jump:

User Panel Messages

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