Whether you need a fancy GUI for your Python app, you have an existing Python desktop app which needs some additional functionality or you are mainly interested in a different theme that will freshen up your app, we are here for you. All this is possible with the help of Telerik UI For WinForms Controls.
You read that right! IronPython and the latest Visual Studio 2019 made all this possible! They enable Python desktop applications to work together with WinForms controls. And more importantly, work together with the Telerik UI For WinForms suite and all the goodies that come out of the bag.
IronPython is a powerful open-source variation of Python. It is an adaptation of the Python programming language that runs on top of Microsoft's .NET framework. IronPython can use the .NET Framework and Python libraries, and other .NET languages can use Python code just as easily.
After you install the latest version of IronPython, you can open Visual Studio 2019 which comes with a built-in template project for “IronPython Windows Forms Application” and create your first app.
Now let’s make a huge step onto using Telerik controls. First, you need to install the Telerik UI for WinForms UI component suite—you can download it from here. Then add the required Telerik assemblies into your project folder for using the RadGridView, FluentTheme and RadChartView (spoiler alert—we will need it for later) controls for WinForms.
To reference the binaries in the app, import the clr library and then use the addReference methods. Here you can see how to add
usings that we are going to need for our sample app.
Now let’s take a look how we can add a radGridView control, containing a bunch of different columns to our form.
The result of this exercise is a radGridView which has the following columns: GridViewDecimalColumn, GridViewTextBoxColumn, GridViewColorColumn, GridViewCheckBoxColumn, GridViewRatingColumn.
If you would like to apply a theme to your controls, as seen in the picture, it can be done as simple as that.
In case you wonder how subscribing to events works it is easier than you might think. Here is a sample of creating a RadButton control and subscribing to its
Then as you know you will have to define your OnButtonClick logic.
So far so good. Now let’s look at a more complex event-related example using the radGridView from our previous example. We will implement some logic in the CellFormatting event in order to fill cells from GridViewRatingColumn with different colors. The value inside the Rating cells can be between 0 and 100. If the value is < 50 we will fill those cells in Red color, otherwise we will use Aqua color. We can achieve this result with the following code.
The end result of our CellFormatting effort looks like that.
Using Telerik controls is as easy as you saw in the radGridView example. Let’s look at another example of setting up radChartView control with BarSeries.
The result is as you might expect for a standard Telerik UI for WinForms application.
This was a short intro to combining Python desktop GUI and the Telerik UI for WinForms suite. Please don’t hesitate to share your experience with integrating Telerik UI for WinForms in your Python projects.
Feel more than welcome to drop us a line in the comments section bellow on how it went with our components or submit your feedback directly to our Feedback Portal. You can download the latest version of Telerik UI for WinForms from your account today, or if you're new to the suite, start a free 30 day trial today:
Dimitar Ivanov is a quality assurance engineer in Telerik UI for WinForm team. He joined the company at the beginning of 2018. Apart from his job, Dimitar likes playing video games or board games with his friends but most of all - drinking ice cold beer.
Subscribe to be the first to get our expert-written articles and tutorials for developers!