[PyGTK] forbid focus of TreeView columns

2005-02-21 Thread Franck Pommereau
Hi all,
I'm building a PyGTK interface in which I would like that no widget 
would be able to get the focus (and so to be activated by pressing the 
Return key). For this purpose, for each widget, I do:

widget.set_property("can-focus", gtk.FALSE)
My problem is a TreeView which has a clickable column, it get the 
default focus and I did not find how to forbid that.

I tried:
def focus (widget, *args) :
try :
widget.set_property("can-focus", gtk.FALSE)
except :
pass
try :
widget.set_property("can-default", gtk.FALSE)
except :
pass
win.forall(focus)
where win is my application window (I also tried on the TreeView) but it 
doesn't work.  :-(
I also tried with widget.unset_flags, same result.  :-((

If I choose another widget and give it the default focus 
(widget.grab_default and widget.grab_focus) it's OK until I click on the 
column which then keeps the focus.  :-(((

I'm sure I could capture the Return key but I don't want to have this 
dashed line around the focused widget...

I think that this column has somewhere an associated widget but I could 
not find it anywhere (and neither could win.forall).

I'm using PyGTK-2.0.0 and cannot use another version.
Thanks in advance for any idea!
Franck
--
http://mail.python.org/mailman/listinfo/python-list


[PyGTK] Resizing a HandleBox

2005-02-21 Thread Franck Pommereau
Hi all,
I'm using PyGTK-2.0.0, when I detach a HandleBox, the resizing of the 
newly created window is broken: it can be resized but it's content (the 
HandleBox and its child) is not affected at all and is not resized.

Does any one have a solytion to this problem?
Thanks in advance!
Franck
--
http://mail.python.org/mailman/listinfo/python-list


Re: Setting sizes of widgets (PyGTK)

2005-03-11 Thread Franck Pommereau
Harlin Seritt wrote:
I have the following code and I would like to know how to set the
length and width of widgets like Buttons. When the window opens the
button fills up the space even though I have told it not to.
Your button is stretched horizontally because there is nothing to put 
around it in order to fill the space. Try to embed it into a HBox, 
surrounded by empty labels :

import pygtk, gtk
class Greeter:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.box = gtk.VBox()
self.window.add(self.box)
self.label = gtk.Label("Please enter your name in the box 
below:")
self.namebox = gtk.Entry(12)
self.button = gtk.Button("Greet Me!")
self.output = gtk.Label("Your output will appear here.")
		hbox = gtk.HBox()
self.box.pack_start(self.label, False, False, 2)
self.box.pack_start(self.namebox, False, False, 2)
hbox.add(gtk.Label())
hbox.pack_start(self.button, False, False, 2)
hbox.add(gtk.Label())
self.box.pack_start(hbox, False, False, 2)
		self.box.pack_start(self.output, False, False, 2)
		self.window.show_all()
def main(self):
gtk.main()

a = Greeter()
a.main()
Cheers,
Franck
--
http://mail.python.org/mailman/listinfo/python-list


The problem of anonymity with decorators

2006-02-07 Thread Franck Pommereau
Dear all,

I would like to work around the "anonymizing" effect of decorators when
an exception is raised in the wrapped function. Let's consider the
following example:

def int_result (fun) :
def wrapped (*largs, **kwargs) :
result = fun(*largs, **kwargs)
if not isinstance(result, int) :
raise TypeError, "should return int"
return result
return wrapped

@int_result
def add (a, b) :
return a+b

print add(1, 2)
print add("foo", "bar")

As expected, the last line results in raising TypeError:

Traceback (most recent call last):
  File "wrapping.py", line 14, in ?
print add("foo", "bar")
  File "wrapping.py", line 5, in wrapped
raise TypeError, "should return int"
TypeError: should return int

My problem is that the errors comes from a function named "wrapped"
while I'd prefer to see here the name of the wrapped function. Indeed,
the code above is only a stripped down sample code but in my
application, I'll have a lot of functions, all wrapped the same way. So
I'd prefer a traceback like:

Traceback (most recent call last):
  File "wrapping.py", line 14, in ?
print add("foo", "bar")
  File "wrapping.py", line 8, in add (wrapped)
@int_result
TypeError: should return int

Where the exception seems to come from the point where add "was"
wrapped, instead of from the inside of the wrapper.

I tried to change wrapper.__name__ and wrapper.func_name but it does not
change the traceback, and wrapper.func_code.co_name is read-only. I also
tried, unsuccessfully, to rename functions with:

import new
def rename (fun, name) :
return new.function(fun.func_code, {}, name)

So, my questions:
 - can I change a function name so that it affects the traceback when an
   exception is raised in the function?
 - is there some special trick to raise an exception making it, in
   appearance, coming from somewhere else?

Thanks in advance for any answer.

Regards,
Franck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The problem of anonymity with decorators

2006-02-08 Thread Franck Pommereau
Alex, Michele and Skip,

Many thanks for your help, I should find my way by putting all these
information together.

Best regards,
Franck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to traverse network devices in our system?

2006-05-18 Thread Franck Pommereau
> Yes, it is Linux. I was just googling and found that there are kudzu
> bindings for python. From that i can query kudzu for any configured and
> unconfigured device (i hope so). is there any other method available
> other kudzu python bindings ?

I do it using DBus/Hal, for instance:

###
import dbus

system_bus = dbus.SystemBus()
hal_manager_obj = system_bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal_manager_obj,
 'org.freedesktop.Hal.Manager')

for udi in hal_manager.FindDeviceByCapability("net") :
obj = system_bus.get_object("org.freedesktop.Hal", udi)
dev = dbus.Interface(obj, 'org.freedesktop.Hal.Device')
print dev.GetProperty("net.interface"),
print dev.GetProperty("net.address")
###

Cheers,
Franck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / glade fundamentals

2006-03-20 Thread Franck Pommereau
> maybe you will find it easyer to use GladeGen to generate the
> skeleton of your application rather then coding it yourself. Take a
> look here: http://www.linuxjournal.com/article/7421

You may also use my PyGG module: http://freshmeat.net/projects/pygg

Cheers,
Franck
-- 
http://mail.python.org/mailman/listinfo/python-list


[Off topic] Re: Backing Up VMWare

2006-04-11 Thread Franck Pommereau
> Hello - has anyone written a Python script to backup VMWare servers?
> If so, I'd appreciate any pointers as to how to go about doing so.

Nothing to do with Python, but... Under Linux, VMware disks are
mountable using the script vmware-mount.pl, see:

  http://www.vmware.com/support/reference/linux/loopback_linux.html

Franck
-- 
http://mail.python.org/mailman/listinfo/python-list