Re: [pygtk] repetitive get_widget() using Glade?

2004-08-11 Thread Johan Dahlin
> > Johan> 2) Call glade.XML again to reparse (and recreate all widgets)
> > 
> > Sounds expensive. :-(
>
>   No, it is not.  libglade automatically caches XML trees, so only the
> first time is the XML file really opened and parsed.  Subsequent
> invocations with same parameters merely construct the widget tree from
> the description in memory.
> 
> 
And it's not like parsing XML would be very expensive anyway.

-- 
Johan Dahlin <[EMAIL PROTECTED]>

___
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] repetitive get_widget() using Glade?

2004-08-11 Thread Christian Robottom Reis
On Wed, Aug 11, 2004 at 04:41:11PM -0400, John Ehresman wrote:
> Skip Montanaro wrote:
> >But when the user pokes the "x" won't the underlying X windows be 
> >destroyed?
> >Is there a way to catch the destroy signal and avoid the window 
> >destruction?
> 
> Connect to the 'delete_event' signal on the window.  Return False if you 
> want the default handler to destroy the window and True to indicate that 
> you've handled the event and the default handler should not be invoked.

And yes, that's in the FAQ:

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq10.006.htp

> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 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] repetitive get_widget() using Glade?

2004-08-11 Thread Gustavo J. A. M. Carneiro
A Qua, 2004-08-11 às 21:31, Skip Montanaro escreveu:
> >> How do I convince Glade to create new Window and TextView widgets on
> >> subsequent calls to get_widget()?
> 
> Johan> Two possible solutions:
> 
> Johan> 1) Don't destroy the window, just hide it.
> 
> But when the user pokes the "x" won't the underlying X windows be destroyed?
> Is there a way to catch the destroy signal and avoid the window destruction?
> I'd happily just hide the window, but that doesn't seem to work either.
> 
> Johan> 2) Call glade.XML again to reparse (and recreate all widgets)
> 
> Sounds expensive. :-(

  No, it is not.  libglade automatically caches XML trees, so only the
first time is the XML file really opened and parsed.  Subsequent
invocations with same parameters merely construct the widget tree from
the description in memory.

> 
> Thanks for the ideas...
> 
> Skip
> 
> ___
> pygtk mailing list   [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic

___
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] repetitive get_widget() using Glade?

2004-08-11 Thread Skip Montanaro

John> Connect to the 'delete_event' signal on the window.  Return False
John> if you want the default handler to destroy the window and True to
John> indicate that you've handled the event and the default handler
John> should not be invoked.

Thanks a million.  Worked like a charm...

Skip
___
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] Invalid TreeIter from custom treemodel

2004-08-11 Thread John Finlay
Vitaly Ostanin wrote:
John Finlay wrote:

Execution of my program output on stderr:
** (pix.py:11897): CRITICAL **: file pygtktreemodel.c: line 739 
(pygtk_generic_tree_model_ref_node): assertion `VALID_ITER(iter, 
tree_model)' failed

Please, tell me, how I can get valid custom iters from XML node 
pointer ?

pygtk-2.3.94
libgtk+2-2.4.4
libxml2-python-2.6.11-alt1
Python 2.3.3
What code is generating the warning message? The above code doesn't 
deal with TreeIters.

May be :) Full example is attached.
Your custom model has a couple of broken methods:
on_iter_n_children() and on_iter_nth_child()
These do not properly handle the case where iter or parent is None. 
These special cases indicate the toplevel rows should be used. See:

file:///usr/local/doc/pygtk2reference/class-gtktreemodel.html#method-gtktreemodel--iter-n-children 

file:///usr/local/doc/pygtk2reference/class-gtktreemodel.html#method-gtktreemodel--iter-nth-child 


for more info. As a guess you should start each with something like:
if not node:
   node = self.doc
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/


Re: [pygtk] repetitive get_widget() using Glade?

2004-08-11 Thread John Ehresman
Skip Montanaro wrote:
But when the user pokes the "x" won't the underlying X windows be destroyed?
Is there a way to catch the destroy signal and avoid the window destruction?
Connect to the 'delete_event' signal on the window.  Return False if you 
want the default handler to destroy the window and True to indicate that 
you've handled the event and the default handler should not be invoked.

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/


Re: [pygtk] repetitive get_widget() using Glade?

2004-08-11 Thread Skip Montanaro

>> How do I convince Glade to create new Window and TextView widgets on
>> subsequent calls to get_widget()?

Johan> Two possible solutions:

Johan> 1) Don't destroy the window, just hide it.

But when the user pokes the "x" won't the underlying X windows be destroyed?
Is there a way to catch the destroy signal and avoid the window destruction?
I'd happily just hide the window, but that doesn't seem to work either.

Johan> 2) Call glade.XML again to reparse (and recreate all widgets)

Sounds expensive. :-(

Thanks for the ideas...

Skip

___
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] repetitive get_widget() using Glade?

2004-08-11 Thread Johan Dahlin
ons 2004-08-11 klockan 21.58 skrev Skip Montanaro:
> I have a simple popup window that contains a TextView widget.  The TV is
> tied to a Python interpreter (code.InteractiveConsole).  The window and TV
> are defined in Glade.  Works great the first time I ask to display it.
> 
> If I poke the "X" button in the window's title bar to destroy it I delete my
> objects (the corresponding X windows are going away, after all) in my
> destroy event handler.  I want to create a new instance the next time I
> select "Interpreter Window" from my debug menu.  Unfortunately, when I call
> .get_widget(...) a second time it returns None instead of a new TextView or
> Window.  How do I convince Glade to create new Window and TextView widgets
> on subsequent calls to get_widget()?

Two possible solutions:

1) Don't destroy the window, just hide it.

2) Call glade.XML again to reparse (and recreate all widgets)

-- 
Johan Dahlin <[EMAIL PROTECTED]>

___
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] repetitive get_widget() using Glade?

2004-08-11 Thread Skip Montanaro

I have a simple popup window that contains a TextView widget.  The TV is
tied to a Python interpreter (code.InteractiveConsole).  The window and TV
are defined in Glade.  Works great the first time I ask to display it.

If I poke the "X" button in the window's title bar to destroy it I delete my
objects (the corresponding X windows are going away, after all) in my
destroy event handler.  I want to create a new instance the next time I
select "Interpreter Window" from my debug menu.  Unfortunately, when I call
.get_widget(...) a second time it returns None instead of a new TextView or
Window.  How do I convince Glade to create new Window and TextView widgets
on subsequent calls to get_widget()?

Thx,

-- 
Skip Montanaro
Got gigs? http://www.musi-cal.com/submit.html
Got spam? http://www.spambayes.org/
[EMAIL PROTECTED]
___
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] Mnemonic broken after adding widget?

2004-08-11 Thread John Finlay
Stephen Kennedy wrote:
I'm trying to improve keyboardability and want to focus the first widget
on a notebook page when switching pages with mnemonics, but not with
arrow keys.
However, mnemonic-activate is not fired if I connect to it after adding
the tab. It's work-aroundable in code but obviously breaks with glade.
See the attached test case. 
 

The notebook's internal "mnemonic-activate" handler stops handlers 
connected after it from being activated.

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/


Re: [pygtk] Invalid TreeIter from custom treemodel

2004-08-11 Thread Vitaly Ostanin
John Finlay wrote:

Execution of my program output on stderr:
** (pix.py:11897): CRITICAL **: file pygtktreemodel.c: line 739 
(pygtk_generic_tree_model_ref_node): assertion `VALID_ITER(iter, 
tree_model)' failed

Please, tell me, how I can get valid custom iters from XML node pointer ?
pygtk-2.3.94
libgtk+2-2.4.4
libxml2-python-2.6.11-alt1
Python 2.3.3
What code is generating the warning message? The above code doesn't deal 
with TreeIters.
May be :) Full example is attached.
--
Regards, Vyt
mailto:  [EMAIL PROTECTED]
JID: [EMAIL PROTECTED]


pix.tar.bz2
Description: application/bzip
___
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] Invalid TreeIter from custom treemodel

2004-08-11 Thread John Finlay
Vitaly Ostanin wrote:
Hello.
I write custom TreeModel, derived from gtk.GenericTreeModel. This 
TreeModel works with XML tree from libxml2-python.

Iters values is XML node references by libxml2-python:
def on_get_iter(self, path):
node = self.doc.getRootElement()
for i in path[1:]:
if node == None:
return None
node=self.on_iter_nth_child(node,i)
if self.is_cell(node) == gtk.FALSE:
return None
return node
Execution of my program output on stderr:
** (pix.py:11897): CRITICAL **: file pygtktreemodel.c: line 739 
(pygtk_generic_tree_model_ref_node): assertion `VALID_ITER(iter, 
tree_model)' failed

Please, tell me, how I can get valid custom iters from XML node pointer ?
pygtk-2.3.94
libgtk+2-2.4.4
libxml2-python-2.6.11-alt1
Python 2.3.3
What code is generating the warning message? The above code doesn't deal 
with TreeIters.

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/


[pygtk] Mnemonic broken after adding widget?

2004-08-11 Thread Stephen Kennedy

I'm trying to improve keyboardability and want to focus the first widget
on a notebook page when switching pages with mnemonics, but not with
arrow keys.

However, mnemonic-activate is not fired if I connect to it after adding
the tab. It's work-aroundable in code but obviously breaks with glade.
See the attached test case. 

Ideas?
Stephen.
-- 
Stephen Kennedy <[EMAIL PROTECTED]>
http://meld.sf.net visual diff and merge


testmnemonic.py
Description: application/python
___
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] Invalid TreeIter from custom treemodel

2004-08-11 Thread Vitaly Ostanin
Hello.
I write custom TreeModel, derived from gtk.GenericTreeModel. This 
TreeModel works with XML tree from libxml2-python.

Iters values is XML node references by libxml2-python:
def on_get_iter(self, path):
node = self.doc.getRootElement()
for i in path[1:]:
if node == None:
return None
node=self.on_iter_nth_child(node,i)
if self.is_cell(node) == gtk.FALSE:
return None
return node
Execution of my program output on stderr:
** (pix.py:11897): CRITICAL **: file pygtktreemodel.c: line 739 
(pygtk_generic_tree_model_ref_node): assertion `VALID_ITER(iter, 
tree_model)' failed

Please, tell me, how I can get valid custom iters from XML node 
pointer ?

pygtk-2.3.94
libgtk+2-2.4.4
libxml2-python-2.6.11-alt1
Python 2.3.3
--
Regards, Vyt
mailto:  [EMAIL PROTECTED]
JID: [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/