Tk and raw_input segfault

Discussion in 'Python' started by dale, May 24, 2005.

  1. dale

    dale Guest

    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
    tk-8.4.6-28
    tcl-8.4.6-23
    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
    tk-8.4.6-37
    tcl-8.4.6-26
    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()) )
    caB.pack()
    self.updateCount = 0
    self.commanded = 0
    self.update()

    def command( self ):
    self.commanded = 1
    self.update()

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

    def test():
    root = Tk()
    root.geometry('640x480')
    Test().pack()
    root.mainloop()

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

    while True:
    f= raw_input()
    print 'f=', f
    sleep(1)
    dale, May 24, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 7stud
    Replies:
    9
    Views:
    843
    Marc 'BlackJack' Rintsch
    Nov 2, 2007
  2. jkv
    Replies:
    0
    Views:
    395
  3. jkv
    Replies:
    0
    Views:
    413
  4. Jean-Paul Calderone

    Re: EOL for sys.stdin.readline() and raw_input()

    Jean-Paul Calderone, Feb 26, 2009, in forum: Python
    Replies:
    0
    Views:
    587
    Jean-Paul Calderone
    Feb 26, 2009
  5. Andrey Vul
    Replies:
    8
    Views:
    670
    Richard Bos
    Jul 30, 2010
Loading...

Share This Page