Re: [pygtk] Simple question on reusing stock item

2009-02-09 Thread John Finlay
Alessandro Dentella wrote:
 Hi,

   i'd like to use stock item in menu entries with modified labels to better
   suit context.

   *  MenuItem doesn't allow to use images (reasonable)
   *  ImageMenuItem doesn't appearently allow to change label (really???)

   I think I could go with IconFactory but it seems to me it's more complex
   than what is should be and I wandered if there is a simple way I was not
   able to work out.

   Thanks
   
   sandro
   *:-)

   
A MenuItem is a Container so you can add anything to it. In your case 
create an empty MenuItem and add an HBox containing an Image and a Label.

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


[pygtk] segmentation fault with gtk.Notebook

2009-02-09 Thread Gaetano Guerriero
Documentation says that since PyGTK 2.4 I can add a page to a gtk.Notebook 
with an empty label. Anyway this crash with segmentation fault. Am i missing 
something ?

$ echo '
import gtk

window = gtk.Window()
box = gtk.HBox()
notebook = gtk.Notebook()
notebook.append_page(gtk.Label(!))
box.add(notebook)
window.add(box)
window.show_all()
gtk.main()' | python
Segmentation fault


I'm using debian packages, so PyGTK 2.12.1 and python 2.5.2.

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


[pygtk] segmentation fault with gtk.Notebook

2009-02-09 Thread Gaetano Guerriero
Documentation says that since PyGTK 2.4 I can add a page to a gtk.Notebook 
with an empty label. Anyway this crash with segmentation fault. Am i missing 
something ?

$ echo '
import gtk

window = gtk.Window()
box = gtk.HBox()
notebook = gtk.Notebook()
notebook.append_page(gtk.Label(!))
box.add(notebook)
window.add(box)
window.show_all()
gtk.main()' | python
Segmentation fault


I'm using debian packages, so PyGTK 2.12.1 and python 2.5.2.

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


Re: [pygtk] segmentation fault with gtk.Notebook

2009-02-09 Thread Gian Mario Tagliaretti
On Mon, Feb 9, 2009 at 1:18 PM, Gaetano Guerriero
gaetano.guerri...@spacespa.it wrote:

Hi Gaetano,

 import gtk

 window = gtk.Window()
 box = gtk.HBox()
 notebook = gtk.Notebook()
 notebook.append_page(gtk.Label(!))
 box.add(notebook)
 window.add(box)
 window.show_all()
 gtk.main()

Your snippet works for me.

cheers
-- 
Gian Mario Tagliaretti
GNOME Foundation member
gia...@gnome.org
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] Creating a subclass of gtk.Image

2009-02-09 Thread Graham Whelan
Hi,

I'm trying to create a custom widget that inherits from gtk.Image but I'm
having problems. When I add more than one of these widgets to a container,
only the first widget is being rendered. My test case looks like this:

import gtk, gobject

class MyImage(gtk.Image):
def __init__(self):
gtk.Image.__init__(self)
self.unset_flags(gtk.NO_WINDOW)

def do_realize(self):
self.set_flags(self.flags() | gtk.REALIZED)

self.window = gtk.gdk.Window(
self.get_parent_window(),
x=self.allocation.x,
y=self.allocation.y,
width=self.allocation.width,
height=self.allocation.height,
window_type=gtk.gdk.WINDOW_CHILD,
wclass=gtk.gdk.INPUT_OUTPUT,
visual=self.get_visual(),
colormap=self.get_colormap(),
event_mask=self.get_events() | gtk.gdk.EXPOSURE_MASK)

self.window.set_user_data(self)
self.style.attach(self.window)
self.style.set_background(self.window, gtk.STATE_NORMAL)

def do_unrealize(self):
self.window.set_user_data(None)

gobject.type_register(MyImage)

if __name__ == '__main__':
win = gtk.Window()
win.connect('destroy', gtk.main_quit)

box = gtk.HBox()

image = MyImage()
image.set_from_stock(gtk.STOCK_OK, gtk.ICON_SIZE_DIALOG)
box.add(image)

image = MyImage()
image.set_from_stock(gtk.STOCK_HELP, gtk.ICON_SIZE_DIALOG)
box.add(image)

win.add(box)
win.show_all()
gtk.main()


With the above code only the first image is rendered.

Any ideas as to what I'm doing wrong?

Thanks,

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

Re: [pygtk] segmentation fault with gtk.Notebook

2009-02-09 Thread Amondo Roquentin
Gian Mario Tagliaretti wrote:
 Your snippet works for me.
 
 cheers

It worked for me too.

May I suggest to check your bindings are compiled/installed okay.
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] reply address for this list

2009-02-09 Thread Alessandro Dentella
Hi,

  I found mysel many times answering to the original author rather than to
  the list. I think that this doesn't only happen to me as is pretty normal
  for public mailing list to have reply address set to the list.

  I think this is inconvenient as many answers of public interest don't
  arrive to the list.

  Is it possible to change this  setting?

  sandro
  *:-)



  
-- 
Sandro Dentella  *:-)
http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Simple question on reusing stock item

2009-02-09 Thread Amondo Roquentin
John Finlay wrote:

 A MenuItem is a Container so you can add anything to it. In your case
 create an empty MenuItem and add an HBox containing an Image and a Label.

Is there a policy on the spacing to apply to HBoxes in this
circumstance? For example, should the spacing be zero or a fixed number?
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Simple question on reusing stock item - SOLVED

2009-02-09 Thread Alessandro Dentella
On Mon, Feb 09, 2009 at 02:04:24AM -0800, John Finlay wrote:
 Alessandro Dentella wrote:
  Hi,
 
i'd like to use stock item in menu entries with modified labels to better
suit context.
 
*  MenuItem doesn't allow to use images (reasonable)
*  ImageMenuItem doesn't appearently allow to change label (really???)
 
I think I could go with IconFactory but it seems to me it's more complex
than what is should be and I wandered if there is a simple way I was not
able to work out.
 
Thanks

sandro
*:-)
 

 A MenuItem is a Container so you can add anything to it. In your case 
 create an empty MenuItem and add an HBox containing an Image and a Label.

Today pygtk FAQ is back (yesterday was not reachable) and I saw the solution
there. What I didn't imaginis that you can instantiate an ImageMenuItem as:

   item = gtk.ImageMenuItem('Foo')


even thought official docs say:

   gtk.ImageMenuItem(stock_id=None, accel_group=None)

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


Re: [pygtk] Simple question on reusing stock item

2009-02-09 Thread Alessandro Dentella
On Mon, Feb 09, 2009 at 02:24:35PM +, Amondo Roquentin wrote:
 John Finlay wrote:
 
  A MenuItem is a Container so you can add anything to it. In your case
  create an empty MenuItem and add an HBox containing an Image and a Label.
 
 Is there a policy on the spacing to apply to HBoxes in this
 circumstance? For example, should the spacing be zero or a fixed number?

I don't have the answer, but I can point out 2 things that I wrote yesterday
erroneusly to John instead of the list  (see other mail on Repy-To).

  1. the code I attach to this message adds the icon but the alignment is
 wrong as can be seen in this image ex.:
 http://www.e-den.it/misc/menu.png

  2. in pygtk FAQ tere are 2 aswers. (It's a pity on Sunday the pygtk FAQ was
 unreachable) and the hint there shows that you can write:

item = gtk.ImageMenuItem('Foo')

 even thought official docs say:

gtk.ImageMenuItem(stock_id=None, accel_group=None)

 This works correctly

sandro
*:-)

-- 
Sandro Dentella  *:-)
http://sqlkit.argolinux.orgSQLkit home page - PyGTK/python/sqlalchemy

###   bad  
code that leads to uncorrect alignment:

  class StockMenuItem(gtk.MenuItem):

  def __init__(self, label, stock, size=gtk.ICON_SIZE_MENU):
  gtk.MenuItem.__init__(self)
  label = gtk.AccelLabel(label)
  hbox = gtk.HBox(spacing=5)
  image = gtk.Image()
  image.set_from_stock(stock, size)
  hbox.add(image)
  hbox.add(label)
  self.add(hbox)
  self.show_all()


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