On Tue, 2002-07-09 at 23:36, Isaac Claymore wrote:
> 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):
        dialog = self.wtree.get_widget('powerPortDialog')
        boxName = '%sBox' % list.get_name()
        box = self.wtree.get_widget(boxName)
        delayName = '%sDelayWidget' % boxName
        delay = dialog.get_data(delayName)

        if delay:
                func = box.move
        else:

> >             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)  
                func = box.put
> > 
> >         # 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 ;)

Yes that would be a problem, sorry it has been a while since I wrote
this and I tried to cut and paste a little too quickly.  I've added the
needed lines, inline, above.  That is the code that reuses the single
widget that I talked about not showing.  The first time through it uses
the GtkLayout.put method and every other time it uses the GtkLayout.move
method.  Note that the widget won't actually be in the list, it will be
on top of it, obscuring a single cell of the list that is below it.

> 
> -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/
-- 
Steve McClure                   430 10th St NW
Racemi                          Suite N-210
http://www.racemi.com           Atlanta, GA 30318
[EMAIL PROTECTED]             voice/fax: 404-892-5850

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to