1 Star 0 Fork 21

eddylapis / Fyne

forked from Gitee 极速下载 / Fyne 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

GoDoc Reference 1.0.0 release Join us on Slack Support Fyne.io
Code Status Build Status Coverage Status

About

Fyne is an easy to use UI toolkit and app API written in Go. We use OpenGL (through the go-gl and go-glfw projects) to provide cross platform graphics.

The 1.0 release is now out and we encourage feedback and requests for the next major release :).

Getting Started

Fyne is designed to be really easy to code with. Here are the steps to your first app.

Prerequisites

As Fyne uses CGo you will require a C compiler (typically gcc). If you don't have one set up the instructions at Compiling may help.

By default Fyne uses the gl golang bindings which means you need a working OpenGL configuration. Debian/Ubuntu based systems may also need to install the libgl1-mesa-dev and xorg-dev packages.

Using the standard go tools you can install Fyne's core library using:

go get fyne.io/fyne

Code

And then you're ready to write your first app!

package main

import (
	"fyne.io/fyne/widget"
	"fyne.io/fyne/app"
)

func main() {
	app := app.New()

	w := app.NewWindow("Hello")
	w.SetContent(widget.NewVBox(
		widget.NewLabel("Hello Fyne!"),
		widget.NewButton("Quit", func() {
			app.Quit()
		}),
	))

	w.ShowAndRun()
}

And you can run that simply as:

go run main.go

It should look like this:

Fyne Hello Dark Theme

Note that Windows applications load from a command prompt by default, which means if you click an icon you may see a command window. To fix this add the parameters -ldflags -H=windowsgui to your run or build commands.

Scaling

Fyne is built entirely using vector graphics, which means applications written with Fyne will scale to any value beautifully (not just whole number values). The default scale value is calculated from your screen's DPI - and if you move a window to another screen it will re-scale and adjust the window size accordingly! We call this "auto scaling", and it is designed to keep an app GUI the same size as you change monitor. You can override this behaviour by setting a specific scale using the FYNE_SCALE environment variable.

Hello normal size
Standard size
Hello small size
FYNE_SCALE=0.5
Hello large size
FYNE_SCALE=2.5

Themes

Fyne ships with two themes by default, "light" and "dark". You can choose which to use with the environment variable FYNE_THEME. The default is dark:

Fyne Hello Dark Theme

If you prefer a light theme then you could run:

FYNE_THEME=light go run main.go

It should then look like this:

Fyne Hello Light Theme

Widget demo

To run a showcase of the features of Fyne execute the following:

cd $GOPATH/src/fyne.io/fyne/cmd/fyne_demo/
go build
./fyne_demo

And you should see something like this (after you click a few buttons):

Fyne Hello Light Theme

Or if you are using the light theme:

Fyne Hello Light Theme

Declarative API

Fyne also provides a declarative API. The following is exactly the same as the code above but in a declarative style.

package main

import (
	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	app := app.New()

	w := app.NewWindow("Hello")
	w.SetContent(&widget.Box{Children: []fyne.CanvasObject{
		&widget.Label{Text: "Hello Fyne!"},
		&widget.Button{Text: "Quit", OnTapped: func() {
			app.Quit()
		}},
	}})

	w.ShowAndRun()
}

Examples

The main examples have been moved - you can find them in their own repository.

Copyright (C) 2018 Fyne.io developers (see AUTHORS) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Fyne.io nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

Fyne 是一个 Go 语言开发的易用的 UI工具包,提供基于 OpenGL 的跨平台图形界面应用开发支持 展开 收起
Go
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/eddylapis/Fyne.git
git@gitee.com:eddylapis/Fyne.git
eddylapis
Fyne
Fyne
master

搜索帮助