Find the answer to your Linux question:
Results 1 to 8 of 8
Hi everyone, I recently installed Slackware 13/x86_64 on one of my boxes and now I'm having troubles with Python code that uses threading and Tkinter. This problem never existed on ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    Slackware 13/64 Python threads/Tkinter


    Hi everyone,

    I recently installed Slackware 13/x86_64 on one of my boxes and now I'm having troubles with Python code that uses threading and Tkinter. This problem never existed on other Linux distro's, it just appeared with Slackware.

    The box in question
    Acer Athlon x86_64 single core used to run Mandriva/64 and the Python code worked fine.

    Now it runs Slackware13/64 and Python threading and Tkinter are not getting along at all(program crashes with out of stack space infinite loop for the thread).

    Any suggestion?...Gerard4143
    Make mine Arch Linux

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    Are the versions of python the same?

  3. #3
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Both are Python 2.6.2

    The only real difference, besides one is Mandriva and one is Slackware, is the window mangers, Mandriva was Gnome and Slackware is KDE
    Make mine Arch Linux

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    can you post the stack traces of a crash? it might be helpful

  6. #5
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Here's the details

    Unhandled exception in thread started by
    Traceback (most recent call last):
    File"./testing.py", line 30, in marquee
    self.text = self.mylabel['text'][-1] + self.mylabel['text'][:-1]
    File "/usr/lib64/python2.6/lib-tk/Tkinter.py", line 1206, in cget
    return self.tk.call(self._w, 'cget','-' + key)
    tkinter.TclError: out of stack space(infinite loop?)
    And the code
    Code:
    #! /usr/bin/python
    
    import Tkinter, thread, time
    
    class MyLab:
    	DATA = 'this is the marquee message! '
    	START = 'start marquee'
    	STOP = 'stop marquee'
    	def __init__(self, master):
    		self.looping = 1
    		self.frame = Tkinter.Frame(master)
    		self.mylabel = Tkinter.Label(self.frame, text = MyLab.DATA, background = 'white')	
    		self.start = Tkinter.Button(self.frame, text = MyLab.START, command = self.startit)	
    		
    		self.mylabel.pack()
    		self.start.pack()
    		self.frame.pack()
    		
    	def startit(self):
    		if (self.start['text'] == MyLab.START):
    			self.looping = 1
    			self.start['text'] = MyLab.STOP
    			thread.start_new_thread(self.marquee, ())
    		else:
    			self.looping = 0
    			self.start['text'] = MyLab.START	
    	
    	def marquee(self):
    		while self.looping:
    			self.text = self.mylabel['text'][-1] + self.mylabel['text'][:-1]
    			self.mylabel['text'] = self.text	
    			time.sleep(.2)	
    		
    root = Tkinter.Tk()
    
    mymar = MyLab(root)
    
    root.mainloop()
    Make mine Arch Linux

  7. #6
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    What about the version of tk? Is that different? I'm just throwing things out there because what you are experiencing is odd. I am running your code on my machine (arch x64) and it works just fine. How quickly does it throw that exception?

  8. #7
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    The exception is thrown as soon as I click the start button.i.e the thread doesn't appear to run at all(or the text marquee message doesn't scroll at all)...

    If I take out the Tkinter object reference and print the data to the terminal then the thread works great.

    The Tkinter version for Slackware is Tkinter.__version__ = "$Revision: 70220 $"

    I'll have to dig to find Mandriva's Tkinter version...
    Make mine Arch Linux

  9. #8
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Finally dug up the Mandriva info:

    Python 2.6.1
    Tkinter $Revision: 67083$
    Make mine Arch Linux

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •