I'm looking at the possibility of porting a Tkinter-based application to 
Cocoa, and since my app is already written in Python, PyObjC is the 
logical starting point for me. However, what I'm not sure about is how 
much translation I'd have to do between Python datatypes and Objective-C 
datatypes. For instance, the code below reads data as a list, massages 
the data a bit, then returns a tuple that is then inserted into a 
Tkinter table display.

             if self.catname == 'All':
                 self.catlist = os.popen('/sw/bin/fink list', 'r', 
os.O_NONBLOCK)
             else:
                 self.catlist = os.popen('/sw/bin/fink list 
--section=%s' % self.catname, 'r', os.O_NONBLOCK)
             for line in self.catlist:
                 newline = line.split('\t')
                 rawcat = newline[0]
                 if rawcat == '(i)':
                     firstcat=rawcat.replace('(i)', 'outdated')
                 elif rawcat == ' i ':
                     firstcat=rawcat.replace('i', 'current')
                 elif rawcat == ' p ':
                     firstcat=rawcat.replace('p', 'provided')
                 else:
                     firstcat = rawcat
                 newlist = (firstcat, newline[1], newline[2], 
newline[3].strip('\n')) #finalline)
                 self.infotable.insert('end' , newlist)

Except for the line "self.infotable.insert('end' , newlist)", there is 
nothing Tkinter-specific in this code.

If I used Interface Builder for the table view, would this data import 
cleanly into the GUI, or would I have to set up some sort of NS-prefixed 
datatype (NSMutableArray?) to parse and display the data correctly? If 
so, how could this snippet be rewritten?

My preference in porting my application is to refactor the GUI layer 
from Tkinter to PyObjC, but otherwise retain as much of my code as 
possible in its present (Python-generic) form. Is this a feasible 
approach, or does using PyObjC require adopting more of an "Objective-C" 
mindset, designing the entire app from the top down to use 
NS*-datatypes? That's a lot more work and I might as well learn 
Objective-C and just use that.

TIA,
Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to