In Glade:
- Select the spinbutton.
- Click the button next to the "Adjustment" text entry that has "..." in it.
- In the window that appears click "New."
- Select the "adjustment1" widget from above.
- From there you can change value for a default value, minimum value, maximum value, and step increment.
You can also change those values from code, the class refrence can be found here: gtk.SpinButton.
Edit: You can get the maximum and minimum values using the following code:
(min, max) = spinbutton.get_range()
where min is minimum value, max is maximum value, and spinbutton is the spin button widget. You can also set it using the following:
spinbutton.set_range(min, max)
After looking at the source to libaccountsservice you actually have to wait for the user to be loaded before accessing the user object. This acheives the result:
from gi.repository import AccountsService, GLib
current_user = GLib.get_user_name()
user = AccountsService.UserManager.get_default().get_user(current_user)
def is_loaded_cb(user, param):
print user.get_icon_file()
user.connect('notify::is-loaded', is_loaded_cb)
main_loop = GLib.MainLoop()
main_loop.run()
Alternatively, you can contact the accounts service directly and synchronously over D-Bus:
from gi.repository import GLib, Gio
current_user = GLib.get_user_name ()
bus = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
result = bus.call_sync ('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant ('(s)', (current_user,)),
GLib.VariantType.new ('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack ()
result = bus.call_sync ('org.freedesktop.Accounts',
path,
'org.freedesktop.DBus.Properties',
'GetAll',
GLib.Variant ('(s)', ('org.freedesktop.Accounts.User',)),
GLib.VariantType.new ('(a{sv})'),
Gio.DBusCallFlags.NONE,
-1,
None)
(props,) = result.unpack ()
print props['IconFile']
print props['RealName']
If you want to set the icon file you need to call the appropriate method:
result = bus.call_sync ('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant ('(s)', ('/tmp/somefile.png',)),
GLib.VariantType.new ('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
If you need to use any other methods, browse the D-Bus interface using D-Feet (in the software center).
Best Answer
widget.queue_draw()
It is the same as in GTK+ 2.x.