469,928 Members | 1,871 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,928 developers. It's quick & easy.

Tk and raw_input segfault

Python newbie disclaimer on

I am running an app with Tkinter screen in one thread and command-line
input in another thread using raw_input(). First question - is this
legal, should it run without issue? If not can you point me to a
description of why.

While updating objects on the screen I get a segfault after an
indeterminate number of updates. It doesn't seem to matter how quickly
the updates occur, but it does segfault faster when there are more
objects on the screen ( as I said failure time seems to have a random
factor added to it ).

Commenting out the raw_input() makes problem go away. I can schedule
as many updates as I wish without error. And it doesn't seem to matter
if I actually hit any keys for raw_input(), it can just sit there.

I have read other posts about readline library failures with Esc O M
sequences and could not recreate those failures.

This happens on 2 separate machines

1st: development workstation
Python 2.3.3 (#1, Feb 5 2005, 16:30:27)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux <name deleted> 2.6.5-7.151-smp #1 SMP Fri Mar 18 11:31:21 UTC
2005 x86_64 x86_64 x86_64 GNU/Linux

2nd: target machine
Python 2.3.3 (#1, Apr 6 2004, 01:47:39)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux <name deleted> 2.6.4-52-default #1 Wed Apr 7 02:08:30 UTC 2004
i686 i686 i386 GNU/Linux

I have tried to simplify the code as much as possible to make error
more visible( no actual updates of the screen etc ) I've uncommented
the "after" code line so it fails much more rapidly. I know its ugly
repeatedly scheduling the after but, the same code runs without the
raw_input, and it shows the error more readily.

To see the error start the code and click the button repeatedly until
it segfaults. It will still segfault if you remove the 'command'
funtion and call update dirctly - it just takes a bit longer and your
wrist will probably get tired.

Thanks in advance for any responses.

from Tkinter import *
from time import sleep
import thread

class Test(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent, bg='white')

# Button Definition: CLEAR ALL OUTPUTS
caB = Button( self, text='CLEAR ALL\nOUTPUTS',\
#command = (lambda: self.update()) )
command = (lambda: self.command()) )
self.updateCount = 0
self.commanded = 0

def command( self ):
self.commanded = 1

def update( self ):
self.updateCount += 1
print 'updatin... num = ', self.updateCount
self.after( 1, self.update )

def test():
root = Tk()

if __name__ == '__main__':
scanTID= thread.start_new_thread( test, () )

while True:
f= raw_input()
print 'f=', f

Jul 19 '05 #1
0 1645

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Nathaniel Echols | last post: by
6 posts views Thread by Stefan Behnel | last post: by
2 posts views Thread by J. W. McCall | last post: by
10 posts views Thread by name | last post: by
21 posts views Thread by planetthoughtful | last post: by
17 posts views Thread by Stuart McGraw | last post: by
8 posts views Thread by Dox33 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.