2009-11-04 29 views
1

当我试图通过dbus获得gnome屏幕保护程序的空闲时间(以秒为单位)时,python会引发TypeError。DBus Python问题

在我找到的屏幕保护程序sessionIdleTime的文档中,它返回一个无符号整数。 http://www.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html#gs-method-GetSessionIdle

但是,当我在python shell中时,输出被转换为一个字符串,而我无法看到它能够在程序中将其转换为字符串。

gs = gs = bus.get_object('org.gnome.ScreenSaver','/org/gnome/ScreenSaver') message = str(gs.GetSessionIdleTime())

回答

0

str(gs.GetSessionIdleTime())投整数成一个字符串。

然后,在字符串变量中使用+将它合并到由输出调用的另一个dbus调用中。