What is the difference between GTK# and Windows Fo

2020-06-13 08:34发布

问题:

What is the difference between GTK# and windows forms? Are they totally different?

Thanks

回答1:

Gtk#:

GTK# is a .NET binding for the Gtk+ toolkit. The toolkit is written in C for speed and compatibility, while the GTK# binding provides an easy to use, object oriented API for managed use. It is in active development by the Mono project, and there are various real-world applications available that use it (Banshee , F-Spot, Beagle, MonoDevelop).

In general, GTK# applications are written using MonoDevelop, which provides a visual designer for creating GTK# GUIs.

Platforms: Unix, Windows, OSX

Pros:

  • Good support for accessibility through its Gtk+ heritage.
  • Layout engine ideal for handling internationalized environments, and adapts to font-size without breaking applications.
  • Applications integrate with the Gnome Desktop.
  • API is familiar to Gtk+ developers.
  • Large Gtk+ community.
  • A Win32 port is available, with native look on Windows XP.
  • The API is fairly stable at this point, and syntactic sugar is being added to improve it.
  • Unicode support is exceptional.

Cons:

  • Gtk+ apps run like foreign applications on MacOS X.
  • Incomplete documentation.

Windows.Forms:

Windows.Forms is a binding developed by Microsoft to the Win32 toolkit. As a popular toolkit used by millions of Windows developers (especially for internal enterprise applications), the Mono project decided to produce a compatible implementation (Winforms) to allow these developers to easily port their applications to run on Linux and other Mono platforms.

Whereas the .Net implementation is a binding to the Win32 toolkit, the Mono implementation is written in C# to allow it to work on multiple platforms. Most of the Windows.Forms API will work on Mono, however some applications (and especially third party controls) occasionally bypass the API and P/Invoke straight to the Win32 API. These calls will likely have to changed to work on Mono.

In general, Winforms applications are written using Microsoft's Visual Studio or SharpDevelop, which both provide a visual designer for creating Winforms GUIs.

Platforms: Windows, Unix, OSX

Pros:

  • Extensive documentation exists for it (books, tutorials, online documents).
  • Large community of active developers.
  • Easiest route to port an existing Windows.Forms application.

Cons:

  • Internationalization can be tricky with fixed layouts.
  • Looks alien on non-Windows platforms.
  • Code that calls the Win32 API is not portable.

Source: Picking the Right Toolkit



回答2:

They are both GUI toolkits, each having their strength and weaknesses. From my experience:

  • Winforms does not require installation on windows, Gtk# does require installation on Windows.
  • Winforms has a designer in Visual Studio, Gtk# has standalone designer and integrated designed in MonoDevelop.
  • Winforms is bound to Windows, Gtk# is cross-platform.
  • Winforms is slow and flickers. Gtk is faster.
  • Most Winforms controls are wrappers around standard windows controls and offer very limited functionality. Gtk widgets are more feature-rich.
  • Gtk allows creating forms and widgets with complex layout. Winforms offers only trivial variants of layout, and FlowLayout & TableLayout & AutoSize are too weak to be able to have complex forms that resize and automatically accomodate to different font sizes, different resolutions.
  • Cairo is faster and has more features than Gdi+ (Cairo supports output and input from more types of files, e.g., svg, pdf)
  • Gtk# is open-source, winforms is not
  • Winforms and Gtk# have 3rd-party controls/widgets (however, with Gtk# there is less need for them because basic controls work really good).

In short, I would not recommend using Winforms (except when there is a strong reason not to have more dependencies than .NET FW), but using Gtk# or WPF.



回答3:

They are different graphical toolkits for creting windowed applications, with different origins.

GTK# is a binding for the GTK library, primarily intended for linux/unix. It also works on windows, but it's not the native environment for which it was designed.

Winforms is another toolkit, this one coming from microsoft.

They are totally different APIs for achieving the same results, but each better suited for a platform.

If you are looking for multiplatform windowing in .net, Qt may be an option now that it got LGPLed.



回答4:

In short: Yes

Both are GUI-Tookits, but WinForms (as the Name says) was mainly developed for windows. GTK has been developed for Gimp and is an approach for a multi os gui toolkit .

If your application only runs on windows, in most cases you should use WinForms.

If your application will run under different OS' (like linux, bsd, windows, macos,... ) you'll prefer GTK.

For a better explanation look here.