telnetlib

I wish use this function that open a unix terminal and write a command calling it from a gui (double click on an item of a listbox) but it doesn't work.Instead if I lunch it from the python idle it works.In the gui not even an error is generate.What do you think about it?

Regards
Giuseppe

def OnPrintLabel(sCode,sPrint):

         HOST = "localhost"
         user = 'user1'
         password = 'pass'

         tn = telnetlib.Telnet(HOST)

         tn.read_until("login: ")
         tn.write(user + "\n")
         tn.read_until("Password: ")
         tn.write(password + "\n")
         tn.write("ls \n")

         sParameter = "/usr/bla/bin/gedit `/usr/bla/bin/bla 30` 80 5 F
%s %s \n" %(sCode,sPrint)
         #print sParameter
         tn.write(sParameter)

         tn.write("exit\n")

#call from this in the gui

def OnItemSelected(self, event):

         #pdb.set_trace()
         item = event.GetItem()
         sCode =item.GetText()
         sCode =str(sCode)
         sPrint = 'A29'
         data.OnPrintLabel(sCode,sPrint)