I want to use Qt for developing Ubuntu desktop, phone and tablet applications but I don't want to learn a new programming language (C++, JavaScript). Is it possible to write Qt application in Python utilizing Qt-Creator as IDE?
Ubuntu – How to use Qt Creator with Python
application-developmentpythonqmlqtqt-creator
Related Solutions
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).
It is currently not possible to use Python with the Ubuntu SDK. The Ubuntu project is tightly focused on getting a stable mobile phone OS by October 2013, and a full convergent story by Ubuntu 14.04. In order to achieve this, QML has been the language of choice to recommend to app developers to write their software.
Technically, provided that there are Qt/QML bindings in Python available, it should be possible to use it with the SDK. However, given the time frames, we want to focus on supporting one toolkit and doing it well, rather than supporting multiple options.
If any community members are interested in contributing towards it, it should not be an impossible task, but right now the status of Python Qt bindings is a bit complicated: PySide, which would be the natural choice, will not be ported to Qt5 in the foreseeable future. PyQt has just been ported to Qt5, but it might not be the best choice in terms of licensing commercial applications, which will coexist with free, open source apps in the ecosystem. See more context on this earlier question.
Best Answer
Yes, Qt-Creator is a C++ IDE, with little support for other languages but since version 2.8.0 a quite basic python support has been added.
That said you can use Qt-Designer (the form building tool), Qt-Translator (the translate tool), etc... easily with python.
There are two Qt-Python bindings right now, the GPL/Commercial dual licensed PyQt, and the LGPL PySide. I have used PyQt for a long time and I'm a happy user, I also have tried PySide but it looks less mature to me. If your license requirements allow you I'd go for PyQt.