Re: [pygtk] delete selection

2003-10-06 Thread Yang Zheng
Hello,

I cannot get to the faq site.  The operation always time out.  Is anyone
else having the same problem?

thanks,
~ Yang

On Fri, 2003-10-03 at 19:21, Christian Reis wrote:
 On Wed, Oct 01, 2003 at 01:46:50PM -0700, Yang Zheng wrote:
  I've figured out how to delete multiple selections.  If anyone runs into
 
 - FAQ 13.22
 
 http://www.async.com.br/faq/pygtk/index.py?req=showfile=faq13.022.htp
 
 If you see anything wrong or worth improving, feel free to hack it :-)
 
 Take care,
 --
 Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] please help with setting accelerator for the menu item

2003-10-06 Thread Alex Roitman
Hi,

I apologize for asking a silly question here, but I just can't figure  
it out by myself. I am creating a submenu of a main menu of a gnome  
program. I would like to add accelerators to the menu items of my menu.

   gomenu = gtk.Menu()
   back = gtk.ImageMenuItem(gtk.STOCK_GO_BACK)
   back.connect(activate,self.back_clicked)
   back.show()
   gomenu.append(self.back)
The above snippet works. But when I attempt to add an accelerator using
   back.add_accelerator()
is when I get in trouble. The add_accelerator() method of gtk.Widget  
wants accel_group as its second argument. What am I supposed to give  
it?

I tried None (does not work) and an empty gtk.AccelGroup() (works but  
produces complains about not being able to connect to the accel group).  
I also tried obtaining the get_accel_group() of the present menu, which  
returns None. I probably should add here that the whole menu hierarchy  
was created in glade and parsed using libglade. I want to just create  
this little submenu from the python code.

Any help is greatly appreciated.

Alex

--
Alexander Roitman   http://ebner.neuroscience.umn.edu/people/alex.html
Dept. of Neuroscience, Lions Research Building
2001 6th Street SE, Minneapolis, MN  55455
Tel (612) 625-7566   FAX (612) 626-9201


pgp0.pgp
Description: PGP signature
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] please help with setting accelerator for the menu item

2003-10-06 Thread Christian Reis
On Mon, Oct 06, 2003 at 01:16:00PM -0500, Alex Roitman wrote:
 I apologize for asking a silly question here, but I just can't figure  
 it out by myself. I am creating a submenu of a main menu of a gnome  
 program. I would like to add accelerators to the menu items of my menu.

I've had this problem before myself. 

gomenu = gtk.Menu()
back = gtk.ImageMenuItem(gtk.STOCK_GO_BACK)
back.connect(activate,self.back_clicked)
back.show()
gomenu.append(self.back)
 
 The above snippet works. But when I attempt to add an accelerator using
back.add_accelerator()
 is when I get in trouble. The add_accelerator() method of gtk.Widget  
 wants accel_group as its second argument. What am I supposed to give  
 it?
 
 I tried None (does not work) and an empty gtk.AccelGroup() (works but  
 produces complains about not being able to connect to the accel group).  

Hmmm. You should save a reference to your AccelGroup, but I'm curious as
to what happens when you set pass in group to add_accelerator().

Have you looked at the GTK+ documentation for AccelGroups? It should be
simple to translate examples to PyGTK from that.

 I also tried obtaining the get_accel_group() of the present menu, which  
 returns None. I probably should add here that the whole menu hierarchy  
 was created in glade and parsed using libglade. I want to just create  
 this little submenu from the python code.

I talked to James over IRC about this once; there's an issue that (in a
similar situation as signals connected via libglade) there isn't an easy
way to reach accelerator groups that are created during the libglade
parse for most/some of the GTK+ widgets.

*However*, when I asked him, I was referring to keyboard accelerators in
widgets *other* than GtkMenu, and since GtkMenu *does* provide an API to
get to its accel_group, I'm as to why get_accel_group() is returning
None. It may very well be a bug.

Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] [NEWBIE] Applets and setup_menu()

2003-10-06 Thread Martin Gadbois
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Martin Gadbois wrote:
| Hello,
|
| Being a Newbie, I was surprised to see that I could not do something
| like that for my brand new
| gnome2 applet (see  enphasis):
|
| class MyApplet:
| ~def __init__(self,applet):
| ~propxml=
| popup name=button3
| menuitem name=Item 1 verb=Props label=_Preferences...
| pixtype=stock
| pixname=gtk-properties/
| /popup
| 
|
| ~self.cfg = { }
| ~self.get_config()
| | applet.setup_menu(propxml,[ (Props,MyApplet.properties) ],self)
| ~applet.add(frame)
| ~applet.show_all()
| | def properties(widget,self):
| ~# Access self.cfg here, display a property box
| ~pass
| ~def get_config(self):
| ~pass # Do something, get config from gconf
|
| def applet_factory(applet):
| ~MyApplet(applet)
|
| No, in fact, when I successfully got it to work, the arguments passed to
| the callback properties()
| were a BonoboUIComponent instance and the verb being called (Props). I
| assumed the 3rd arg to
| setup_menu() would be passed to the callback as 'data'.
|
| I use gnome-python  pyGtk 2.0.0.
|
| My questions:
| 1) What is the 3rd argument of setup_menu() (gnome-python says it is
| extra_args) and how is it used?
| 2) Can callbacks be methods of a class?
| 2b) How to pass 'self' to a callback?
| 3) Should I just use procedural functions?
For the record:
1) It is user-data. It does behave differently when None. When none, the callback 
requires 2 args
(widget,verb). If not None, the callback requires (widget,verb,user_data)
2) Yes. use 'self.method' in the verbs
2b) Use self.method, not Class.method.
3) No. member class works well.
Working example:
class MyApplet:
~def __init__(self,applet):
~propxml=
~   popup name=button3
~ menuitem name=Item 1 verb=Props label=_Preferences...
~  pixtype=stock
~  pixname=gtk-properties/
~ /popup
~ 
~self.cfg = { }
~self.get_config()
~applet.setup_menu(propxml,[ (Props,self.properties) ],Extra)
~applet.add(frame)
~applet.show_all()
~   def properties(widget,extra):
~# Access self.cfg here, display a property box
# here, extra == Extra
~pass
~   def get_config(self):
~pass # Do something, get config from gconf
def applet_factory(applet):
~MyApplet(applet)
- --
Martin
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/gcVx9Y3/iTTCEDkRAlcXAJ9p2YWWG5aUsfWlFjp4znZp0BXquwCgyDvC
Ax5I43Ty4x+lsX8JrNQBFZM=
=il45
-END PGP SIGNATURE-
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] please help with setting accelerator for the menu item

2003-10-06 Thread Alex Roitman
Chris, 

Thanks for your response!

On Mon, Oct 06, 2003 at 03:28:51PM -0300, Christian Reis wrote:
 Hmmm. You should save a reference to your AccelGroup, but I'm curious as
 to what happens when you set pass in group to add_accelerator().

I apologize, but I'm clueless as to how to save a reference to my 
AccelGroup. What is my AccelGroup?
 
 Have you looked at the GTK+ documentation for AccelGroups? It should be
 simple to translate examples to PyGTK from that.

I have some reference in front of me right now:
  http://developer.gnome.org/doc/API/gtk/gtk-keyboard-accelerators.html
but I would not call it documentation in its usual sense. 
All descriptions and explanations seem yet to be filled. If you could 
refer me to a better doc I would be most grateful.

  I also tried obtaining the get_accel_group() of the present menu, which  
  returns None. I probably should add here that the whole menu hierarchy  
  was created in glade and parsed using libglade. I want to just create  
  this little submenu from the python code.
 
 I talked to James over IRC about this once; there's an issue that (in a
 similar situation as signals connected via libglade) there isn't an easy
 way to reach accelerator groups that are created during the libglade
 parse for most/some of the GTK+ widgets.

What puzzles me is that the glade file gets away with the following XML 
which is enough for a fully functional accelerators:

  widget class=GtkImageMenuItem id=the_id
property name=visibleTrue/property
property name=label translatable=yesThe Label/property
signal name=activate handler=on_activate/
accelerator key=the_key modifiers=the_mod signal=activate/

This does not seem to ever worry about accel group at all!
 
 *However*, when I asked him, I was referring to keyboard accelerators in
 widgets *other* than GtkMenu, and since GtkMenu *does* provide an API to
 get to its accel_group, I'm as to why get_accel_group() is returning
 None. It may very well be a bug.

Should I make a testcase and file it with Gnome bugzilla then?

Thanks,
Alex

-- 
Alexander Roitman   http://ebner.neuroscience.umn.edu/people/alex.html
Dept. of Neuroscience, Lions Research Building
2001 6th Street SE, Minneapolis, MN  55455
Tel (612) 625-7566   FAX (612) 626-9201


signature.asc
Description: Digital signature
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] please help with setting accelerator for the menu item

2003-10-06 Thread Christian Reis
On Mon, Oct 06, 2003 at 03:03:42PM -0500, Alex Roitman wrote:
 On Mon, Oct 06, 2003 at 03:28:51PM -0300, Christian Reis wrote:
  Hmmm. You should save a reference to your AccelGroup, but I'm curious as
  to what happens when you set pass in group to add_accelerator().
 
 I apologize, but I'm clueless as to how to save a reference to my 
 AccelGroup. What is my AccelGroup?

Well, I meant saving a reference as a python variable:

group = gtk.AccelGroup()

But I'm still curious about the warning issued.

  Have you looked at the GTK+ documentation for AccelGroups? It should be
  simple to translate examples to PyGTK from that.
 
 I have some reference in front of me right now:
   http://developer.gnome.org/doc/API/gtk/gtk-keyboard-accelerators.html
 but I would not call it documentation in its usual sense. 
 All descriptions and explanations seem yet to be filled. If you could 
 refer me to a better doc I would be most grateful.

That's the old 1.0 documentation. Try

http://developer.gnome.org/doc/API/2.0/gtk/gtk-Keyboard-Accelerators.html

(and keep the 2.0 API docs handy)

  I talked to James over IRC about this once; there's an issue that (in a
  similar situation as signals connected via libglade) there isn't an easy
  way to reach accelerator groups that are created during the libglade
  parse for most/some of the GTK+ widgets.
 
 What puzzles me is that the glade file gets away with the following XML 
 which is enough for a fully functional accelerators:
 
   widget class=GtkImageMenuItem id=the_id
 property name=visibleTrue/property
 property name=label translatable=yesThe Label/property
 signal name=activate handler=on_activate/
 accelerator key=the_key modifiers=the_mod signal=activate/
 
 This does not seem to ever worry about accel group at all!

But I assure you that libglade, internally, *does* consider them :-)

  *However*, when I asked him, I was referring to keyboard accelerators in
  widgets *other* than GtkMenu, and since GtkMenu *does* provide an API to
  get to its accel_group, I'm as to why get_accel_group() is returning
  None. It may very well be a bug.
 
 Should I make a testcase and file it with Gnome bugzilla then?

I'm not sure; let's see if anybody else has a comment, and if not, I'd
say yes.

Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] please help with setting accelerator for the menu item

2003-10-06 Thread John Finlay


Christian Reis wrote:

On Mon, Oct 06, 2003 at 03:03:42PM -0500, Alex Roitman wrote:
 

On Mon, Oct 06, 2003 at 03:28:51PM -0300, Christian Reis wrote:
   

Have you looked at the GTK+ documentation for AccelGroups? It should be
simple to translate examples to PyGTK from that.
 

I have some reference in front of me right now:
 http://developer.gnome.org/doc/API/gtk/gtk-keyboard-accelerators.html
but I would not call it documentation in its usual sense. 
All descriptions and explanations seem yet to be filled. If you could 
refer me to a better doc I would be most grateful.
   

That's the old 1.0 documentation. Try

   http://developer.gnome.org/doc/API/2.0/gtk/gtk-Keyboard-Accelerators.html

(and keep the 2.0 API docs handy)
 

Or try the PyGTK2 reference docs:

http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtkaccelgroup.html

John

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/