非常简单、简洁和容易的 GUI 编程“框架" [英] Very simple, terse and easy GUI programming “frameworks”
问题描述
请列出可以快速编写 GUI 应用程序的 GUI 编程库、工具包、框架.我的意思是这样
- GUI 完全在人类可读(和人类可写)纯文本文件(代码)中描述
- 代码简洁(每个小部件/事件对 1 或 2 行代码),适合编写脚本
- 从代码中可以明显看出 GUI 的结构和操作(小部件的嵌套和事件流)
- 有关如何构建 GUI 的详细信息是隐藏的(例如主循环、附加事件侦听器等)
- 支持自动布局(vboxes、hboxes 等)
正如答案所暗示的那样,这可能被定义为声明性 GUI 编程,但不一定如此.如果可行,任何方法都可以,易于使用且简洁.
有一些这样的 GUI 库/工具包.它们在下面列出.如果您发现缺少合格的工具包,请扩展列表.说明该项目是否跨平台、成熟、活跃,如果可能,请举例说明.
请使用此维基来讨论仅开源项目.
这是迄今为止的列表(按字母顺序):
软糖
(来源:
(来源:
(来源:
(来源:
(来源:
(来源:
(来源:
(来源:
(来源:picamatic.com)
感谢您的贡献!
不是开玩笑,而是 HTML.
它是跨平台的,并在一个简单的文本文件中总结了 gui 布局.它绝对是成熟的,并且易于理解和有据可查.
有很多方法可以为动态内容制作 HTML 文件模板,如果您不喜欢尖括号,还有其他方法可以将自定义语法转换为 HTML.
使用 Javascript 的客户端脚本,使用 PHP/Ruby/Python/Perl 的服务器端脚本.
它并不适合所有用途,但对于许多用途来说,它已经足够了.也没有理由必须提供它 - 如果需要,您可以将 HTML 文件分发给您的客户 - 请参阅 TiddlyWiki 一个很好的例子,说明可以去哪里.
Please list GUI programming libraries, toolkits, frameworks which allow to write GUI apps quickly. I mean in such a way, that
- GUI is described entirely in a human-readable (and human-writable) plain text file (code)
- code is terse (1 or 2 lines of code per widget/event pair), suitable for scripting
- structure and operation of the GUI is evident from the code (nesting of widgets and flow of events)
- details about how to build the GUI are hidden (things like mainloop, attaching event listeners, etc.)
- auto-layouts are supported (vboxes, hboxes, etc.)
As answers suggest, this may be defined as declarative GUI programming, but it is not necessarily such. Any approach is OK if it works, is easy to use and terse.
There are some GUI libraries/toolkits like this. They are listed below. Please extend the list if you see a qualifying toolkit missing. Indicate if the project is crossplatform, mature, active, and give an example if possible.
Please use this wiki to discuss only Open Source projects.
This is the list so far (in alphabetical order):
Fudgets
Fudgets is a Haskell library. Platform: Unix. Status: Experimental, but still maintained. An example:
import Fudgets
main = fudlogue (shellF "Hello" (labelF "Hello, world!" >+< quitButtonF))
(source: picamatic.com)
GNUstep Renaissance
Renaissance allows to describe GUI in simple XML. Platforms: OSX/GNUstep. Status: part of GNUstep. An example below:
<window title="Example">
<vbox>
<label font="big">
Click the button below to quit the application
</label>
<button title="Quit" action="terminate:"/>
</vbox>
</window>
(source: picamatic.com)
HTML
HTML-based GUI (HTML + JS). Crossplatform, mature. Can be used entirely on the client side.
Looking for a nice "helloworld" example.
(source: picamatic.com)
JavaFX
JavaFX is usable for standalone (desktop) apps as well as for web applications. Not completely crossplatform, not yet completely open source. Status: 1.0 release. An example:
Frame {
content: Button {
text: "Press Me"
action: operation() {
System.out.println("You pressed me");
}
}
visible: true
}
Screenshot is needed.
Phooey
Phooey is another Haskell library. Crossplatform (wxWidgets), HTML+JS backend planned. Mature and active. An example (a little more than a helloworld):
ui1 :: UI ()
ui1 = title "Shopping List" $
do a <- title "apples" $ islider (0,10) 3
b <- title "bananas" $ islider (0,10) 7
title "total" $ showDisplay (liftA2 (+) a b)
(source: picamatic.com)
PythonCard
PythonCard describes GUI in a Python dictionary. Crossplatform (wxWidgets). Some apps use it, but the project seems stalled. There is an active fork.
I skip PythonCard example because it is too verbose for the contest.
(source: picamatic.com)
Shoes
Shoes for Ruby. Platforms: Win/OSX/GTK+. Status: Young but active. A minimal app looks like this:
Shoes.app {
@push = button "Push me"
@note = para "Nothing pushed so far"
@push.click {
@note.replace "Aha! Click!"
}
}
(source: picamatic.com)
Tcl/Tk
Tcl/Tk. Crossplatform (its own widget set). Mature (probably even dated) and active. An example:
#!/usr/bin/env wish
button .hello -text "Hello, World!" -command { exit }
pack .hello
tkwait window .
(source: picamatic.com)
tekUI
tekUI for Lua (and C). Platforms: X11, DirectFB. Status: Alpha (usable, but API still evolves). An example:
#/usr/bin/env lua
ui = require "tek.ui"
ui.Application:new {
Children = {
ui.Window:new {
Title = "Hello",
Children = {
ui.Text:new {
Text = "_Hello, World!", Style = "button", Mode = "button",
},
},
},
},
}:run()
(source: picamatic.com)
Treethon
Treethon for Python. It describes GUI in a YAML file (Python in a YAML tree). Platform: GTK+. Status: work in proress. A simple app looks like this:
_import: gtk
view: gtk.Window()
add:
- view: gtk.Button('Hello World')
on clicked: print view.get_label()
Yet unnamed Python library by Richard Jones:
This one is not released yet. The idea is to use Python context managers (with
keyword) to structure GUI code. See Richard Jones' blog for details.
with gui.vertical:
text = gui.label('hello!')
items = gui.selection(['one', 'two', 'three'])
with gui.button('click me!'):
def on_click():
text.value = items.value
text.foreground = red
XUL
XUL + Javascript may be used to create stand-alone desktop apps with XULRunner as well as Mozilla extensions. Mature, open source, crossplatform.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="300" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<caption label="Hello World"/>
</window>
(source: picamatic.com)
Thank your for contributions!
Not to kid, but HTML.
It's cross-platform, and sums up the gui-layout in a simple textfile. It's definitely mature, as well as well-understood and well documented.
There's a bunch of ways to template HTML files for dynamic content, and other ways to convert custom syntaxes to HTML if you dislike angle-brackets.
Client-side scripting w/ Javascript, server-side scripting with PHP/Ruby/Python/Perl.
It's not well suited for all purposes, but for many, it's good enough. There's no reason that it has to be served either - you can distribute a HTML file to your clients if you want - see TiddlyWiki for a good example of where that can go.
这篇关于非常简单、简洁和容易的 GUI 编程“框架"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!