WPF/XAML 的开源替代品有哪些?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2962874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 21:49:38  来源:igfitidea点击:

What are the Open Source alternatives to WPF/XAML?

wpfuser-interfacexamlopen-sourcedeclarative-programming

提问by Evan Plaice

If we've learned anything from HTML/CSS it's that, declarative languages (like XML) do a good job of describing User Interfaces because:

如果我们从 HTML/CSS 中学到了什么,那就是声明式语言(如 XML)在描述用户界面方面做得很好,因为:

  1. It's easy to build code preprocessors that can template the code effectively.
  2. The code is in a well defined well structured (ideally) format so it's easy to parse.
  3. The technology to effectively parse or crawl an XML based source file already exists.
  4. The UIs scripted code becomes much simpler and easier to understand.
  5. It simple enough that designers are able to design the interface themselves.
  6. Programmers suck at creating UIs so it should be made easy enough for designers.
  1. 构建可以有效地模板化代码的代码预处理器很容易。
  2. 代码采用定义良好、结构良好(理想情况下)的格式,因此很容易解析。
  3. 有效解析或抓取基于 XML 的源文件的技术已经存在。
  4. UI 脚本化代码变得更加简单和易于理解。
  5. 它足够简单,设计人员可以自己设计界面。
  6. 程序员不擅长创建 UI,所以它应该对设计师来说足够容易。

I recently took a look at the meat of a WPF application (ie. the XAML) and it looks surprisingly familiar to the declarative language style used in HTML.

我最近查看了 WPF 应用程序(即 XAML)的主要内容,它看起来与 HTML 中使用的声明性语言样式非常相似。

The current state of desktop UI development is largely fractionalized, otherwise there wouldn't be so much duplicated effort in the domain of graphical user interface design (IE. GTK, XUL, Qt, Winforms, WPF, etc).

桌面 UI 开发的当前状态在很大程度上是碎片化的,否则在图形用户界面设计领域(IE. GTK、XUL、Qt、Winforms、WPF 等)不会有这么多的重复工作。

There are 45 GUI platforms for Python alone

仅 Python 就有 45 个 GUI 平台

What are some Open Source GUI's that represent these characteristics:

代表这些特征的开源 GUI 有哪些:

  • standardized
  • platform independent
  • declarative markup language
  • language agnostic
  • 标准化
  • 平台无关
  • 声明性标记语言
  • 语言不可知论者

WPF, or more specifically XAML seems like a pretty likely step in the right direction.

WPF,或更具体地说,XAML 似乎是朝着正确方向迈出的很可能的一步。

Update:

更新:

Thanks a lot for the info, keep it comin'. Here's are the options I've gathered from the comments and answers.

非常感谢您提供的信息,请继续关注。以下是我从评论和答案中收集的选项。

GladeXML

格莱德XML

  • Editor: Glade Interface Designer
  • OS Platforms: All
  • GUI Platform: GTK+
  • Languages: C (libglade), C++, C# (Glade#), Python, Ada, Pike, Perl, PHP, Eiffel, Ruby
  • 编辑:Glade 界面设计师
  • 操作系统平台:所有
  • 界面平台:GTK+
  • 语言:C (libglade)、C++、C# (Glade#)、Python、Ada、Pike、Perl、PHP、Eiffel、Ruby

XRC (XML Resource)

XRC(XML 资源)

XML based formats that are either not free, not cross-platform, or language specific

基于 XML 的格式不是免费的、不是跨平台的,或者是特定于语言的

XUL

XUL

  • Editor: Any basic text editor
  • OS Platforms: Any OS running a browser that supports XUL
  • GUI Platform: Gecko Engine?
  • Languages: C++, Python, Ruby as plugin languages not base languages
  • 编辑器:任何基本的文本编辑器
  • 操作系统平台:运行支持 XUL 的浏览器的任何操作系统
  • GUI平台:Gecko引擎?
  • 语言:C++、Python、Ruby 作为插件语言而不是基础语言

Note: I'm not sure if XUL deserves mentioning in this list because it's less of a desktop GUI language and more of a make-webapps-run-on-the-desktop language. Plus, it requires a browser to run. IE, it's 'DHTML for the desktop.'

注意:我不确定 XUL 是否值得在此列表中提及,因为它不是一种桌面 GUI 语言,而是一种 make-webapps-run-on-the-desktop 语言。另外,它需要浏览器才能运行。IE,它是“桌面DHTML”。

CookSwing

厨师秋千

XAML (Moonlight)

XAML(月光)

  • Editor: MonoDevelop
  • OS Platforms: Linux and other Unix/X11 based OSes only
  • GUI Platforms: GTK+
  • Languages: .NET
  • 编辑:MonoDevelop
  • 操作系统平台:仅限 Linux 和其他基于 Unix/X11 的操作系统
  • 图形界面平台:GTK+
  • 语言:.NET

Note: XAML is not a pure Open Source format because Microsoft controls its terms of use including the right to change the terms at any time. Moonlight can not legally be made to run on Windows or Mac. In addition, the only platform that is exempt from legal action is Novell. See thisfor a full description of what I mean. XAML is also not an ECMA standard like C#, Managed C++, and the CLR.

注意:XAML 不是纯粹的开源格式,因为 Microsoft 控制着其使用条款,包括随时更改条款的权利。Moonlight 不能合法地在 Windows 或 Mac 上运行。此外,唯一免于法律诉讼的平台是 Novell。有关我的意思的完整描述,请参阅this。XAML 也不是像 C#、托管 C++ 和 CLR 那样的 ECMA 标准。

Update: The question has been changed from "Is there an Open source alternative to WPF? because the original question was wrong, and it sucked. The direction of this question has changed direction to match up to align with the new input. My apologies to the people who responded before it changed.

更新:问题已从“是否有 WPF 的开源替代方案?因为最初的问题是错误的,而且很糟糕。这个问题的方向已改变方向以匹配新的输入。我很抱歉在它改变之前做出反应的人。

采纳答案by Thomas

Qt is developing QML, which looks a lot like XAML except in JSON. It's available as a preview built against the current version, and is available in snapshots of the next version.

Qt 正在开发 QML,除了 JSON 之外,它看起来很像 XAML。它可用作针对当前版本构建的预览版,并可在下一版本的快照中使用。

Here's a little snippet from http://doc.qt.nokia.com/4.7-snapshot/declarative-ui-components-progressbar.html

这是来自http://doc.qt.nokia.com/4.7-snapshot/declarative-ui-components-progressbar.html的一个小片段

import Qt 4.7
import "content"

Rectangle {
   id: main

    width: 600; height: 405
    color: "#edecec"

    Flickable {
       anchors.fill: parent
       contentHeight: column.height + 20

       Column {
           id: column
           x: 10; y: 10
           spacing: 10

           Repeater {
               model: 25

               ProgressBar {
                 property int r: Math.floor(Math.random() * 5000 + 1000)
                 width: main.width - 20

                 NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite }
                 ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite }
                 ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite }
               }
           }
       }
   }
}

回答by Dave Markle

  • The Web is taking most of the steam away from desktop apps as it is.

    I think that the big reason is that everyone's so focused on the web right now. HTML5 is going to be a quantum leap forward in what the web can do. With fast JavaScript interpreters and capable browsers, the need for a desktop programs will begin to wane over time. That's the horse that Google is betting on, and to a much lesser extent, Apple as well.

  • Creating something good would have radically different implementations for each OS, so the base toolkit itself wouldn't be very portable.

    If you think about it, the Web is the only really common substrate we have upon which to develop this sort of infrastructure in a cross-platform manner. WPF is incredibly different from an architectural perspective vs. WinForms/straight WinAPI code. Adapting something like it to each OS would take a great deal of very different plumbing for each OS if you were to have a prayer of making something that performed well. (Not that web apps are very fast, mind you, but they're getting better).

  • Look and feel is always going to be somewhat of an issue.

    Whose look and feel do you use? Do you try to adapt the UI to the OS chrome so it looks "native", or do you do something like Swing did years ago and develop apps that look distinctively different from everything out there? (Ugh, that was a train wreck...) And if you choose to adapt the UI to each OS's look and feel, you may have all sorts of measurement and design issues.

  • 网络正在从桌面应用程序中带走大部分蒸汽。

    我认为最大的原因是现在每个人都非常关注网络。HTML5 将是网络功能的一个巨大飞跃。有了快速的 JavaScript 解释器和功能强大的浏览器,对桌面程序的需求将随着时间的推移开始减弱。这就是谷歌押注的马,在较小程度上也是押注苹果。

  • 为每个操作系统创建好的东西会有完全不同的实现,因此基本工具包本身不会很便携。

    如果您考虑一下,Web 是我们以跨平台方式开发此类基础设施的唯一真正通用的基础。WPF 与 WinForms/直接的 WinAPI 代码相比,从架构的角度来看是非常不同的。如果您希望制作一些性能良好的东西,那么将类似的东西调整到每个操作系统需要大量非常不同的管道。(请注意,并不是 Web 应用程序非常快,但它们正在变得越来越好)。

  • 外观和感觉总是会有些问题。

    您使用谁的外观和感觉?您是否尝试将 UI 调整到 OS chrome 使其看起来“原生”,或者您是否像 Swing 几年前所做的那样并开发出与所有应用程序看起来截然不同的应用程序?(呃,那简直是火车失事……)如果您选择使 UI 适应每个操作系统的外观和感觉,您可能会遇到各种测量和设计问题。

回答by code4life

Novell has an open source implementation of Silverlight, with great support for XAML, called Moonlight:

Novell 有一个 Silverlight 的开源实现,它对 XAML 有很好的支持,称为 Moonlight:

http://en.wikipedia.org/wiki/Moonlight_(runtime)

http://en.wikipedia.org/wiki/Moonlight_(运行时)

http://www.mono-project.com/Moonlight

http://www.mono-project.com/Moonlight