Hello World tutorial

In this tutorial, we will be creating a Hello World widget, displaying only Hello World.

Step 1 We create a python file called helloworld.py and open it with an editor.

Step 2: imports We need to import wxPython to create the user interface of the widget, and ofcourse we will have to import the widgets module of Tribler:

import wx

import Tribler.Core.Widgets.widgets as widgets

Step 3: General information

We will now describe our widget in the module.

__name__        = "Hello World"

__author__      = "My Name"

__version__     = "0.1"

__description__    = "Displays Hello world"

width   = 200

height  = 200

We create a widget of 200x200 with title Hello World.

Step 4: create the widget class with user interface

class widget(widgets.tribler_widget):

    def __init__(self, *args, **kw):

        widgets.tribler_widget.__init__(self, *args, **kw)    


        self.helloWorld = wx.StaticText(self, -1, "Hello World", (0,0), (-1,-1))        

First, we create a class called widget which extends the tribler_widget from the Tribler widget module. The __init__ function is standard and calls the base class init. Lastly, we create a text with 'Hello World' at location (0,0) using wxPython.

That's it!

Start Tribler, click the "Add widget" button and go to the "insert widget" tab. Select your widget file and select "Debug Widget". Test your widget, before inserting it into the repository!

You can also download the source from this page.