fyne README

The project's README from github.com/fyne-io/fyne. As one markdown file: README.md.

Go API Reference Latest Release Join us on Slack
Build Status Coverage Status

About

Fyne is an easy-to-use UI toolkit and app API written in Go. It is designed to build applications that run on desktop and mobile devices with a single codebase.

Prerequisites

To develop apps using Fyne you will need Go version 1.22 or later, a C compiler and your system's development tools. If you're not sure if that's all installed or you don't know how then check out our Getting Started document.

Using the standard go command you can add Fyne to your project by running two commands. First:

go get fyne.io/fyne/v2@latest

If you are new to Go, it is important to know that (as of Go 1.18) go get only downloads the specified module and registers it in the go.mod file. It does not add any dependencies into the go.mod file. The command for automatically adding missing dependencies will remove unused modules as well. Therefore, you must first add a reference to fyne in a .go source file. After you have done that, you can run the second command:

go mod tidy

Now you can build and run your application.

Widget demo

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

go install fyne.io/demo@latest
demo

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

Fyne Demo Dark Theme

Or if you are using the light theme:

Fyne Demo Light Theme

And even running on a mobile device:

Fyne Demo Mobile Light Theme

Getting Started

Fyne is designed to be really easy to code with. If you have followed the prerequisite steps above then all you need is a Go IDE (or a text editor).

Open a new file and you're ready to write your first app!

package main

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

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("Hello Fyne!")
	w.SetContent(container.NewVBox(
		hello,
		widget.NewButton("Hi!", func() {
			hello.SetText("Welcome :)")
		}),
	))

	w.ShowAndRun()
}

And you can run that simply as:

go run main.go

[!NOTE]
The first compilation of Fyne on Windows can take up to 10 minutes, depending on your hardware. Subsequent builds will be fast.

It should look like this:

Fyne Hello Dark Theme Fyne Hello Dark Theme

Run in mobile simulation

There is a helpful mobile simulation mode that gives a hint of how your app would work on a mobile device:

go run -tags mobile main.go

Another option is to use fyne command, see Packaging for mobile.

Installing

Using go install will copy the executable into your go bin dir. To install the application with icons etc into your operating system's standard application location you can use the fyne utility and the "install" subcommand.

go install fyne.io/tools/cmd/fyne@latest
fyne install

Packaging for mobile

To run on a mobile device it is necessary to package up the application. To do this we can use the fyne utility "package" subcommand. You will need to add appropriate parameters as prompted, but the basic command is shown below. Once packaged you can install using the platform development tools or the fyne "install" subcommand.

fyne package -os android -appID my.domain.appname
fyne install -os android

The built Android application can run either in a real device or an Android emulator. However, building for iOS is slightly different. If the "-os" argument is "ios", it is build only for a real iOS device. Specify "-os" to "iossimulator" allows the application be able to run in an iOS simulator:

fyne package -os ios -appID my.domain.appname
fyne package -os iossimulator -appID my.domain.appname

Preparing a release

Using the fyne utility "release" subcommand you can package up your app for release to app stores and market places. Make sure you have the standard build tools installed and have followed the platform documentation for setting up accounts and signing. Then you can execute something like the following, notice the -os ios parameter allows building an iOS app from macOS computer. Other combinations work as well :)

$ fyne release -os ios -certificate "Apple Distribution" -profile "My App Distribution" -appID "com.example.myapp"

The above command will create a '.ipa' file that can then be uploaded to the iOS App Store.

Documentation

More documentation is available at the Fyne developer website or on pkg.go.dev.

Examples

You can find many example applications in the examples repository. Alternatively a list of applications using fyne can be found at our website.

Shipping the Fyne Toolkit

All Fyne apps will work without pre-installed libraries, this is one reason the apps are so portable. However, if looking to support Fyne in a bigger way on your operating system then you can install some utilities that help to make a more complete experience.

Additional apps

It is recommended that you install the following additional apps:

app go install description
fyne_settings fyne.io/fyne/v2/cmd/fyne_settings A GUI for managing your global Fyne settings like theme and scaling
apps github.com/fyne-io/apps A graphical installer for the Fyne apps listed at https://apps.fyne.io

These are optional applications but can help to create a more complete desktop experience.

FyneDesk (Linux / BSD)

To go all the way with Fyne on your desktop / laptop computer you could install FyneDesk as well :)

FyneDesk screenshot in dark mode

fyne (fyne-io/fyne)

Searching Database…

28.8K ·GitHub
Что это такое?Fyne — это простой в использовании набор инструментов для создания пользовательских интерфейсов и API для приложений, написанный на Go и вдохновлённый Material Design. Он создан для того, чтобы из одного кода собирать приложения, работающие на настольных компьютерах и мобильных устройствах.
Так это библиотека, которую я подключаю в свой код, или фреймворк, на котором целиком работает моё приложение?И то и другое: вы подключаете fyne.io/fyne/v2 и пишете приложение, используя его виджеты и API для приложений, а отдельная утилита командной строки fyne отвечает за сборку, установку и публикацию приложения.
Как запустить первое приложение?Выполните 'go get fyne.io/fyne/v2@latest', добавьте упоминание fyne в файл исходного кода .go, затем выполните 'go mod tidy'. После этого 'go run main.go' соберёт и запустит ваше приложение.
Что должно быть установлено заранее?Go 1.22 или новее, компилятор C и инструменты разработки вашей системы. Чтобы писать код, подойдёт любая IDE или текстовый редактор с поддержкой Go.
Есть ли подводные камни, о которых стоит знать заранее?Два. Во-первых, начиная с Go 1.18, команда 'go get' только скачивает модуль, поэтому нужно сослаться на fyne в коде до того, как 'go mod tidy' подтянет зависимости. Во-вторых, первая сборка на Windows может занять до 10 минут.
Один код действительно подходит и для настольных систем, и для мобильных?Да, именно на это и рассчитан проект. Под мобильные платформы приложение собирается утилитой fyne: 'fyne package -os android' — для устройств или эмуляторов, '-os ios' — для реального iPhone, '-os iossimulator' — для симулятора iOS.
А можно что-нибудь запустить и посмотреть Fyne в действии, не начиная писать код?Да: выполните 'go install fyne.io/demo@latest', затем запустите 'demo'. Откроется витрина виджетов с возможностями набора инструментов, в тёмной и светлой темах.
Тем, кто будет запускать моё приложение, придётся что-то доустанавливать?Нет. Все приложения на Fyne работают без заранее установленных библиотек — проект называет это одной из причин, по которым его приложения так легко переносятся.
Могу ли я настроить внешний вид своих приложений?Приложения из коробки идут с тёмной и светлой темами, а необязательное приложение fynesettings даёт графический интерфейс для управления глобальными настройками Fyne, например темой и масштабированием.
Используется ли Fyne для чего-то крупнее обычных приложений?Да: FyneDesk превращает машину под Linux или BSD в полноценную графическую среду на базе Fyne, а есть ещё приложение-установщик с графическим интерфейсом для просмотра коллекции приложений Fyne.
What are similar projects?mygo, iced, flutter, qt, MaterialDrawer, native, kivy, glance
Creator
fyne-io
Size
119.5 MB
Stars
28.8K
Age
8y
Commits · 90 Days