[pygtk] Combobox error? duplicated columns

2008-02-13 Thread Edward Stow
Hi

I'm not sure is this is an error --  but when I attach a ListModel and
and CellRenderer to a gtk.ComboBox I end up with duplicate columns in
the list box. Attached is a small screenshot.

This only occurs if I have first opened the combobox list editor in
glade and then saved.

Glade inserts an empty items property in the xml:
property name=items translatable=yes/property

Removing this element fixes the problem.  The code below replicates the problem.

Is this a bug and should be reported on bu

Relevent versions numbers are:

ii  python  2.5.1-0ubuntu3
ii  python-glade2   2.10.4-0ubuntu3
ii  python-gtk2 2.10.4-0ubuntu3

ii  glade-3 3.2.0-0ubuntu1
ii  libglade2-0 2.6.0-3

-code follows ---
#!/usr/bin/env python2.5

import pygtk
import gtk
import gtk.glade


glade_buffer = ?xml version=1.0 encoding=UTF-8 standalone=no?
!DOCTYPE glade-interface SYSTEM glade-2.0.dtd
!--Generated with glade3 3.2.0 on Thu Feb 14 10:01:52 2008 by
[EMAIL PROTECTED]
glade-interface
  widget class=GtkWindow id=window1
property name=eventsGDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK/property
child
  widget class=GtkVBox id=vbox1
property name=visibleTrue/property
property name=eventsGDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK/property
child
  widget class=GtkComboBox id=combobox1
property name=visibleTrue/property
property name=eventsGDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK/property
property name=wrap_width1/property
!--V  Note the items property --
property name=items translatable=yes/property
  /widget
/child
  /widget
/child
  /widget
/glade-interface


if __name__ == __main__:

xml = gtk.glade.xml_new_from_buffer(glade_buffer, len(glade_buffer))

combobox = xml.get_widget('combobox1')

liststore = gtk.ListStore(str)
liststore.append(['first'])
liststore.append(['second'])

combobox.set_model(liststore)

cell = gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.set_attributes(cell, text=0)

w = xml.get_widget('window1')
w.show_all()
gtk.main()

-- 

Edward Stow
attachment: duplicate_columns.png___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Toolbar layout button to right

2008-02-19 Thread Edward Stow
Hi,

I'm having trouble packing a toolbar.

I require a toolbar with 3 buttons packed to the left and one that is
always on the right. As illustrated below.

[Button1__Button2__Button3__Button4]

Packing the three to the left is ok.  This is the default behaviour of
glade when constructing the toolbar.

My question is how to have the right button (button4) on the right hand side.

I tried adding a ToolbarItem, with a HBox  and the button in the the
last hbox container.

Running this does not work - even though glade shows the button on the
right hand side.

Any suggestions:

Thanks
-- 

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


Re: [pygtk] Toolbar layout button to right

2008-02-20 Thread Edward Stow
On Wed, Feb 20, 2008 at 10:36 AM, Gian Mario Tagliaretti
[EMAIL PROTECTED] wrote:
 On Feb 20, 2008 12:21 AM, Edward Stow [EMAIL PROTECTED] wrote:

  Hi Edward,


   I'm having trouble packing a toolbar.
  
   I require a toolbar with 3 buttons packed to the left and one that is
   always on the right. As illustrated below.
  
   [Button1__Button2__Button3__Button4]

  You can use a gtk.SeparatorToolItem setting its expand property to True.
  http://www.pygtk.org/docs/pygtk/class-gtkseparatortoolitem.html

This almost works except when you set_visible_horizontal(False) - to
hide the vertical bar  naturally voids the expand property.

But using  a ToolItem does work:

   toolbar = gtk.Toolbar()

   sep = gtk.ToolItem()
   sep.set_expand(True)

   toolbar.insert(gtk.ToolButton(None, 'Button 1'), 0)
   toolbar.insert(sep, 1)
   toolbar.insert(gtk.ToolButton(None, 'Button 2'), 2)

-- 

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


Re: [pygtk] Toolbar layout button to right

2008-02-20 Thread Edward Stow
Hi again,

Glade does not appear to set the expand property on toolbar items ...
can this be verified?

Using glade 3.2.0 -- setting the packing expand option to Yes appears
to have no effect - when the ToolItem is created by gladed the expand
property is False.

Note that the Glade UI shows that the item has been expanded in the UI
builder but when running the application the item is not expanded.

Or am I just missing on some other option to be set.

Thanks

On Thu, Feb 21, 2008 at 5:16 AM, Edward Stow [EMAIL PROTECTED] wrote:
 On Wed, Feb 20, 2008 at 10:36 AM, Gian Mario Tagliaretti
  [EMAIL PROTECTED] wrote:


  On Feb 20, 2008 12:21 AM, Edward Stow [EMAIL PROTECTED] wrote:
  
Hi Edward,
  
  
 I'm having trouble packing a toolbar.

 I require a toolbar with 3 buttons packed to the left and one that is
 always on the right. As illustrated below.

 [Button1__Button2__Button3__Button4]
  
You can use a gtk.SeparatorToolItem setting its expand property to True.
http://www.pygtk.org/docs/pygtk/class-gtkseparatortoolitem.html


 This almost works except when you set_visible_horizontal(False) - to
  hide the vertical bar  naturally voids the expand property.

  But using  a ToolItem does work:

toolbar = gtk.Toolbar()

sep = gtk.ToolItem()
sep.set_expand(True)

toolbar.insert(gtk.ToolButton(None, 'Button 1'), 0)
toolbar.insert(sep, 1)
toolbar.insert(gtk.ToolButton(None, 'Button 2'), 2)

  --

  Edward Stow




-- 

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


Re: [pygtk] help with two main windows in pygtk

2008-02-20 Thread Edward Stow
Prashant:

On Thu, Feb 21, 2008 at 4:44 AM, Prashant Shah [EMAIL PROTECTED] wrote:
 I am making a PyGTK Application.

  I am using glade. I have made two Windows (main_window, new_company)
  and saved them within the same galde file and loading them using
  libglade (?)

  I have a button in the main_window which when clicked should show the
  new_comany window (within a vbox in the main window).

  I am not sure how to implement this using pygtk.

  Should I make a different class and different file for each Window ?
  This is going to be fairly big application.

  And how to load the the new_company window within a vbox in the main_window.

  This is the signal handler for the button click in the main
  window(mwglade). vbox_main is the vbox. new_comp_glade is the window
  for the new company.

  def new_file(self,widget,data=None):
 New data file
 self.new_comp_glade = self.mwglade.get_widget(new_company)
 self.vbox_main = self.mwglade.get_widget(vbox_main)
 self.vbox_main.add(self.new_comp_glade)


I'm not sure what you are trying to do  exactly but adding a
gtk.Window to a widget is not going to work.  Consider adding the
container (VBox, or HBox ) that is the child of the window

And I know that you cannot add a widget that already has a parent.

So consider unparent() 'ing the widget that you are adding to the vbox.

self.new_comp_glade = self.mwglade.get_widget(new_company)
self.vbox_main = self.mwglade.get_widget(vbox_main)

child = self.new_comp_glade.get_child()
if child:
# remove the child from the top window
self.new_comp_glade.remove(child)
self.vbox_main.add(child)

  This gives seg fault.

  Am I doing something wrong here since this is not making sense. I know
  I have messed up somewhere.
  ___
  pygtk mailing list   pygtk@daa.com.au
  http://www.daa.com.au/mailman/listinfo/pygtk
  Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/




-- 

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


Re: [pygtk] help with two main windows in pygtk

2008-02-21 Thread Edward Stow
On Fri, Feb 22, 2008 at 3:28 AM, Prashant Shah [EMAIL PROTECTED] wrote:
   self.new_comp_glade = self.mwglade.get_widget(new_company)
self.vbox_main = self.mwglade.get_widget(vbox_main)
  
child = self.new_comp_glade.get_child()
if child:
   # remove the child from the top window
   self.new_comp_glade.remove(child)
   self.vbox_main.add(child)

  Cool !! It works :) Thanks a lot !!!

  I am making a small financial app in pygtk (gpl)

  glade file :
  http://rapidshare.com/files/93713518/main.glade.html

  I have a =MainWindow= window (hbox: menubar, statusbar, a central main
  area where all the stuff is displayed) with a menu item called create
  company. On clicking create company - it has to open the
  =CreateCompany= window in the central main area.

  I have made different windows for vouchers/reports. For every action
  it will load the windows in the central main area.

  I dont know whether this is the rightway - I just took a guess.

  Also should I use seperate python files for each gtk window or how is it 
 done ??

I use one glade file that contains many top level windows - each top
window contains a child container that is reparented as needed.  Each
of these containers is represented by a View class (a python class,)
each View subclass knows how to initialise the view, populate widgets
with model data, and respond to events.

I keep each view class in a separate *.py file.

Whether this the 'python way' I don't know.

Suggest you read up on Model View Controller / Model View Presenter patterns.

Martin Fowler is a starting point
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] GObject signals subclassing

2008-03-07 Thread Edward Stow
Hi

I am creating a custom subclass of gtk.Widget and was looking for
better documentation on creating custom signals.
I have located the tutorial [1] on subclassing gobject and the
pygobject reference documentation [2].

1.  Could somebody point me towards reference documentation for
__gsignals__ class variable?

2.  The subclassing gobject toturial[1] suggests that you use
__gobject_init__() if you are subclassing a derivative of gobject as
calling the derivative__init__() will overwrite your custom
properties.  I assume that this does not apply to custom signals
defined in __gsignals__ ?  I could not detect any negative effects in
my subclass of gtk.Widget

3.  Class closures.  I was looking for a better explanation of the
GObject class closure methods.  Eg from the signals.py source in the
gobject source.

def do_my_signal(self, arg):
print C: class closure for `my_signal' called with argument, arg

This method only appears to be a callback method for the 'my_signal'
signal -- does it have any other purpose?

The tutorial also suggests that class closures are optional.  Under
what conditions are they needed?

It would be useful to link the gobject tuturial from the pygtk.org site.

[1] http://www.sicem.biz/personal/lgs/docs/gobject-python/gobject-tutorial.html

[2]http://www.pygtk.org/docs/pygobject/
-- 

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