Tutorials for Gio, the GUI framwork in Go.

Overview
#go, #golang, #gui, #gioui

You want a Gui. Of course you do.

Did you know that Go has a great GUI library called Gio? In a 10-part tutorial we will start completely from scratch, with zero background required, and build a self contained GUI application:

Screenshot of egg_timer

Get started - Time the egg

Background

Command-lines are great and all, but let's face it, 95% of users aren't power users. They want buttons to push, toggles to switch and simply get on with their lives. Enter Gio - a great toolkit to build stunningly beautiful, lightning fast, flexible interfaces that meet your needs.

Three out of three

For an interface to work, it must be:

  1. Beautiful
    • No one will use an app that looks like #$%$#!"#
  2. Fast
    • Snappy, instant, responsive, immediate, direct
    • Quick to code, easy to test
  3. Flexible
    • Fit your needs, your ideas, your principles
    • Not impose it's will on you
    • Simple should be simple, complex should be allowed

1 and 2 and 3. Beautiful AND Fast AND Flexible. No compromises.

Just do it

But I don't know how

Agreed, the official Gio website is a bit advanced. Nice repos exist with many examples, but where to start? If you're a practical learner, you simply want to get started, code something simple, and learn as you go along. That's me at least, and if you're like that too, we're soulmates.

So let's just do exactly that. The point here is to build something simple, from the ground up, and touch upon concepts and ideas as we go along. Every step moves us forward, and every new feature builds on something we've touched upon before. The goal is to change the initial I don't know to a more optimistic I don't know how - yet.

Come along for the ride!

Disclaimer

I really like Gio, I like the people behind it, I sponsor it financially, and I want it to succeed. But I´m by no means an expert. My goal is simply to share what I've learned in the hope that you find it useful. Hope that works.

Cheers

Comments
  • panic: runtime error: invalid memory address or nil pointer dereference

    panic: runtime error: invalid memory address or nil pointer dereference

    Getting the following error when I try to run the Eggtimer Blank window. The window runs briefly and then immediately closes. I can run the hello test from gioui.org perfectly. so don't think it's a missing install.

    `panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x10 pc=0xb0b91a]

    goroutine 8 [running, locked to thread]: gioui.org/app.(*Window).processEvent(0xc00020a000, {0xc44948, 0xc000206090}, {0xc42158?, 0xc000292000?})`

    opened by roborobs1023 10
  • Decide how to handle Chapter 1 process hanging issue

    Decide how to handle Chapter 1 process hanging issue

    This is a copypasta from #12 and I'm moving it to an issue because I don't want it to get lost. I think we need to decide what to do, if anything. Until I understand your direction a bit more I feel uncomfortable suggesting which way to go.

    The demo at the end of Chapter 1 does not contain an os.Exit(0) line. When the student clicks the window frame's X to exit the app, the window goes away but the process still hangs in the terminal.

    Now, you may know that already and it may be intentional for all I know. If it is, I agree with your call, because I'm pretty sure the added complexity to get the os.Exit(0) line into the right place would defeat the goal of keeping this chapter SIMPLE.

    BUT, if that IS your reason then my opinion is that you need to do an "information" or "warning" callout at the end of the chapter. The hung process looks bad and makes the project look bad for producing a "failed" demo. Providing just a sentence or two telling the student that "its intentional" and to use ctrl-c to exit the process eliminates this negative "broken" vibe.

    opened by BuckeyeCoder 5
  • undefined: clip.Circle

    undefined: clip.Circle

    Hi, I'm doing these tutorials, they are great.

    But I think they are out of date, the Circle has been removed from the package gioui.org/op/clip here: https://github.com/gioui/gio/commit/6534639276d7536b223b56326130f0c68a5e8278

    opened by StrawberryChocolateFudge 4
  • chore - Spelling and grammar

    chore - Spelling and grammar

    Errors noticed while following the egg timer tutorial.


    Thank you for writing this tutorial. I'll have to read it a couple more times for it to fully sink in, but it's a great start for the Gio journey.

    opened by jwhett 4
  • A few small typos

    A few small typos

    First of all thanks for the great tutorial!

    I wanted to give something back so I fixed some typos I found while I was following along.

    Namely:

    Chapter 1: Fix the link to Jeremy Bytes blog Chapter 5: FramEvent -> FrameEvent Chapter 6: margin -> margins Chapter 9: Use f32.Pt + float32 casts

    Thanks again for putting your time into this tutorial!

    opened by Caiofcas 2
  • The Chapter 10 missed some part of codes

    The Chapter 10 missed some part of codes

    Tutorial: Egg Timer Page: Input Boiltime Link : https://github.com/jonegil/gui-with-gio/blob/main/egg_timer/10_input_boiltime.md

    I tried to follow the Chapter 10. There are missed code lines in section 2. The editor widget:

    1. There is no clear how boilDuration is initialized. I assume it is extracted number from string boilDurationInput.
    2. There are some notes/comments how layouts are done, but there is no code for it.
    opened by miry 2
  • Teleprompter example unit handling

    Teleprompter example unit handling

    Hi @jonegil, I noticed an issue in your teleprompter program on my HiDPI screen. Namely, no text is visible. :D

    These lines (259-262) are the big problem: https://github.com/jonegil/gui-with-gio/blob/main/teleprompter/code/main.go#L259

    You are converting a value measured in pixels into DP with a cast. On my HiDPI screen, this means that if the value was originally 200 Px, it's now 200 Dp which is 400 Px. Setting the margins so high made no space for text to appear between them on my screen, so I saw nothing.

    It would be best to convert your codebase to work almost entirely in Dp and Sp. Raw pixel values are only for times when you need to directly invoke Ops (like clipping). Whenever working with layouts, try to use Dp (and Sp for text).

    I tried to convert your codebase to doing this for you, but there are a few places that you're using an integer value to modify both text size and positioning of elements, and changing that led to design decisions I didn't want to make for you. I suggest that you redefine all of the values at the top of draw() as one of the unit types and then handle the necessary conversions throughout your layout code. I'm happy to answer any questions you may have about how to do this.

    opened by whereswaldon 1
  • Chapter 3 questions

    Chapter 3 questions

    @jonegil let's leave this issue open until I conclude all Chapter 3 edits. Please reply with answers so I know what to do - thanks!

    CH3 Q1: Read the following:

    io/system - Provides high-level events that are sent from the window. Most important is the system.FrameEvent. It's effectively a list of operations that do one of two things: details how to handle input and describes what to display.

    This is confusing. Does it do one thing or two things? Sounds like two. If its two then it doesn't do

    one of two things

    it does two things. If its one thing then it "details OR describes", not "details AND describes". I'm not sure which one is right.

    opened by BuckeyeCoder 1
  • Linters Gone Wild

    Linters Gone Wild

    This PR is a bit different. Let's think about all the kinds of changes that can be made, and then divide them into two groups as follows:

    1. Changes that I wrote; we'll call these "substantive" changes;
    2. Changes coming from the Markdown linter I am using; we'll call those "linter" changes.

    With those definitions in place, I will tell you that I wasn't 100% pleased with the last PR. The quality was fine, but it was a challenge for me to see the substantive changes I made because they were swallowed up in all the noise emanating from the linter changes. Instead of the GitHub merging process showing us the small, "surgical strikes" that my edits usually are, it was deleting entire paragraphs and then replacing them simply because it wanted to replace triple back-ticks with single back-ticks.

    I would rather have a much quieter merging experience, wouldn't you?

    So, that spawned the idea for this PR. This is an entire PR dedicated solely to the Markdown linter! There is not even one substantive change in this entire PR. If its been changed, the linter did it; I am blameless lol.

    Now, be assured that I have still code reviewed each linter change here. If its here then I have agreed to it, albeit sometimes with a smirk. You're going to see the following:

    1. Genuine errors being corrected. This includes the code back-tick issue;
    2. The linter being very opinionated, even to the point of being a bit ridiculous.

    A common example of the second point is when using italics. There are two perfectly valid forms in Markdown for making a word italic: single asterisks and single underscores. Why there needs to be two I don't know, but there are. For no reason — other than having an opinion — this linter changes asterisks to underscores. Does it hurt anything? No. But it certainly makes for a lot of changes when the author preferred asterisks when writing, thus my smirking.

    By giving the linter a chance to get its chattiness over with, future PR's will be much quieter with near 100% substantive changes. This PR is an investment towards a quieter, more studious future. — DW

    opened by BuckeyeCoder 1
  • capitalize GUI consistently

    capitalize GUI consistently

    Being consistent with words / abbreviations is recommended.

    Markdown (MD) tables should have a dashed line separating "header" columns from "body"; they render better.

    MD uses triple backticks ONLY for entire codeblocks (```go). When referencing a keyword like defer, just use single backticks.

    The words "intent" and "intention" are REALLY close, almost interchangeable. I've switched to "intent" for the following reasons:

    1. As used in the Goal section, the words "intention" and "section" — both ending in "tion" — just don't flow.
    2. Intention is usually when a person wants to do something. This tutorial is a more formal thing and "intent" is more formal than familiar.

    Link was missing its extension, but magically was still working? LOL

    Other "flow" changes, nothing major worth mentioning.

    Only got excited (!) in one place, I promise LOL

    opened by BuckeyeCoder 1
  • First couple of proofreading pages completed.

    First couple of proofreading pages completed.

    BTW, I'm Geek Stocks in case you're wondering WTF? (That's "WHO the fuck?") lol

    I'm not sure when I'll have time again to proofread so I'm submitting these now. Mostly minor stuff; one broken link. I do intend to get to all of the site as I have time.

    One important note for you to consider though. The demo at the end of Chapter 1 does not contain an os.Exit(0) line. When the student clicks the window frame's X to exit the app, the window goes away but the process still hangs in the terminal.

    Now, you may know that already and it may be intentional for all I know. If it is, I agree with your call, because I'm pretty sure the added complexity to get the os.Exit(0) line into the right place would defeat the goal of keeping this chapter SIMPLE.

    BUT, if that IS your reason then my opinion is that you need to do an "information" or "warning" callout at the end of the chapter. The hung process looks bad and makes the project look bad for producing a "failed" demo. Just a sentence or two telling the student that "its intentional" and just use ctrl-c to exit the process for now. And that you'll fix this issue in Chapter X (I haven't looked but it does get fixed.)

    Something to think about. I didn't propose anything because I didn't want to presuppose your intentions.

    opened by BuckeyeCoder 1
Cross platform GUI in Go based on Material Design

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

Fyne.io 18.8k Nov 22, 2022
Go wrapper around the Iup GUI toolset

Iup Go Wrapper iup is a Go wrapper around the Iup GUI toolkit. The project was started on April 27, 2011. Fork https://github.com/grd/iup is a fork of

grd 24 Nov 28, 2020
Platform-native GUI library for Go.

ui: platform-native GUI library for Go This is a library that aims to provide simple GUI software development in Go. It is based on my libui, a simple

Pietro Gagliardi 8.2k Nov 28, 2022
Go Wrapper for the wxWidgets GUI

This is the source code for wxGo a Go wrapper of the wxWidgets library. The actuall wxWidgets source code is not included and will need to be downloa

Jeroen Dirks 57 Oct 15, 2022
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)

Thanks to go-astilectron build cross platform GUI apps with GO and HTML/JS/CSS. It is the official GO bindings of astilectron and is powered by Electr

Quentin Renard 4.6k Nov 29, 2022
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)

gowd Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs) How to use this library: Download and install nwjs Install this library g

Danny 385 Nov 16, 2022
A Windows GUI toolkit for the Go Programming Language

About Walk Walk is a "Windows Application Library Kit" for the Go Programming Language. Its primarily useful for Desktop GUI development, but there is

Alexander Neumann 6.3k Nov 28, 2022
RobotGo, Go Native cross-platform GUI automation @vcaesar

Robotgo Golang Desktop Automation. Control the mouse, keyboard, bitmap, read the screen, Window Handle and global event listener. RobotGo supports Mac

vgo 8k Nov 22, 2022
Common library for Go GUI apps on Windows

winc Common library for Go GUI apps on Windows. It is for Windows OS only. This makes library smaller than some other UI libraries for Go.

Tad Vizbaras 139 Aug 23, 2022
Cross-platform GUI for go is never this easy and clean.

gimu Strongly suggest NOT to use this project anymore, the auto-generated cgo wrapper of Nuklear has a random crash issue which is hard to fix (becaus

Allen Dang 66 Jul 12, 2022
Windows GUI framework for Go.

gform is an easy to use Windows GUI toolkit for Go It provides two approaches to create UI. 1. Pure code. gform.Init() mainWindow := gform.NewForm(ni

Allen Dang 277 Nov 12, 2022
Easy Go GUI wrapper for interactive manipulation of visual algorithms/backend code.

RenderView ================ Install: go get github.com/TheGrum/renderview Needs either Shiny (limited functionality), Gio, go-gtk, or gotk3. The latt

null 28 Aug 4, 2022
Windows GUI library for Go (Golang). Comes with a graphical UI designer.

Version 2 Please go to Version 2 of this library for the latest version. Windows GUI Library This is a pure Go library to create native Windows GUIs.

null 154 Nov 1, 2022
Super minimal, rock-solid foundation for concurrent GUI in Go.

faiface/gui Super minimal, rock-solid foundation for concurrent GUI in Go. Installation go get -u github.com/faiface/gui Currently uses GLFW under th

Michal Štrba 455 Nov 14, 2022
Cross platform rapid GUI framework for golang based on Dear ImGui.

giu Cross platform rapid GUI framework for golang based on Dear ImGui and the great golang binding imgui-go. Any contribution (features, widgets, tuto

Allen Dang 1.6k Dec 1, 2022
This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

Nuklear Package nk provides Go bindings for nuklear.h — a small ANSI C gui library. See github.com/vurtun/nuklear. All the binding code has automatica

null 1.5k Nov 23, 2022
GUI toolkit for go

Mostly-immediate-mode GUI library for Go. Source port to go of an early version of nuklear. ⚠️ Subject to backwards incompatible changes. ⚠️ ⚠️ Featur

Alessandro Arzilli 752 Nov 26, 2022
A list of Go GUI projects

(Please follow @Go100and1 for updates on this page, and all kinds of details and facts in Go). A list of Go GUI/graphics/image related projects native

null 1k Nov 21, 2022
Odile is a simple GUI for the croc utility by Schollz.

Odile Odile is a simple GUI for the croc utility by Schollz. This program uses Fyne, a UI toolkit written in Go, as the graphical interface. Effort wa

null 12 Aug 18, 2022