• Stars
    star
    273
  • Rank 150,780 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cross-platform UI library with native controls

iup-go

Build Status Go Reference

Go bindings for IUP, a multi-platform toolkit for building graphical user interfaces. The toolkit provides system native UI controls for Windows, Linux (GTK+), and macOS.

IUP C source code is included and compiled together with bindings. Note that the first build can take a few minutes.

Requirements

Go 1.17 is minimum required version (cgo.Handle, new style build tags).

Windows

On Windows, you need a C compiler, like Mingw-w64 or TDM-GCC. You can also build a binary in MSYS2 shell.

Note that Windows manifest is included in the build by default. IUP controls appearance will follow the system appearance only if the manifest is used. If not using the manifest, it will always look like Windows XP Classic. See below how to disable manifest if you want to include your own.

  • To remove console window, i.e., compile GUI app, build with -ldflags "-H=windowsgui".
  • You can add icon resource to .exe file with the rsrc tool.

windows

Linux

On Linux, you need a C compiler and GTK+ development packages.

  • Debian/Ubuntu: apt-get install libgtk-3-dev
  • RedHat/Fedora: dnf install gtk3-devel

When you are not using gl tag, the library is built with GDK_NULL to completely remove the X11 usage, so it should just work in Wayland.

You may provide explicit compiler and linker flags instead of using the defaults provided by pkg-config, if gtk3 and other dependencies are in a non-standard location:

CGO_CFLAGS="-I<include path> ..." CGO_LDFLAGS="-L<dir> -llib ..." go build -tags nopkconfig

Note that you can also build and link against the GTK2 version, see build tags below.

linux

macOS

On macOS, you need Xcode or Command Line Tools for Xcode.

Note that support for Cocoa is a work in progress. Not everything is implemented. If you can help with Cocoa or GLCanvas, please join the IUP mailing list. Also note that you must use and distribute binary in the .app directory, together with .nib compiled resources, see example.app.

You can also build for GTK+ in macOS, with gtk build tag. It will use Quartz native rendering. See screenshot, .app is not required with GTK+.

Install GTK+ development packages with brew.

  • brew install gtk+3

darwin

Other

Although not tested, the library should work on other Unix-like systems, FreeBSD, NetBSD, OpenBSD, DragonFly, Solaris, Illumos, and AIX.

You can also compile for time-tested Motif library if GTK+ is not available, though not all controls and attributes are possible, check the documentation for details.

  • Debian/Ubuntu: apt-get install libmotif-dev libxmu-dev libxpm-dev
  • RedHat/Fedora: dnf install motif-devel libXpm-devel

motif

Build tags

  • gl - build with support for GLCanvas (Windows and Linux)
  • gtk - use GTK+ in macOS or Windows
  • gtk2 - link with GTK2 version, default is GTK3 (Linux)
  • motif - build for X11/Motif 2.x environment
  • nomanifest - do not include manifest in Windows build
  • nopkgconfig - do not use pkg-config for compile and link flags. User specifies CGO_CFLAGS and CGO_LDFLAGS env vars

Documentation

IUP documentation is nice, every Go function in doc reference there. Also check Go Reference and Examples.

Thread-Safety

User interface (and OpenGL) is usually not thread-safe and IUP is not thread-safe. Some platforms enforce running UI on the main thread. Note that a goroutine can arbitrarily and randomly be scheduled or rescheduled on different running threads.

The secondary threads (goroutine) should not directly update the UI, instead, use PostMessage that is expected to be thread-safe. See example that sends data to an element, that will be received by a callback when the main loop regains control. You can also use the IdleFunc and Timer.

Cross-compile (Linux)

To cross-compile for Windows install MinGW toolchain.

$ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w"
$ file alarm.exe
alarm.exe: PE32+ executable (console) x86-64, for MS Windows

$ CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w"
$ file alarm.exe
alarm.exe: PE32 executable (console) Intel 80386, for MS Windows

To cross-compile for macOS install OSXCross toolchain.

$ CGO_ENABLED=1 CC=x86_64-apple-darwin21.1-clang GOOS=darwin GOARCH=amd64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=10.14'"
$ file alarm
alarm: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK>

$ CGO_ENABLED=1 CC=aarch64-apple-darwin21.1-clang GOOS=darwin GOARCH=arm64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=10.14'"
$ file alarm
alarm: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>

Credits

License

iup-go is MIT licensed, same as IUP. View LICENSE.

More Repositories

1

raylib-go

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
C
1,528
star
2

beeep

Go cross-platform library for sending desktop notifications, alerts and beeps
Go
1,428
star
3

cam2ip

Turn any webcam into an IP camera
Go
868
star
4

url2img

HTTP server with API for capturing screenshots of websites
Go
534
star
5

go-fitz

Golang wrapper for the MuPDF Fitz library
C
396
star
6

dlgs

Go cross-platform library for displaying dialogs and input boxes
Go
383
star
7

malgo

Mini audio library
C
285
star
8

go-unarr

Go bindings for unarr (decompression library for RAR, TAR, ZIP and 7z archives)
Go
280
star
9

x264-go

Go bindings for x264
Go
211
star
10

goiv

Small and simple image viewer written in pure Go.
Go
201
star
11

cbconvert

CBconvert is a Comic Book converter
Go
190
star
12

shm

System V shared memory functions in pure Go.
Go
126
star
13

mpeg

MPEG-1 Video decoder, MP2 Audio decoder and MPEG-PS Demuxer in pure Go
Go
124
star
14

bukanir

Bukanir streams movies and TV shows from bittorrent magnet links
Java
84
star
15

aac-go

Go bindings for vo-aacenc
Go
58
star
16

gsmgo

GSMGo is SMS HTTP server with REST API
Go
50
star
17

keepalived_exporter

Keepalived Prometheus Exporter
Go
44
star
18

go-sdl2-android-example

Go-SDL2 example running on Android
Java
32
star
19

vov

VoV is a high score game for Android
Go
30
star
20

jpegli

Go encoder/decoder for JPEG based on jpegli
Go
29
star
21

volti

Volti is GTK+ application for controlling audio volume from system tray/notification area
Python
28
star
22

pyhtmleditor

PyQt WYSIWYG HTML Editor
Python
26
star
23

go-mpv

Go bindings for libmpv
Go
26
star
24

acra-go

Backend for Application Crash Reports for Android (ACRA)
Go
24
star
25

avif

AVIF image encoder/decoder
Go
24
star
26

jpegxl

JPEG XL image encoder/decoder
Go
16
star
27

flite-go

Go bindings for Flite (festival-lite)
Go
14
star
28

webp

WebP image encoder/decoder
Go
11
star
29

crtaci

"Crtaći" searches YouTube, DailyMotion and Vimeo for good old cartoons
Go
10
star
30

vidextr

Simple video extractor for YouTube, DailyMotion and Vimeo in Go.
Go
10
star
31

heic

HEIC image decoder
Go
9
star
32

comic-utils

Comic book archive utils
Python
6
star
33

oss

oss provides access to OSS (Open Sound System) audio interface
Go
6
star
34

svg

SVG icon decoder
Go
6
star
35

jxl

Go decoder for JPEG XL image format
C
4
star
36

mpeg-examples

Examples for mpeg library
Go
4
star
37

framebuffer

Fork of removed repo github.com/jteeuwen/framebuffer
Go
4
star
38

go-smpeg2

Golang bindings for the smpeg2 - SDL2 MPEG Player Library
Go
4
star
39

prang

A violent point-and-shoot game for android
C
2
star
40

bgradio

Qt/libVLC online radio streaming player that runs in system tray
Python
2
star
41

vim

My Vim config
Vim Script
1
star
42

base64

Fork of goost.org/encoding/base64
Go
1
star
43

umtsmon

Qt4 port of umtsmon
C++
1
star
44

libtorrent-go

SWIG Go bindings for libtorrent-rasterbar
C++
1
star