Starting Off With Some Basic Widgets

After I thoroughly went through the code of the library I am working on during the Community Bonding period, I focused my attention to some basic widget implementations to get comfortable with writing code in VTK. After a video chat with my mentors during the first week, we came up with a list of tasks for me to complete to get my hands dirty.

Image Widget

My first widget was a simple image element which takes the image path and the required size as inputs. I started off with this because the code for this was pretty simple and most of it was already written in other classes.

Possible improvements to this include:

  1. Resizing the image with mouse.
  2. Changing the image by browsing the file system during display.

The code for this is available here :


I then moved on to implement a checkbox element. This was implemented as a composition of the Button2D and TextBox2D class objects. This was where I really started getting experience with VTK since I faced a lot of problems during implementation which made me go through a lot of documentation of the toolkit. It helped me find a few bugs in the classes that I used. This is what I finally made:

One issue I faced while implementing this was that the set of icons used in the Button2D class was a dictionary. This was a problem because we need a particular order for the icons in the buttons (Block followed by a Tick if checked) but dictionaries in python are randomly ordered, thus sometimes the buttons were initially ticks. After discussing with my mentors, we decided to change the dictionary to a list of tuples. The code for the same can be found here:

My mentors and I focused our attention to reviewing a pending PR in the repository. It is an important PR which refactors a huge portion of the code. I have decided to make a PR for checkbox after this PR and the one mentioned above are merged.

Plans for the Project

In a video call meeting, my mentors discussed what outcomes they expect from this project. They want me to move to 3D UI components ASAP, so I decided to complete the 2D portions in the next 2-3 weeks. One of the most important of the 2D widgets is a file select menu, which is not only an important component in itself, but can also enhance the functioning of other elements by allowing the user to control what is displayed.

Leave a Reply

Your email address will not be published. Required fields are marked *