Hands-On GUI Application Development in Go

Book description

Discover Golang's GUI libraries such as Go-GTK (GIMP Toolkit) and Go-Qt and build beautiful, performant, and responsive graphical applications

Key Features

  • Conceptualize and build state-of-art GUI applications with Golang (Go)
  • Tackle the complexity of varying GUI application sizes with a structured and scalable approach
  • Get hands-on experience of GUI development with Shiny, and labs/ui, Fyne, and Walk

Book Description

Go is often compared to C++ when it comes to low-level programming and implementations that require faster processing, such as Graphical User Interfaces (GUIs). In fact, many claim that Go is superior to C++ in terms of its concurrency and ease of use. Most graphical application toolkits, though, are still written using C or C++, and so they don't enjoy the benefits of using a modern programming language such as Go.

This guide to programming GUIs with Go 1.11 explores the various toolkits available, including UI, Walk, Shiny, and Fyne. The book compares the vision behind each project to help you pick the right approach for your project. Each framework is described in detail, outlining how you can build performant applications that users will love. To aid you further in creating applications using these emerging technologies, you'll be able to easily refer to code samples and screenshots featured in the book. In addition to toolkit-specific discussions, you'll cover more complex topics, such as how to structure growing graphical applications, and how cross-platform applications can integrate with each desktop operating system to create a seamless user experience. By delving into techniques and best practices for organizing and scaling Go-based graphical applications, you'll also glimpse Go's impressive concurrency system. In the concluding chapters, you'll discover how to distribute to the main desktop marketplaces and distribution channels.

By the end of this book, you'll be a confident GUI developer who can use the Go language to boost the performance of your applications.

What you will learn

  • Understand the benefits and complexities of building native graphical applications
  • Gain insights into how Go makes cross-platform graphical application development simple
  • Build platform-native GUI applications using andlabs/ui
  • Develop graphical Windows applications using Walk
  • Create multiplatform GUI applications using Shiny, Nuklear, and Fyne
  • Use Go wrappers for GTK and Qt for GUI application development
  • Streamline your requirements to pick the correct toolkit strategy

Who this book is for

This book is designed for Go developers who are interested in building native graphical applications for desktop computers and beyond. Some knowledge of building applications using Go is useful, but not essential. Experience in developing GUIs is not required as the book explores the benefits and challenges they pose. This book will also be beneficial for GUI application developers who are interested in trying Go.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On GUI Application Development in Go
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Graphical User Interface Development
  7. The Benefits of Native Graphical Applications
    1. Return of the graphical application
      1. Personal computers
      2. From desktop to internet
      3. Smart phones, apps, and customer retention
    2. Native performance
    3. Integrated user experience
    4. Reliability and offline functionality
    5. Maintainability and testing
    6. Summary
  8. Graphical User Interface Challenges
    1. Standard look and feel or app theme
    2. GUIs and visual hierarchy
      1. Multiple documents
      2. Accessory windows
      3. Visual hierarchy
      4. Mobile standards
    3. Concurrency and multi-threading
      1. Switching threads
      2. Avoiding complexity
    4. Web services and cloud integration
      1. Communications
      2. Data parsing
      3. Standard components
    5. Developing for multiple platforms
      1. Cross-platform APIs
      2. Icons and design
      3. Testing
    6. Packaging and distribution
    7. Summary
  9. Go to the Rescue!
    1. Introduction
    2. Cross-platform for any application
      1. Cross-compiling
      2. Standard library
    3. Concurrency in language design
      1. Goroutines
      2. Channels
      3. The sync package
    4. Web services included as standard
    5. Choosing your look and feel
    6. Summary
  10. Section 2: Toolkits Using Existing Widgets
  11. Walk - Building Graphical Windows Applications
    1. Background and aims
    2. Get started with walk
      1. Setup
      2. Code
      3. Build
      4. Run
    3. Benefits of a declarative API
      1. Compared with the native API
      2. Using both APIs for flexibility
    4. Building a user interface
      1. Style
      2. Layout
      3. Toolbar and menu
      4. Communicating with the GUI
        1. View model
        2. Detail view
        3. List view
      5. Background processing
    5. Walk in a cross-platform application
    6. Summary
  12. andlabs UI - Cross-platform Native UIs
    1. Background and history
    2. Getting started with andlabs UI
      1. Prerequisites
        1. Microsoft windows
        2. macOS
        3. Linux
      2. Setup
        1. Rebuilding the UI library (workaround)
      3. Code
      4. Build
      5. Run
    3. Generic API for multiple platforms
      1. Controls
        1. Box
        2. Containers
        3. Widgets
        4. Menu
      2. Area and drawing
    4. Building a user interface
      1. Style
      2. Layout
        1. Main email window
        2. Email compose dialog
      3. Toolbar and menu
      4. Communicating with the GUI
      5. Background processing
        1. Example
    5. Challenges with multiple native GUIs
      1. Consistent style
        1. Brand styles
        2. User experience
      2. Testing
      3. Cross-compilation
        1. Building for Linux on macOS or windows
          1. macOS
          2. Windows
        2. Building for windows on Linux or macOS
        3. Building for macOS on Linux or Windows
        4. A better solution
    6. Summary
  13. Go-GTK - Multiple Platforms with GTK
    1. GTK+ background
    2. Getting started with Go-GTK
      1. Prerequisites
        1. Installing GTK+
          1. macOS
          2. Windows
          3. Linux
        2. Install Go-GTK
      2. Build
      3. Run
    3. Signals and namespaces
      1. Signals
      2. Passing data
      3. Namespaces
    4. Sample application
      1. Layout
      2. Compose layout
      3. Signaling
      4. Thread handling
      5. Cross compilation
    5. Theming
    6. Summary
  14. Go-Qt - Multiple Platforms with Qt
    1. Qt background
    2. Getting started with therecipe/qt
      1. Prerequisites
        1. Preparing CGo
        2. Installing Qt
          1. macOS
          2. Windows
          3. Linux
          4. License / Qt account
        3. Installing qt (the bindings)
      2. Build
      3. Run
    3. Object model and event handling
      1. Inheritance
      2. Memory management
      3. Signals and slots
    4. Sample application
      1. Layout
      2. The compose layout
      3. Signalling
      4. Thread handling
      5. Cross-compilation
    5. Theming
    6. Summary
  15. Section 3: Modern Graphical Toolkits
  16. Shiny - Experimental Go GUI API
    1. Background and the vision for Shiny
    2. Design and supported platforms
      1. Architecture
        1. Lower layer
        2. Higher layer
      2. Supported platforms
      3. Drivers currently included
    3. Getting started with Shiny
      1. Setup
      2. Example
      3. Cross-compiling
        1. Cross-compiling for macOS
    4. Widgets and material design
      1. Design
      2. Icons
      3. Themes
      4. Widgets
    5. Getting started continued
      1. Code
      2. Supporting code
      3. Build and Run
    6. Building a user interface
      1. Design
      2. Layout
      3. Navigation
      4. File list
      5. Image view
      6. Communicating with the GUI
      7. Background processing
    7. Summary
  17. nk - Nuklear for Go
    1. Background and design of Nuklear
    2. Rendering and platform support
      1. Rendering modules
      2. Supported platforms
    3. Getting started with nk
      1. Prerequisites
        1. Linux
        2. macOS and Windows
        3. Android
      2. Setup
      3. Example
      4. Code
      5. Build and run
      6. Cross-compiling
    4. Widgets, layout, and skinning
      1. Widgets
      2. Layout
        1. NkLayoutRow
        2. NkLayoutRowTemplate
        3. NkLayoutSpace
      3. Drawing
        1. Command queue
        2. Draw functions
      4. Skinning
    5. Building a user interface
      1. Layout
        1. Main email window
        2. Email compose dialog
      2. Toolbar and menu
      3. Communicating with the GUI
      4. Background processing
    6. Summary
  18. Fyne - Material Design-Based GUI
    1. Background and vision for Fyne
    2. Getting started with Fyne
      1. Prerequisites
        1. Linux
        2. macOS
      2. Setup
      3. Example
      4. Code
      5. Build and run
      6. Cross compiling
    3. Rendering and vector graphics
      1. Vector graphics
      2. Drivers
      3. Supported platforms
    4. Canvas, widgets, and layouts
      1. Canvas (drawing)
      2. Layout
      3. Widgets
      4. Themes
        1. Packaged themes
    5. Building a user interface
      1. Layout
        1. Main email window
        2. Compose dialog
      2. Toolbar and menu
      3. Communicating with the GUI
        1. Loading emails
        2. Sending email
      4. Background processing
    6. Building an image viewer
      1. Layout
      2. Navigation
      3. File listing
      4. Image view
      5. Communicating with the GUI
      6. Background processing
    7. Summary
  19. Section 4: Growing and Distributing Your Application
  20. Navigation and Multiple Windows
    1. Planning application layout
      1. Standard layouts
      2. Device form factors
      3. Responsive or adaptive design
      4. Custom layouts
    2. Navigating your application
      1. Progressive disclosure
        1. Example 1 – Microsoft Edge
        2. Example 2 – Skyscanner flight search
      2. Menus and toolbars
        1. Toolbar
        2. Menu 
      3. Multiple windows
    3. Window types and keeping things clean
      1. Standard dialogs
      2. Modal windows
      3. Window hints
        1. Sizes
        2. Other hints
    4. Notifications and task status
      1. Minor alerts
      2. Background progress
    5. Platform-specific considerations
      1. Window grouping
      2. Application instances
      3. Extra features
    6. Summary
  21. Concurrency, Networking, and Cloud Services
    1. Concurrency, threads, and GUI updates
      1. Managing long-running processes
        1. Signaling shutdown
        2. Checking completion
      2. Communicating through channels
      3. Graphical updates from goroutines
    2. Network resources and caching
      1. Loading remote resources
        1. Images
        2. JSON
      2. Caching resource data
    3. Connecting to cloud services
      1. Encoding
        1. JSON
        2. XML
      2. Authentication – OAuth 2.0
        1. First request
        2. Storing tokens
      3. Posting data
      4. GUI integration
        1. Incoming messages
        2. Activity notifications
          1. Spinner
          2. Status panel
    4. Consistent user experience when offline
      1. Caching responses
      2. Queuing actions
      3. Starting offline
    5. Summary
  22. Best Practices in Go GUI Development
    1. Separation of concerns
      1. Suggested application structure
    2. Test-driving UI development
      1. Designed to be testable
      2. Example application test
    3. Continuous integration for GUIs
      1. Approaches to GUI test automation
      2. Avoiding external dependencies
    4. Managing platform specifics
    5. Summary
  23. Distributing Your Application
    1. Metadata and icons
      1. Application icon
      2. Describing your app
    2. Bundling assets
      1. go-bindata
      2. packr
      3. rsrc
      4. fyne bundle
    3. Building a release
      1. Preparing
        1. Compiler installation
      2. Building
      3. Packaging
        1. Linux
          1. Create metadata files
          2. Packaging release
        2. macOS
          1. Creating metadata files
          2. Packaging release
        3. Windows
          1. Creating metadata files
          2. Packaging release
        4. Cross-platform packaging tools
          1. fyne package
    4. Distributing to platform marketplaces
      1. Mac App Store
        1. Packaging
        2. Uploading
        3. Reviewing
      2. Microsoft Store
        1. Packaging
        2. Uploading
        3. Reviewing
      3. Linux package manager
        1. Debian (.deb)
          1. Packaging
          2. Distribution
        2. Red Hat (.rpm)
          1. Packaging
          2. Distribution
        3. Tarball (.tar.gz)
          1. Arch Linux
          2. Gentoo Linux
          3. Others
        4. Containers
    5. Summary
  24. Installation Details
    1. Installing Go
      1. Microsoft Windows
        1. Git
        2. Go
        3. Environment
      2. Apple macOS
      3. Linux
    2. Setting up Cgo
      1. Microsoft Windows
      2. Apple macOS
      3. Linux
  25. Cross Compiler Setup
    1. Cross compiling for macOS with CGo
      1. To macOS from Linux or Windows
    2. Cross compiling for Windows with CGo
      1. To Windows from macOS
      2. To Windows from Linux
    3. Cross compiling for Linux with CGo
      1. To Linux from macOS
      2. To Linux from Windows
  26. Comparison of GUI Toolkits
  27. Connecting GoMail to a Real Email Server
    1. Download Gmail credentials
    2. Creating a server provider
      1. Downloading inbox messages
      2. Sending messages
      3. Listening for new messages
    3. Updating an example to use Gmail
  28. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On GUI Application Development in Go
  • Author(s): Andrew Williams
  • Release date: February 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789138412