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)

widgets
Searching Database…

28.8K ·GitHub
What is this?Fyne is an easy-to-use UI toolkit and app API written in Go, inspired by Material Design. It is designed to build applications that run on desktop and mobile devices from a single codebase.
So is it a library I import into my code, or a framework that runs my whole app?Both sides of a toolkit: you import fyne.io/fyne/v2 and write your app against its widgets and app API, while a separate fyne CLI utility handles packaging, installing and releasing the app.
How do I get a first app running?Run 'go get fyne.io/fyne/v2@latest', add a reference to fyne in a .go source file, then 'go mod tidy'. After that 'go run main.go' builds and launches your app.
What do I need to have installed before that?Go 1.22 or later, a C compiler and your system's development tools. For writing the code, any Go IDE or text editor will do.
Any gotchas I should know about upfront?Two: since Go 1.18, 'go get' only downloads the module, so you must reference fyne in your code before 'go mod tidy' resolves dependencies. Also, the first compilation on Windows can take up to 10 minutes.
Can one codebase really ship to both desktop and mobile?Yes, that is the design goal. You package for mobile with the fyne utility: 'fyne package -os android' for devices or emulators, '-os ios' for a real iPhone, '-os iossimulator' for the iOS simulator.
Is there something I can run to see Fyne in action before writing code?Yes: 'go install fyne.io/demo@latest', then run 'demo'. It launches a widget showcase of the toolkit's features, available in both dark and light themes.
Will people who run my app need to install anything extra?No. All Fyne apps work without pre-installed libraries, which the project cites as one reason its apps are so portable.
Can I customize the look of my apps?Apps come with dark and light themes out of the box, and the optional fynesettings app gives you a GUI for managing global Fyne settings like theme and scaling.
Is Fyne used for anything bigger than typical apps?Yes: FyneDesk turns a Linux or BSD machine into a full Fyne-based desktop environment, and there is a graphical installer app for browsing the collection of Fyne apps.
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