返回介绍

Introduction

发布于 2025-02-22 22:19:48 字数 3265 浏览 0 评论 0 收藏 0

The first part of the IronPython Mono Winforms tutorial introduces the Mono platform and the Winforms library.

About this tutorial

This is Mono IronPython Winforms tutorial. Mono IronPython Winforms tutorial is for beginner programmers. The goal of this tutorial is to teach readers basics of GUI programming in Mono Winforms for the IronPython programming language. The tutorial is created and tested on Linux. Nevertheless, it can be used on other operating systems as well. Most examples should run without modification. Images used in this tutorial can be downloaded here .

Mono

Mono is an open development initiative sponsored by Xamarin to develop an open source, UNIX version of the Microsoft .NET development platform. It is a .NET compatible set of tools, which include C# compiler, Common Language Runtime, ADO.NET, ASP.NET and Winforms libraries.

Mono can be divided into three groups:

  • Core components
  • Gnome development stack
  • Microsoft compatibility stack

The core components are the C# language and the Common language runtime. The Gnome development stack includes the GTK# library and various database connectivity libraries. Finally, the Microsoft compatibility stack includes the ADO.NET, ASP.NET and the Winforms libraries.

Mono is multiplatform programming platform. It can be run on Linux, BSD, Mac OS X, Solaris and Windows operating systems. It is a multilanguage effort. For now, only C# language is fully supported. Languages like Visual Basic or IronPython are not yet finished. They are still being developed.

Winforms

Windows Forms is a graphical user interface application programming interface (API) included as a part of Microsoft's .NET Framework. As of 13 May 2008, Mono's System.Windows.Forms 2.0 is API complete. Simply put, Winforms is a library for creating GUI applications.

IronPython

IronPython is an implementation of the Python programming language for the .NET Framework and Mono. IronPython is written entirely in C#. There are some significant differences between Python and IronPython.

Runnning code examples

Our tutorial uses IronPython language.

simple.py

#!/usr/bin/ipy

import clr

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import Application, Form

class IForm(Form):

  def __init__(self):
    self.Text = 'Simple'
    self.Width = 250
    self.Height = 200
    self.CenterToScreen()

Application.Run(IForm())

This small code example shows a simple window on the screen. It uses the Winforms library. It is coded in IronPython.

#!/usr/bin/ipy

This is the path to the IronPython interpreter.

$ chmod +x simple.py
$ ./simple.py

We make the script executable and run it.

Reference

This was an introduction to the Mono IronPython Winforms.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文