Giter Site home page Giter Site logo

fyne's Introduction

GoDoc Reference Code Status Build Status Coverage Status Used By

About

Fyne is an easy to use UI toolkit and app API written in Go. We use the EFL render pipeline to provide cross platform graphics.

This is under heavy development and is not yet capable of supporting a full application

Getting Started

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

Prerequisites

Before you can use the Fyne tools you need to have a stable copy of EFL (at least 1.19) installed. This will be automated by our bootstrap scripts soon, but for now you can follow our setup instructions.

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

go get github.com/fyne-io/fyne

Code

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

    package main

    import "github.com/fyne-io/fyne/widget"
    import "github.com/fyne-io/fyne/desktop"

    func main() {
    	app := desktop.NewApp()

    	w := app.NewWindow("Hello")
    	w.SetContent(widget.NewList(
    		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

Scaling

Fyne is built entirely using vector graphics which means that applications that are written using it will scale to any value beautifully (not just whole number values). The default scale value is equated from your screen's DPI - and if you move a window to another screen it will re-calculate and adjust the window size accordingly!

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/github.com/fyne-io/fyne/examples/
go run main.go

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

If you prefer a more declarative API then that is provided too. The following is exactly the same as the code above but in this different style.

package main

import "github.com/fyne-io/fyne"
import "github.com/fyne-io/fyne/desktop"
import "github.com/fyne-io/fyne/widget"

func main() {
	app := desktop.NewApp()

	w := app.NewWindow("Hello")
	w.SetContent(&widget.List{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.

fyne's People

Contributors

andydotxyz avatar edelmanjm avatar fsx avatar steveoc64 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.