Canonical Voices

Posts tagged with 'pygtk'

mandel

Recently in Ubuntu One we have been working or using PyQt for the UI of our application so that we could keep a smaller code base. While doing the move I noticed that we needed to have a widget similar to GtkArrow and to my surprise there is not one.

The following is a small implementation fo such a widget that might help other people that are in need of it. Even maybe someone that cares enough will write it in C++ and will propose it to Qt, sorry but I don’t have the time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
from PyQt4.QtGui import QPainter, QStyle, QStyleOption, QWidget
 
 
class QArrow(QWidget):
    """Qt implementation similar to GtkArrow."""
 
   UP = 0
   DOWN = 1
   LEFT = 2
   RIGHT = 3
 
   def __init__(self, direction, parent=None):
       """Create a new instance."""
       QWidget.__init__(self, parent)
       if not direction in (QArrow.UP, QArrow.DOWN,
                 QArrow.LEFT, QArrow.RIGHT):
           raise ValueError('Wrong arrow direction.')
       self._direction = direction
 
    def paintEvent(self, event):
        """Paint a nice primitive arrow."""
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        if self._direction == QArrow.UP:
            primitive = QStyle.PE_IndicatorArrowUp
        elif self._direction == QArrow.DOWN:
            primitive = QStyle.PE_IndicatorArrowDown
        elif self._direction == QArrow.LEFT:
            primitive = QStyle.PE_IndicatorArrowLeft
        else:
            primitive = QStyle.PE_IndicatorArrowRight
        self.style().drawPrimitive(primitive, opt, p, self)

Took longer to think the correct way to do it than the actual coding, at the end is very simple.

Read more
David

Ubuntu App Developer Week – Day 2 Summary

Wow, what a great follow-up to the first day! The second Ubuntu App Developer Week brought lots of awesome: great speakers and sessions, great participation, improvisation, Python, GTK, KDE, Qt, PyGI, Zeitgeist, Gstreamer, Introspection, Thunderbird, Unity, API Integration, hacking, fun… all the buzzwords you can associate when developing in your favourite Free Software Platform.

PyGTK is dead, long live PyGI! Using gobject-introspection in Python

By Martin Pitt

Martin’s complementary session to the GObject Introspection (GI) one on Monday was very popular. He started off with a recap of what GI is and the importance of the availability of several programming language bindings in any modern development platform. He provided an overview on how GI works in practice, and then delved into how it actually works in Python through the use of Pygobject and the gi.repository module, with lots of coding examples and comparison with traditiona GTK+ C code. After that he described other API differences, in particular the caveats with contructoirs, passing arrays, output arguments, GDestroyNotify and what to do with non-introspectable functions or methods. The next topic where overrides: how to provide custom code to override the introspected library’s objects. The second part of the session focused on explaining in detail how to migrate old PyGtk code to GTK3 and PyGI, in a series of easy guidelines: renaming, checking and repeating, and packaging changes. He wrapped up with a series of pointers on how to learn more and a Q+A session with lots of interesting questions from the audience.

Check out the session log here.

Zeitgeist API & Zeitgeist Application Integration

By Manish Sinha (???? ??????) and Seif Lotfy

For this session we had the luxury of having two key members of the Zeitgeist project to explain us all the details on how to integrate it to your own projects.  Manish, one of the Zeitgest developers, kicked off with an introduction on what Zeitgeist is: an automatic event logger which logs the events that happen on your computer. He then went on through the details of the Zeitgest terminology (events, manifestations, actors, timestamps…), architecture, and its interaction with D-Bus, with an overview of the API interface and the existing bindings: Python, C/Vala and C#. The session went on with examples of how real world applications and data providers use Zeitgeist, such as EOG plugins or Tomboy. Seif then chipped in with an example of  how Zeitgeist support was integrated into a GEdit plugin. Throughout the session lots of interesting questions were raised by the audience.

Check out the session log here.

GStreamer+Python: Multimedia Swiss Army Machete

By Jason DeRose

A very intersesting session indeed. In it, Jason explained all the points why GStreamer is the multimedia framework due to its economy of scale and why Python is the perfect complement with its simplicity and language clarity. According to him, together they provide the ultimative multimedia development tool, and this was why he chose to use them in hos own project: Novacut, the distributed video editor. From this point on, it was “Learning by doing”, and he then walked thorugh the code examples he’d set up for the session, showcasing how simple it is to work with multimedia streams with his swiss army machete :)

Check out the session log here.

KDE Development Intro: Q+A

By Harald Sitter and Jonathan Riddell

I’d especially like to mention this session due to a change of schedule. The original speaker, KDE/Kubuntu ninja Joathan Thomas could not make if due to last-minute commitments. But no worries, KDE/Kubuntu friends are always there to lend a hand, and in no time Harald and Jonathan stepped up to fill the gap and do an impromptu KDE Development Intro and Q+A session. In there they gave an overview on the essentials every prospective KDE developer should know and answered in detail the questions in the audience. All in all a great insight on how to get started developing KDE apps.

Check out the session log here.

Thunderbird + Unity = Awesome, and how JSCtypes lets you get to the candy

By Mike Conley

Mike has been working over the last 3 months at Mozilla on ways in which Thunderbird can integrate nicely into Ubuntu, in particular with Unity. He started explaining the main points he’s been focusing on: the messaging menu, the Unity launcher adn Ubuntu One, and for the rest of the session he covered the first two. Going straight to the subject, the next topic was to explain what a Thunderbird extension is, and how they are written using a mixture of Javascript, the XUL mark-up language and CSS, all executed by the Gecko engine. He then introduced JS-CTypes, which allow developers to access C libraries directly from Chrome-level Javascript code. and how he used them to write a Unity launcher add-on. the resto of the session focused on this subject, with plenty of code examples.

Check out the session log here.

STORY: Unity, hacking on a real-world app

By Marco Trevisan

The last session of the day was one of my favourite ones: an inspiring personal story. Marco is a community contributor to Unity who told us about his journey since he found an application itch to scratch and until his own feature was landed. He started with a very easy to understand overview of the Unity architecture and how all the pieces fit together, following with the story on how he found something that needed improvement and how he went about fixing it: indicator-sound not being precise when setting the volume with the mouse wheel. Do read it, as it is going to be a great help to all of you who are looking on how to get started contributing to Ubuntu development.

Check out the session log here.

The Day Ahead: Upcoming Sessions for Day 3

A quick look at today’s session lineup for your development pleasure:

16:00 UTC
Qt Quick: QML the Language – Jürgen Bocklage-Ryannel
Here’s a special treat for anyone interested in Qt development: Jürgen Bocklage-Ryannel, from Nokia, the maker of Qt, will be introducing Qt Quick and QML as the language used in Qt Quick. He’ll be showing some elements of the UI and the general process, and tell you the right places to go to to get more information.

17:00 UTC
Make your applications work in the cloud with Ubuntu OneStuart Langridge
Who else than the Ubuntu One mastermind himself could tell you better about supercharging your apps with cloud functionality? Join Stuart in this talk where he’ll be describing how to integrate Ubuntu One into your applications and bring your users to cloud 9 ;)

18:00 UTC
Take control of your desktop easily with DBusAlejandro J. Cura
D-Bus, the cross-desktop message bus system, is becoming more and more ubiquitous in any Free Software distribution. You can bring your applications to a whole new level letting them talk to other ones in a desktop session, and Alejandro can tell you exactly how to do that.

19:00 UTC
Touchégg: Bringing Multitouch Gestures to your DesktopJosé Expósito
It’s always great to see real-world examples of how the newest and coolest technologies are being used. José will be showcasing his multitouch-based application, Touchégg, introducing its features, describing how to add new multitouch gestures, the technologies used to develop it, and how it uses the uTouch-GEIS API. Check out the summary and the logs from the other Multitouch session on Monday to learn more.

20:00 UTC
Unity: Integrating with Launcher and PlacesMikkel Kamstrup Erlandsen
Do you want your application to seamlessly blend into the new Ubuntu user interface experience? Do you want it to provide all interaction capabilities that Unity provides? Then join Unity developer Mikkel Kamstrup in his walkthrough with examples on how to plug your app into the Launcher and Places API.

21:00 UTC
Tracking Source Code History with BazaarJelmer Vernooij
Learn how to control the history of your source code with a distributed and modern revision control system. Bazaar is powerful, fast, and most importantly, easy and fun to use. Jelmer has had a lot to do in developing Bazaar, so he knows well what he’s talking about. Join him in this session where he’ll tell you the basics and more sophisticated uses of the revision control system used to develop Ubuntu and thousands of other projects in Launchpad.

Looking forward to seeing you all there in a few hours!


Read more