Re: [pygtk] Linking textview and combobox

2010-06-08 Thread Brian Rowlands (Greymouth High School)
Hi Folks
Found my mental block:

divisions = []
textbuffer = cbc['divisions'].get_buffer()
text =
cbc['divisions'].get_buffer().get_text(*textbuffer.get_bounds())
divisions = text.splitlines()
<-- needed this and a minor change in the lines
above
if no_divisions != '':
#set divisions list
store = gtk.ListStore(str)
for i in divisions:
if i != '' : store.append([i]) 
cbc['divisionCB'].set_model(store)
cell = gtk.CellRendererText()
cbc['divisionCB'].pack_start(cell, True)
cbc['divisionCB'].add_attribute(cell, 'text', 0)


Cheers

Brian
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] Linking textview and combobox

2010-06-07 Thread Brian Rowlands (Greymouth High School)
Hi folks
I'm trying to populate a combobox with the lines showing in a textview
widget. My question is how do I do this?

I've a textview widget called 'divisions'. This coding reads its
associated  buffer:
textbuffer = cbc['divisions'].get_buffer()
divisions =
cbc['divisions'].get_buffer().get_text(*textbuffer.get_bounds())

If the lines in textview are:
First line
Second line

Then divisions contains all these characters including \n.

This coding creates one character entries in the combobox called
divisonsCB:
store = gtk.ListStore(str)
 for i in divisions:
   if i != '\n' : store.append(i) 
 cbc['divisionCB'].set_model(store)
 cell = gtk.CellRendererText()
 cbc['divisionCB'].pack_start(cell, True)
  cbc['divisionCB'].add_attribute(cell, 'text', 0)

Can someone help me think logically on this issue please?

Thanks Brian

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/