[pygtk] Handling new foreign windows in pygtk app.

2010-01-19 Thread Radek Vykydal
Hello list,


I am trying to solve this problem:

In root-only environment (Anaconda installer) we are running very simple
C window manager (only taking care of setting focus of windows), Anaconda
pygtk GUI, and on demand nm-connection-editor (C Gtk+ application) can 
be run.

In Anaconda (the pygtk app) I have class (constructor is taking Xid of 
window)
for embedding nm-c-e foreign window using gtk.Socket. What I need now is 
a mechanism
for notifying about appearing nm-c-e windows (providing their Xid), idally
it would allow to set a callback on event/notification.

My last idea was:
- catch CreateNotify events in the C window manager
- 'forward' them via ClientMessage to Anaconda pygtk app
  (to a window W specified/found in window manager by its wmname),
  sending Xid of created window
- in Anaconda pygtk app set client-event callback on the window W
  which will use Xid to (eventually) embed the created window

Does it sound like it could work?
Especially, is X ClientMessage received in pyGtk app generating 
client-event Gtk signal?

I made an example but it doesn't work - base.py doesn't call the ce-cb 
callback when
I seem to send ClientMessage to its window.

I run two python processes (in my environment, metacity wm is running).


base.py:

#!/usr/bin/python

import pygtk
import gtk

def ce_cb(widget, event):
print "Got client event!"

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
# This doesn't help
#window.add_events(gtk.gdk.CLIENT_EVENT)
window.connect("client-event", ce_cb)
window.show()

gtk.main()


send_event.py:

#!/usr/bin/python

import sys
import Xlib
from Xlib import display
from Xlib.protocol import event

d = display.Display()
s = d.screen()
children = s.root.query_tree().children

for c in children:
if c.get_wm_name() == "base.py":
break
else:
print "ERROR: base.py not found"
sys.exit(1)

# here I don't know exactly what I am doing to be honest
atom = d.intern_atom('WINDOW')

cm = event.ClientMessage(window = c,
 client_type = atom,
 data = (8, "01234567890123456789"))

c.send_event(cm)
d.flush()


What I am doing wrong?
Or is my whole concept wrong?


Thanks,

Radek



___
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] integration of C gtk app into pygtk app (in limited environment)

2010-01-13 Thread Radek Vykydal
On 01/13/2010 09:01 PM, Radek Vykydal wrote:
> Hello list,
>
> I am trying to integrate nm-connection-editor which is C gtk app into
> Anaconda installer
> python GUI. There is a limited mini-wm window manager running in the
> environment.
> My goal is to take control over the nm-connection-editor window when the
> nm app
> is run (python UI being already running) so that:
>
> * the nm window behaves as modal
>I was experimenting with something like this:
>
> http://www.redhat.com/archives/anaconda-devel-list/2010-January/msg00037.html
>
>which basically means:
>- creating new gdk window from xid of nm-connection-editor
>- setting some python UI window as transient for it
>- setting modal hint of nm-connection-editor window to true
>
>but couldn't get it working (modality of nm window)
>
> * I can handle limited resolution of the python UI (800x600).
>- Moving nm window to the top a bit doesn't help because next
> window/dialog run
>from it is placed in the center again.
>
> Do you have any hints or pointers?
>
>

Hm, I've just found Gtk.Socket - can this be a way to go?

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


[pygtk] integration of C gtk app into pygtk app (in limited environment)

2010-01-13 Thread Radek Vykydal
Hello list,

I am trying to integrate nm-connection-editor which is C gtk app into 
Anaconda installer
python GUI. There is a limited mini-wm window manager running in the 
environment.
My goal is to take control over the nm-connection-editor window when the 
nm app
is run (python UI being already running) so that:

* the nm window behaves as modal
  I was experimenting with something like this:

http://www.redhat.com/archives/anaconda-devel-list/2010-January/msg00037.html

  which basically means:
  - creating new gdk window from xid of nm-connection-editor
  - setting some python UI window as transient for it
  - setting modal hint of nm-connection-editor window to true

  but couldn't get it working (modality of nm window)

* I can handle limited resolution of the python UI (800x600).
  - Moving nm window to the top a bit doesn't help because next 
window/dialog run
  from it is placed in the center again.

Do you have any hints or pointers?

Thanks,

Radek
___
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] interference between gtk.gdk.threads_init() and SIGCHLD handling

2005-08-11 Thread Radek Vykydal
On Thu, 2005-08-11 at 15:26 +0100, Gustavo J. A. M. Carneiro wrote:
> On Thu, 2005-08-11 at 16:21 +0200, Radek Vykydal wrote:
> > Hello,
> > 
> > I wrote a python module which forks and execes a child.
> > In the parent I made (with signal.signal()) handler to
> > catch SIGCHLD and the parent calls gtk.main() to wait for the
> > child's exit(). The SIGCHLD handler calls os.waitpid()
> > and gtk.main_quit().
> > 
> > The module works fine alone, but when I incorporate it
> > into application which is calling gtk.gdk.threads_init() before
> > running it's mainloop, the
> > SIGCHLD handler isn't called (after the the child's exit()).
> > 
> > Could you tell me the reason and, possibly, recommend me
> > how I can wait for the child in better way?
> 
> (requires pygtk >= 2.6)
> 
> def child_cb(pid, status):
> # do something
> 
> gobject.child_watch_add(pid, child_cb)
> 

unfortunately, I must use pygtk 2.0

___
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] interference between gtk.gdk.threads_init() and SIGCHLD handling

2005-08-11 Thread Radek Vykydal
Hello,

I wrote a python module which forks and execes a child.
In the parent I made (with signal.signal()) handler to
catch SIGCHLD and the parent calls gtk.main() to wait for the
child's exit(). The SIGCHLD handler calls os.waitpid()
and gtk.main_quit().

The module works fine alone, but when I incorporate it
into application which is calling gtk.gdk.threads_init() before
running it's mainloop, the
SIGCHLD handler isn't called (after the the child's exit()).

Could you tell me the reason and, possibly, recommend me
how I can wait for the child in better way?

Thanks,

Radek

___
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] how to have tkwait in pyGTK

2005-07-28 Thread Radek Vykydal
Hello,

how can I do something like tkwait from Tcl/Tk in pyGTK (Python)

I need to stop processing the code while waiting for
results of dialog. 
(Actually I need to implement my own run() method in a class
derived from MessageDialog).

Thanks, Radek 


___
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/