seg fault

Ajay abra9823 at mail.usyd.edu.au
Thu Nov 4 15:06:07 CET 2004


hi!

i have some code with a gui that does some processing in another thread,
say t2.
when t2 needs to display something on the gui, it generates an event (which
i have binded earlier). the code runs fine on windows but segfaults on
linux.
the point where it segfaults is when it generates the event.

any ideas why?

the code is

#app.py

import sys
sys.path.append('\\Program Files\\Python\\Lib\\python23.zip\\lib-tk')
sys.path.append('/n/filer1/u1/hons2004/rwhitake/elvin/local/usr/lib/python2.3/site-packages/')
import os
from Tkinter import *
import tkMessageBox
import tkFileDialog
import tkSimpleDialog
from Queue import Queue
from time import localtime
import threading

import elvin

class Phone:
	def __init__(self, master):
		self.frame = Frame(master)
		self.frame.pack()

		Label(self.frame, text="Enter message", justify=LEFT).grid(row=0)
		self.entryMessage = Entry(self.frame, width=25)
		self.entryMessage.grid(row=1, column=0)
		Button(self.frame, text="Send", command=self.sendMessage).grid(row=4,
column=0)

		v_scrollbar = Scrollbar(self.frame, orient=VERTICAL)
		v_scrollbar.grid(row=5, column=1, sticky=N+S)
		h_scrollbar = Scrollbar(self.frame, orient=HORIZONTAL)
		h_scrollbar.grid(row=6, column=0, sticky=E+W)
		self.answerText = Text(self.frame, width=25, height=15,
xscrollcommand=h_scrollbar.set, yscrollcommand=v_scrollbar.set)
		self.answerText.grid(row=5, column=0, sticky=N+S+E+W)
		self.answerText.config(state=DISABLED)

		self.q = Queue()
		self.reply=""
		self.frame.bind("<<reply>>", self.displayReply)

		self.phnumber = tkSimpleDialog.askstring("Phone number", "Enter
phonenumber", parent=self.frame)
		if self.phnumber is None:
			sys.exit(0)

		self.th = threading.Thread(target=self.setElvin)
		self.th.start()

	def setElvin(self):
		elvin_con = elvin.connect("elvin://praxis.it.usyd.edu.au")
		sub = elvin_con.subscribe("equals(type, 'FREEVO_SMS_REPLY')")
		sub.add_listener(self.answerMessage)
		sub.register()
		elvin_con.run()

	def sendMessage(self):
		message = self.entryMessage.get()
		if message == "":
			tkMessageBox.showerror("Error", "Enter message", parent=self.frame)
			return

		offset = "+1000"
		t=localtime()
		date=str(t.tm_mday) + "/" + str(t.tm_mon) + "/" + str(t.tm_year)
		time=str(t.tm_hour) + ":" + str(t.tm_min) + ":" + str(t.tm_sec)
		con = elvin.connect("elvin://praxis.it.usyd.edu.au")
		con.notify(type="FREEVO_SMS", SMSSource=self.phnumber,
SMSDestination="foo", SMSDate=date, SMSTime=time, SMSGMTOffset=offset,
SMSText=message)

	def answerMessage(self, sub, msg, insec, rock):
		print msg
		self.reply = msg.get("SMSMessage")
		dest = msg.get("SMSDestination")
		if dest == self.phnumber:
			self.frame.event_generate('<<reply>>', when='tail')

	def displayReply(self, event=None):
		self.answerText.config(state=NORMAL)
		self.answerText.insert(INSERT, self.reply+"\n\n")
		self.answerText.config(state=DISABLED)


root = Tk()
phone = Phone(root)
root.mainloop()








----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Python-list mailing list