Re: Some issues calling atk methods
- From: Piñeiro <apinheiro igalia com>
- To: danw gnome org
- Cc: gnome-shell-list gnome org
- Subject: Re: Some issues calling atk methods
- Date: Wed, 18 Aug 2010 18:32:55 +0200 (CEST)
From: Dan Winship <danw gnome org>
JFYI
> Does this work usefully in other language bindings? I think this is just
> considered bad class design, and the answer is "don't do that then"...
Although the thread is over, to fullfill my curiosity, I was testing
this issue with python.
Although initially I have a weird problem (importing pyatspi causes a
problem with mixed python bindings) I was able to get it working.
In this case, if you call atk_label.get_name, you call the AtkObject
one. In the same way, get_name doesn't appear as a method inherited
from AtkAction. Probably this is because the method resolution order:
| Method resolution order:
| __main__.CallyText
| __main__.CallyActor
| gi.repository.Atk.GObjectAccessible
| gi.repository.Atk.Object
| gobject._gobject.GObject
| gi.repository.Atk.Component
| gi.repository.Atk.Action
| gi.repository.Atk.Text
| gi.repository.Atk.EditableText
| gobject.GInterface
| __builtin__.object
So in this case you can't call AtkAction.get_name calling
atk_label.get_action (0). So the overlap issue is still there. But in
this case you can do the following to workaround that:
Atk.Action.get_name (atk_label, 0)
and obviously, call AtkObject one using this:
Atk.Object.get_name (atk_label)
Silly test attached.
BR
===
API (apinheiro igalia com)
#!/usr/bin/env python
# Testing if python have the same problem with overlapped
# ->get_name methods (AtkObject and AtkAction)
# More info here:
# http://mail.gnome.org/archives/gnome-shell-list/2010-August/msg00017.html
#
# How to use pygi from:
# http://live.gnome.org/PyGObject
#
# Author: Alejandro Pinheiro <apinheiro igalia com>
#import pyatspi don't import this!! or you would load manual python bindings, and the example will not work
import pygtk
pygtk.require ('2.0') # adds gi to the pythonpath
from gi.repository import Clutter
from gi.repository import Atk
def key_press_cb (self, event, label):
atk_label = label.get_accessible ()
name = atk_label.get_name ()
name_using_class = Atk.Object.get_name (atk_label)
action_name = Atk.Action.get_name (atk_label, 0)
print "label name: " + name
print "label name using class: " + name_using_class
print "label action 0 name: " + action_name
if __name__ == "__main__":
Clutter.init (None)
color = Clutter.Color ()
color.red = 0xff
color.green = 0x00
color.blue = 0x00
color.alpha = 0xff
label = Clutter.Text ()
label.set_text ("Some text")
label.set_font_name ("Sans Bold 32px")
label.set_color (color)
s = Clutter.Stage ()
s.title = 'Overlapping methods'
s.set_size (600, 200)
s.connect ('destroy', lambda x: Clutter.main_quit())
s.connect ('button-press-event', key_press_cb, label);
s.add_actor (label)
s.show_all ()
Clutter.main ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]