473,414 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to delete an entry content after click a button (Tkinter)

I'm looking for a simle form to delete the entry content after pushing a button, in the next link the solution for the code works (verified it), after read that i try it, but it doesn't work for me

http://bytes.com/topic/python/answers/867449-gui-text-entry-tkinter

Python 2.7.9 [MSC v.1500 64 bit (AMD64)] on Windows 7 64 bits

this is the part of code that i can't fix:

Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  2.  
  3. def evclr():
  4.     chatsend.delete(0,END)
  5.  
  6. def chat(user, items, userslist):
  7.     global chatsend
  8.  
  9.     v0 = Tkinter.Tk()
  10.     v0.geometry('450x250+100+100')
  11.     v0.title('J+ CHATTING ROOM Welcome')
  12.     chat_msg = Tkinter.StringVar()
  13.  
  14.     chatwindow = Tkinter.Text(v0, height=12, width=55)
  15.     chatwindow.insert(Tkinter.INSERT, chat_content)
  16.     chatwindow.pack()
  17.  
  18.     chatsend = Tkinter.Entry(v0, bd=3, textvariable=chat_msg).pack()
  19.  
  20.     sendbutton = Tkinter.Button(v0, text='SEND', command=evclr).pack()
  21.  
  22.     v0.mainloop()
  23.  
  24.  
  25. chat_content = '''
  26.       Tue 07 Apr 2015
  27.   12:11:25 
  28. X> ===í}
  29. éé===
  30. '''
  31.  
  32. chat('X', [0, 2], ['CARLOS VILLALOBOS', 'CESAR BENCOMO', 'JOHNNY CASH'])
  33.  
and this is what i get:

Expand|Select|Wrap|Line Numbers
  1. Exception in Tkinter callback
  2. Traceback (most recent call last):
  3.   File "C:\Python27\64\lib\lib-tk\Tkinter.py", line 1532, in __call__
  4.     return self.func(*args)
  5.   File "C:/Python27/Scripts/prueba04.py", line 13, in evclr
  6.     chatsend.delete(0,END)
  7. AttributeError: 'NoneType' object has no attribute 'delete'
  8. Exception in Tkinter callback
  9. Traceback (most recent call last):
  10.   File "C:\Python27\64\lib\lib-tk\Tkinter.py", line 1532, in __call__
  11.     return self.func(*args)
  12.   File "C:/Python27/Scripts/prueba04.py", line 13, in evclr
  13.     chatsend.delete(0,END)
  14. AttributeError: 'NoneType' object has no attribute 'delete'
Apr 7 '15 #1

✓ answered by bvdet

That's because method call pack() returns None. Assign the widget instance to chatsend without calling pack(), then call chatsend.pack() on the next line.

2 9403
bvdet
2,851 Expert Mod 2GB
That's because method call pack() returns None. Assign the widget instance to chatsend without calling pack(), then call chatsend.pack() on the next line.
Apr 7 '15 #2
Thanks so much, i really apreciate your help and time spent
Apr 7 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Casey Hawthorne | last post by:
Is there a better way to delete the image from a Tkinter button other than the following: - reconstructing the button - image=blank.gif -- Regards,
0
by: [Yosi] | last post by:
I search solution for a little bit strange problem , I working on an application which includes a button. Click on this button will create number of threads each one execute deferent executable...
5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
0
by: radders | last post by:
Hi guys, What I'd like to do is place three edit boxes with three static text labels on a click button. This would let the user input RGB values to the three edit boxes and then click the...
3
by: eddie69 | last post by:
Hi, Newbie question here: I am creating an application in VB Studio 2005 which reads the status of an USB PIR Motion sensor. So far, I have managed to get the application to read the motion...
12
by: Thammarat charoenchai. | last post by:
Hi, I'm try to learn vb.net. in delphi have .click method for click button by coding. Can I do that with vb.net Thank you very much.
5
by: laziers | last post by:
Hi, anyone know how to write a single-cilick button? I use this: <asp:button id="ButtonAdd" runat="server" text="Anuluj" onclick="Click_ButtonAdd" /> if ( !isPostBack){...
2
by: Philip Fortuna | last post by:
Hi, I have a database in which me and my collegues do some registries. I would like to block the finished entry with a button so anyone besides the ones that know how to edit the tables?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.