On Tue, Jul 09, 2002 at 10:58:52AM -0400, Steve McClure wrote:
> On Mon, 2002-07-08 at 02:10, Isaac Claymore wrote:
> > Guys, I need to make my GtkCList cells editable with GtkCombo and GtkEntry...
> > I searched through the GTK on-line API doc and Tutorial, but failed to get
> > relevant information.
> > Any hint or point to URL is greatly appreciated ;)
>
> A tough one, not really tough, but it took a lot of trial and error and
> tweaking, here is what I did:
> 1. add a select-row handler on the CList, when the user does the right
> thing, in my case, click on column one (the only editable one), call a
> routine that does something like this:
>
> =====
> def createEntryWidgetForCList(self, list, row, col):
> delay = gtk.GtkEntry()
> delay.set_name(delayName)
> dialog.set_data(delayName, delay)
>
> delay.connect('activate', self.clistEntryWidgetDelayChanged)
> delay.connect('key-press-event', \
> self.clistEntryWidgetDelayCheckCancel)
> delay.connect('focus-out-event', \
> self.clistEntryWidgetDelayCheckCancel)
>
> # figure out where to put the widget
> labelName = '%sLabel' % list.get_name() #the clist column label
> l = self.wtree.get_widget(labelName)
> labelH = l.get_window().height
> labelW = l.get_window().width
> x = labelW
> rowH = (list.get_window().height - labelH) / list.rows
> colW = list.get_window().width - labelW
> y = rowH * row + labelH
> delay.set_usize(colW, rowH)
>
> delay.grab_focus()
> delay.set_data('row', row)
> delay.set_data('column', col)
> delay.set_data('widget', list)
> delay.show()
> func(delay, x, y)
Your message did give me some hints, but the GtkEntry failed to show up
in the GtkCList after I somewhat copied your codes to mine. I guess the
problem was due to the above "func(delay, x, y)", your message didn't
have the implementation of that 'func', so I commented it out in my code.
Could you show me the 'func'?
Thanks ;)
-Clay
> gtk.grab_add(delay)
>
> =====
> The CList column head label is used to determine the right size and
> location for the widget. I also save my widget so I only create it once
> but I didn't show that here for the sake of clarity. The
> clistEntryWidgetDelayChanged function gets the text from the entry and
> puts it into the clist using the row and column stored in the set_data
> calls. The clistEntryWidgetDelayCheckCancel is a little ugly in my code
> as I didn't know how to get the keypress handling right. A focus out or
> escape key cancels the input (hides the widget). A Delete, Tab,
> BackSpace, Return, KP_Enter, or LineFeed key will return false and let
> the other event handlers take over, otherwise I make sure it is an
> integer (they can only enter numbers in my scenario) and if not I call
> gdk_beep() and entry.emit_stop_by_name('key-press-event')
>
> Let me know if you need more details.
>
> >
> > - Clay
> > _______________________________________________
> > pygtk mailing list [EMAIL PROTECTED]
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> --
> Steve McClure 430 10th St NW
> Racemi Suite N-210
> http://www.racemi.com Atlanta, GA 30318
> [EMAIL PROTECTED] voice/fax: 404-892-5850
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/