[pygtk] Updating the Display

2003-03-21 Thread Jesse Pavel


Hi everyone,

I'm having an issue in having a dialog display its
contents immediately--I want to display a message to
the user before a long operation begins, and so
I create a dialog, stick a label in it, and show it.
Normally, the contents are not displayed until my lengthy
callback finishes; I've tried putting a

while gtk.events_pending():
gtk.main_iteration()

immediately after the dialog.show(), but that isn't
working.

Can someone fill me in on what I'm doing wrong?

Thanks,
Jesse
___
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] gtk_tree_selection_get_selected_rows()?

2003-03-21 Thread Johan Dahlin
fre 2003-03-21 klockan 23.10 skrev Greg Ward:
> I'm playing around with a GtkTreeView widget with multiple selection.
> Looks like gtk_tree_selection_get_selected_rows() (aka
> TreeView.get_selected_rows()) isn't wrapped in pygtk 1.99.15.  ;-(  I
> think I can workaround it using TreeView.selected_foreach(), but
> that's a bit awkward.  Is this a deliberate omission, a known oversight,
> or a minor detail that got left out by mistake?

get_selected_rows() was actually introduced in Gtk+ 2.2

PyGtk 1.99.x is still aimed at Gtk+ 2.0 (so we won't delay PyGtk 2.0
even further)

I guess you have to wait or use get_selected_foreach() for now I'm
afraid.
Or just write your own get_selected_row() in python since it's a quite
trivial function.

-- 
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source

___
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] gtk_tree_selection_get_selected_rows()?

2003-03-21 Thread Greg Ward
I'm playing around with a GtkTreeView widget with multiple selection.
Looks like gtk_tree_selection_get_selected_rows() (aka
TreeView.get_selected_rows()) isn't wrapped in pygtk 1.99.15.  ;-(  I
think I can workaround it using TreeView.selected_foreach(), but
that's a bit awkward.  Is this a deliberate omission, a known oversight,
or a minor detail that got left out by mistake?

Greg
-- 
Greg Ward <[EMAIL PROTECTED]> http://www.gerg.ca/
Vote Cthulhu -- why settle for a lesser evil?
___
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] threading problem

2003-03-21 Thread Pablo Endres

Hi Guys,

I'm working on a monitoring software that has a notebook.
The firstpage is a drawing area (the expose event draws
a pixmap with the image), the other pages contain a progress bar
and a textbox. 

I have a thread for each machine being monitored, that 
updates the DA and in error list when a problem is detected.

When this happens normally the user would access the page in 
the notebook containing the detailed information of the error.
On expose of this page an dialog with the error info is displayed.

The problem comes when the dialog is closed.  With this event
I clear() the error dict, but after that the corresponding thread 
gets caught in a sleep() and never wakes up.

Any ideas on what the cause of this "sleeping beaty" can be?

thanks in advance

-- 
Democracy is two wolves and a sheep voting on what to have for dinner.
Liberty is two wolves attempting to have a sheep for dinner and
finding a well-informed, well-armed sheep.


Pablo Endres
Centro de Datos

GSM:  +584127347610

___
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] VTK

2003-03-21 Thread John Hunter
> "George" == George A Dowding <[EMAIL PROTECTED]> writes:

George> Hello, I am looking for information on using Pygtk and
George> VTK.  I haven't come across anything that explains how to
George> do that.  If anybody can point me in the right direction,
George> I would appreciated it.

If you look in Wrapping/Python/vtk/gtk/ you'll see a class
GtkVTKRenderWindow that contains a demo in the __main__ section at the
bottom.  Currently, this works only with a patched version of pygtk
provided by John K Luebs that exposes xid.  You'll have to rebuild
pygtk from cvs with this patch.

It appears that people are moving to gtkglext, however, so I recently
adapted the gtkgl render window that ships with vtk to work with
gtkglext.  The same patch caveat applies.

Also, it currently only works under X windows because I am having
trouble getting pygtkglext working under win32 and hence can't test
the use of hwnd in place of xid for the gtkglext code.  But I expect
to have this resolved soon.  If you need this platform, let me know
and I can provide you with an installer.

Here is some demo code and the gtkglext render window class

The xid, hwnd patch
--- pygtk-1.99.15/gtk/gdk.override.orig	2003-03-07 15:12:46.0 -0500
+++ pygtk-1.99.15/gtk/gdk.override	2003-03-07 15:33:16.0 -0500
@@ -15,6 +15,12 @@
 #  include 
 #endif
 
+#if defined(GDK_WINDOWING_X11)
+#include 
+#elif defined(GDK_WINDOWING_WIN32)
+#include 
+#endif
+
 extern PyTypeObject PyGtkWidget_Type;
 
 %%
@@ -1844,6 +1850,30 @@
 return Py_None;
 }
 %%
+override-slot GdkWindow.tp_getattr
+PyObject *
+_wrap_gdk_window_tp_getattr(PyGObject *self, char *attr)
+{
+GdkWindow *window = GDK_WINDOW(self->obj);
+
+#if defined(GDK_WINDOWING_WIN32)
+if (!strcmp(attr, "hwnd")) {
+	return PyLong_FromVoidPtr(GDK_WINDOW_HWND(window));
+}
+#elif defined(GDK_WINDOWING_X11)
+if (!strcmp(attr, "xid")) {
+	return PyLong_FromUnsignedLong(GDK_WINDOW_XID(window));
+}
+#endif
+
+{
+	PyObject *name = PyString_FromString(attr);
+	PyObject *ret = PyObject_GenericGetAttr((PyObject *)self, name);
+	Py_DECREF(name);
+	return ret;
+}
+}
+%%
 override gdk_window_get_geometry noargs
 static PyObject *
 _wrap_gdk_window_get_geometry(PyGObject *self)

The gtkglext class:


GtkGLExtVTKRenderWindow.py
Description: Binary data

Some demo code:


cylinder_demo.py
Description: Binary data


I'm using CVS pygtk1.99.15, VTK4.2 and python 2.2 on redhat linux 8.

If you need more info or help, let me know.

John Hunter
___
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] Mishandled exception

2003-03-21 Thread Johan Dahlin
> is the right place to do it?  If so, a link from the pygtk home page
> might be a good idea...

It's the right place, gnome-python product, pygtk component.

Yes, this is a good idea.

James, could you add a link, please?

-- 
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source

___
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] Mishandled exception

2003-03-21 Thread Greg Ward
On 21 March 2003, Johan Dahlin said:
> However, it's a bit risky reporting stuff here on the mailing list,
> since it's easy to "lose" them. It's better to report stuff in bugzilla,
> cause they will stay there and annoy us until they're fixed.

OK, I'm doing so now.  I presume this:

  http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-python

is the right place to do it?  If so, a link from the pygtk home page
might be a good idea...

Greg
-- 
Greg Ward <[EMAIL PROTECTED]> http://www.gerg.ca/
God is real, unless declared integer.
___
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] Mishandled exception

2003-03-21 Thread Johan Dahlin
fre 2003-03-21 klockan 12.41 skrev Greg Ward:
> I was just playing around with GtkListStore, and I think I've found a
> simple-but-subtle bug in pygtk: an exception condition is not being
> correctly returned to Python.  Illustration:
> 
> $ python
> Python 2.2.2 (#1, Jan 18 2003, 10:18:59) 
> [GCC 3.2.2 20030109 (Debian prerelease)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import gtk
> >>> gtk.ListStore() <<< should raise TypeError, I guess
> 
> >>> adsfasf <<< should definitely raise NameError
> TypeError: GtkListStore requires at least one argument

I've seen this behavior before, but I never got around to fix it.

The problem was that the constructor of GtkListStore (and GtkTreeStore
too) was treated as a normal function, eg returning NULL on error
instead of -1.

Thanks for reporting it.

However, it's a bit risky reporting stuff here on the mailing list,
since it's easy to "lose" them. It's better to report stuff in bugzilla,
cause they will stay there and annoy us until they're fixed.

-- 
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source

___
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] Mishandled exception

2003-03-21 Thread Greg Ward
I was just playing around with GtkListStore, and I think I've found a
simple-but-subtle bug in pygtk: an exception condition is not being
correctly returned to Python.  Illustration:

$ python
Python 2.2.2 (#1, Jan 18 2003, 10:18:59) 
[GCC 3.2.2 20030109 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
>>> gtk.ListStore() <<< should raise TypeError, I guess

>>> adsfasf <<< should definitely raise NameError
TypeError: GtkListStore requires at least one argument
>>> adsfasf
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'adsfasf' is not defined

Same problem if I pass 1 argument to ListStore:

>>> gtk.ListStore(2)

>>> asdf
TypeError: could not get typecode from object

I'm pretty sure this is just a case of some wrapper code forgetting to
return NULL to its caller when an exception has been set.  Oh yeah, this
is GTK+ 2.2.1 and pygtk 1.99.15.

James, is that enough info to track down the bug?

Greg
-- 
Greg Ward <[EMAIL PROTECTED]> http://www.gerg.ca/
Sure, I'm paranoid... but am I paranoid ENOUGH?
___
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] Changing a SpinButton's maximum value

2003-03-21 Thread Greg Ward
On 21 March 2003, James Henstridge said:
> For pygtk-1.99.x, the above style of updating the adjustment will work 
> (assigning to the attribute).

OK, I've upgraded to GTK+ 2.0 and pygtk 1.99.x, and indeed
"adjustment.upper = x" works fine.  But, there's just one teeny-tiny
itsy-bitsy little glitch:

  adjustment.upper = 5

barfs with

  TypeError: upper must be a double

which is just the sort of annoying C-level detail that Python
programmers don't normally have to deal with.

Thanks for the help!

Greg
-- 
Greg Ward <[EMAIL PROTECTED]> http://www.gerg.ca/
If you and a friend are being chased by a lion, it is not necessary to
outrun the lion.  It is only necessary to outrun your friend.
___
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] connect_after does not work for treeview

2003-03-21 Thread James Henstridge
Maik Hertha wrote:

The difference to the 0.6.x code is, that I include the return statements in the 
functions with
FALSE. If I do a signal_connect I get a deadlock situation with the dialog window 
which is called via
Set_options_button.clicked().
Could it be a bug anyway ?
 

The behaviour was implemented in GTK 2.0.  It is different to GTK 1.2, 
but it is not considered a bug.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


___
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] connect_after does not work for treeview

2003-03-21 Thread Stephen Kennedy
> For the standard widget event signals, a custom accumulator is set.  
> When going through the list of handlers to call for the signal, the 
> process goes like this:
>1. call handler
>2. if it returned True, skip the rest of the handlers in 
> the list and return True
>3. otherwise, continue to the next handler
> GtkTreeView handles button press events, so its handler will return 
> True.  If you have a handler further down the list, then it won't get 
> called.

OK, thats what I got from the gobject docs. Whats I think is a bug
is that the default handler returns true which means that 'after' handlers
can never be called unless the default handler is explicitly blocked.
I think it's much more natural for the default handlers to return false.

Anyhoo, the behaviour I was trying to fix is that if a treeview had no
items selected and right mouse button was pressed, that the item under
the mouse should be selected before the context menu pops up.

In the end I used treeview.get_path_at_pos and treeview.set_cursor
just before the popup.

Stephen.

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

___
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] connect_after does not work for treeview

2003-03-21 Thread Maik Hertha
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Answer from Christian Reis
> 
> Plain "connect" works fine, but the "connect_after"
> callback does not get called.
> Or am I doing something wrong? See attached example.

There might be a default handler that is returning TRUE somewhere that is running 
after your connect()ed handler, but I'm not sure. A simple code snippet would have 
perhaps been easier to grasp, though :-)

Answer from James:  
Stephen Kennedy wrote:

>Plain "connect" works fine, but the "connect_after"
>callback does not get called.
>Or am I doing something wrong? See attached example.
>  
>
No bug here.

For the standard widget event signals, a custom accumulator is set.  
When going through the list of handlers to call for the signal, the 
process goes like this:

   1. call handler
   2. if it returned True, skip the rest of the handlers in the list and
  return True
   3. otherwise, continue to the next handler

GtkTreeView handles button press events, so its handler will return 
True.  If you have a handler further down the list, then it won't get 
called.

- --- reply

So far so good. But I have the same problem with the good old Clist. There is the same 
situation.

- --- snippet - connect

self.user_printers_clist.connect('select-row', self.onRowSelected)
self.user_printers_clist.connect('unselect-row',   self.onRowSelected)
self.user_printers_clist.connect_after('button_press_event', 
self.onRowBtn2Clicked)

- --- snippet - methods

def onRowBtn2Clicked(self, clist, ev):
''' verarbeitet doppelklicks auf die zeilen  '''
# print clist.selection, ev.button, ev.type
if not clist.selection:
return
data = clist.get_row_data( clist.selection[0] )
# if there is a double click, call the dialog via signal-propagation
if ev.button == 1 and ev.type == 5:
self.set_options_button.clicked()
return FALSE

def onRowSelected(self, clist, row, *args):
''' aktiviere und deaktiviere die aktionsknöpfe '''
#print clist.selection, clist.get_data('user-item-data')
if len(clist.selection) > 0:
_status = TRUE
_p = clist.get_row_data( clist.selection[0] )
else:
_status = FALSE

if clist.get_data('user-item-data') == 'system-to-user':
self.select_printer_button.set_sensitive( _status )

elif clist.get_data('user-item-data') == 'user-to-system':
_val = _status
if _status and _p.name == 
self.default_printer_label.get_text():
_val = not _status
self.set_default_button.set_sensitive( _val )
self.deselect_printer_button.set_sensitive( _status )
self.set_options_button.set_sensitive( _status )
return FALSE

- --- snippet end.
The difference to the 0.6.x code is, that I include the return statements in the 
functions with
FALSE. If I do a signal_connect I get a deadlock situation with the dialog window 
which is called via
Set_options_button.clicked().

Could it be a bug anyway ?

Enlightment is appreciated :-)

- --maik./

mit freundlichem Gruß /
with best regards

Maik Hertha
- 
hartmann+hertha
it design

mhertha at hartmann-hertha.de
http://www.hartmann-hertha.de
- 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQE+euNwbd3QGXGos6ERAmrfAJ9RcZMgWPvpCS9t8Y4zEhD0ScuzqwCggZV1
MH/smiX8pYOGpmjANWqBzjk=
=cbWc
-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/