tray

package module
v0.0.0-...-6c55236 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 1 Imported by: 0

README

Go tray for windows

Go tray for windows.

Download and Install
go get github.com/zooyer/tray
Generate rsrc.syso(depend app.manifest)
go get github.com/akavel/rsrc
rsrc -arch amd64 -manifest app.manifest -o rsrc.syso
Example
//go:generate rsrc -arch amd64 -manifest app.manifest -o rsrc.syso
func main() {
	tray, err := New(&Options{
		Tip: "test",
		Icon: "./logo.ico",
		Click: func(x, y int) {
			fmt.Println("x:", x, "y:", y)
		},
		Menus: Menus{
			{
				Name: "test",
				Action: func(tray *Tray) {
					fmt.Println("click test")
				},
			},
			{
				Name: "exit",
				Action: func(tray *Tray) {
					_ = tray.Stop()
				},
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	tray.Message("running", "is running")

	tray.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Menu struct {
	Name   string
	Action func(tray *Tray)
}
type Menus []Menu

type Option

type Option func(opts *Options)

func WithClick

func WithClick(click func(x, y int)) Option

func WithIcon

func WithIcon(icon string) Option

func WithMenus

func WithMenus(menus Menus) Option

func WithTip

func WithTip(tip string) Option

type Options

type Options struct {
	Tip   string
	Icon  string
	Click func(x, y int)
	Menus Menus
}

type Tray

type Tray struct {
	// contains filtered or unexported fields
}

func New

func New(options *Options, option ...Option) (*Tray, error)

func (*Tray) Message

func (t *Tray) Message(title, message string)

func (*Tray) Run

func (t *Tray) Run()

func (*Tray) Stop

func (t *Tray) Stop() (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL