Documentation ¶
Overview ¶
Package goey provides a declarative, cross-platform GUI. The range of controls, their supported properties and events, should roughly match what is available in HTML. However, properties and events may be limited to support portability. Additionally, styling of the controls will be limited, with the look of controls matching the native platform.
The minimal GUI example application is bitbucket.org/rj/goey/example/onebutton, and additional example applications are in the example folder.
Screenshots ¶
There are screenshots of some of the example applications linked in the README, located at https://bitbucket.org/rj/goey/src/default/README.md.
Windows ¶
To get properly themed controls, a manifest is required. Please look at the source for the example applications for an example. This file needs to be compiled with github.com/akavel/rsrc to create a .syso that will be recognize by the go build program. Additionally, you could use build flags (-ldflags="-H windowsgui") to change the type of application built.
CGO is not required.
Linux ¶
Although this package does not use CGO, some of its dependencies do. The build machine also requires that GTK+ 3 is installed. This should be installed before issuing `go get` or you will have error messages during the building of some of the dependencies.
On Ubuntu:
sudo apt-get install libgtk-3-dev
Darwin (MacOS)
A port to darwin using the Cocoa API is in the repository, but is only available under the macos branch. Development has been done on linux using GNUstep, so the build tags will need to be updated to build on a darwin system.
Index ¶
- Constants
- Variables
- type Align
- type Alignment
- type Button
- type Checkbox
- type Control
- func (w *Control) Close()
- func (w *Control) Handle() uintptr
- func (w *Control) Layout(bc base.Constraints) base.Size
- func (w *Control) MinIntrinsicHeight(width base.Length) base.Length
- func (w *Control) MinIntrinsicWidth(base.Length) base.Length
- func (w *Control) OnDestroy()
- func (w *Control) SetBounds(bounds base.Rectangle)
- func (w *Control) TakeFocus() bool
- func (w *Control) TypeKeys(text string) chan error
- type CrossAxisAlign
- type DateInput
- type Decoration
- type Empty
- type Expand
- type HBox
- type HR
- type Img
- type Insets
- type IntInput
- type Label
- type MainAxisAlign
- type P
- type Padding
- type Progress
- type SelectInput
- type Slider
- type TabItem
- type Tabs
- type TextAlignment
- type TextArea
- type TextInput
- type VBox
- type Window
- func (w *Window) Child() base.Element
- func (w *Window) Close()
- func (w *Window) Message(text string) *dialog.Message
- func (w *Window) MinSize() base.Size
- func (w *Window) OnDeleteEvent() bool
- func (w *Window) OnDestroy()
- func (w *Window) OnSizeAllocate(width, height int)
- func (w *Window) OpenFileDialog() *dialog.OpenFile
- func (w *Window) SaveFileDialog() *dialog.SaveFile
- func (w *Window) Screenshot() (image.Image, error)
- func (w *Window) Scroll() (horizontal, vertical bool)
- func (w *Window) SetChild(child base.Widget) error
- func (w *Window) SetIcon(img image.Image) error
- func (w *Window) SetOnClosing(callback func() bool)
- func (w *Window) SetScroll(horizontal, vertical bool)
- func (w *Window) SetTitle(title string) error
- func (w *Window) Title() string
Examples ¶
Constants ¶
const ( DIP = base.DIP // Device-independent pixel (1/96 inch) PT = base.PT // Point (1/72 inch) PC = base.PC // Pica (1/6 inch or 12 points) Inch = base.Inch // Inch from a British imperial system of measurements )
Common lengths used when describing GUIs. Note that the DIP (device-independent pixel) is the natural unit for this package. Because of limited precision, the PT listed here is somewhat smaller than its correct value.
Variables ¶
var ( // ErrSetChildrenNotReentrant is returned if a reentrant call to the method // SetChild is called. ErrSetChildrenNotReentrant = errors.New("method SetChild is not reentrant") )
Functions ¶
This section is empty.
Types ¶
type Align ¶
type Align struct { HAlign Alignment // Horizontal alignment of child widget. VAlign Alignment // Vertical alignment of child widget. WidthFactor float64 // If greater than zero, ratio of container width to child width. HeightFactor float64 // If greater than zero, ratio of container height to child height. Child base.Widget // Child widget. }
Align describes a widget that aligns a single child widget within its borders.
The default position is for the child widget to be centered. To change the position of the child, the horizontal and vertical alignment (the fields HAlign and VAlign) should be adjusted.
The size of the control depends on the WidthFactor and HeightFactor. If zero, the widget will try to be as large as possible or match the child, depending on whether the box constraints are bound or not. If a factor is greater than zero, then the widget will try to size itself to be that much larger than the child widget.
type Alignment ¶
type Alignment int16
Alignment represents the position of a child widget along one dimension. Some common values for alignment, such as AlignStart, AlignCenter, and AlignEnd, are given constants, but other values are possible. For example, to align a child with an position of 25%, use (AlignStart + AlignCenter) / 2.
const ( AlignStart Alignment = -32768 // Widget is aligned at the start (left or top). AlignCenter Alignment = 0 // Widget is aligned at the center. AlignEnd Alignment = 0x7fff // Widget is aligned at the end (right or bottom). )
Common values for alignment, representing the position of child widget.
type Button ¶
type Button struct { Text string // Text is a caption for the button. Disabled bool // Disabled is a flag indicating that the user cannot interact with this button. Default bool // Default is a flag indicating that the button represents the default action for the interface. OnClick func() // OnClick will be called whenever the user presses the button. OnFocus func() // OnFocus will be called whenever the button receives the keyboard focus. OnBlur func() // OnBlur will be called whenever the button loses the keyboard focus. }
Button describes a widget that users can click to initiate an action.
Simultaneously setting both disabled and default to true is not supported. It may or may not work, depending on the platform.
Example ¶
clickCount := 0 // In a full application, this variable would be updated to point to // the main window for the application. var mainWindow *Window // These functions are used to update the GUI. See below var update func() var render func() base.Widget // Update function update = func() { err := mainWindow.SetChild(render()) if err != nil { panic(err) } } // Render function generates a tree of Widgets to describe the desired // state of the GUI. render = func() base.Widget { // Prep - text for the button text := "Click me!" if clickCount > 0 { text = text + " (" + strconv.Itoa(clickCount) + ")" } // The GUI contains a single widget, this button. return &VBox{ AlignMain: MainCenter, AlignCross: CrossCenter, Children: []base.Widget{ &Button{Text: text, OnClick: func() { clickCount++ update() }}, }, } }
Output:
type Checkbox ¶
type Checkbox struct { Text string // Text is a caption for the checkbox. Value bool // Is the checkbox checked? Disabled bool // Disabled is a flag indicating that the user cannot interact with this checkbox. OnChange func(value bool) // OnChange will be called whenever the value (checked or unchecked) changes. OnFocus func() // OnFocus will be called whenever the checkbox receives the keyboard focus. OnBlur func() // OnBlur will be called whenever the checkbox loses the keyboard focus. }
Checkbox describes a widget that users input or update a flag. The model for the value is a boolean value.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control is an opaque type used as a platform-specific handle to a control created using the platform GUI. As an example, this will refer to a HWND when targeting Windows, but a *GtkWidget when targeting GTK.
Unless developping new widgets, users should not need to use this type.
Any method's on this type will be platform specific.
func (*Control) Close ¶
func (w *Control) Close()
Close removes the element from the GUI, and frees any associated resources.
func (*Control) Layout ¶
func (w *Control) Layout(bc base.Constraints) base.Size
Layout determines the best size for an element that satisfies the constraints.
func (*Control) MinIntrinsicHeight ¶
MinIntrinsicHeight returns the minimum height that this element requires to be correctly displayed.
func (*Control) MinIntrinsicWidth ¶
MinIntrinsicWidth returns the minimum width that this element requires to be correctly displayed.
type CrossAxisAlign ¶
type CrossAxisAlign uint8
CrossAxisAlign identifies the different types of alignment that are possible along the cross axis for vertical box and horizontal box layouts.
const ( Stretch CrossAxisAlign = iota // Children will be stretched so that the extend across box CrossStart // Children will be aligned to the left or top of the box CrossCenter // Children will be aligned in the center of the box CrossEnd // Children will be aligned to the right or bottom of the box )
Allowed values for alignment of the cross axis in a vertical box (VBox) or horizontal box (HBox).
type DateInput ¶
type DateInput struct { Value time.Time // Values is the current string for the field Disabled bool // Disabled is a flag indicating that the user cannot interact with this field OnChange func(value time.Time) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the field receives the keyboard focus OnBlur func() // OnBlur will be called whenever the field loses the keyboard focus }
DateInput describes a widget that users input or update a single date. The model for the value is a time.Time value.
type Decoration ¶
type Decoration struct { Fill color.RGBA // Background color used to fill interior. Stroke color.RGBA // Stroke color used to draw outline. Insets Insets // Space between border of the decoration and the child element. Radius base.Length // Radius of the widgets corners. Child base.Widget // Child widget. }
Decoration describes a widget that provides a border and background, and possibly containing a single child widget.
The size of the control will match the size of the child element, although padding will be added between the border of the decoration and the child element as specified by the field Insets.
func (*Decoration) Kind ¶
func (*Decoration) Kind() *base.Kind
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
type Empty ¶
type Empty struct { }
Empty describes a widget that is either a horizontal or vertical gap.
The size of the control will be a (perhaps platform dependent) spacing between controls. This applies to both the width and height.
type Expand ¶
type Expand struct { Factor int // Fraction (minus one) of available space used by this widget Child base.Widget // Child widget. }
Expand wraps another widget to indicate that the widget should expand to occupy any available space in a HBox or VBox. When used in any other context, the widget will be ignored, and behavior delegated to the child widget.
In an HBox or VBox, the widget will be positioned according to the rules of its child. However, any excess space along the main axis will be added based on the ratio of the widget's factor to the sum of factors for all widgets in the box.
type HBox ¶
type HBox struct { AlignMain MainAxisAlign // Control distribution of excess horizontal space when positioning children. AlignCross CrossAxisAlign // Control distribution of excess vertical space when positioning children. Children []base.Widget // Children. }
HBox describes a layout widget that arranges its child widgets into a row. Children are positioned in order from the left towards the right. The main axis for alignment is therefore horizontal, with the cross axis for alignment is vertical.
The size of the box will try to set a width sufficient to contain all of its children. Extra space will be distributed according to the value of AlignMain. Subject to the box constraints during layout, the height should match the largest minimum height of the child widgets.
type HR ¶
type HR struct { }
HR describes a widget that is a horizontal separator.
type Img ¶
type Img struct { Image image.Image // Image to be displayed. Width, Height base.Length // Dimensions for the image (see notes on sizing). }
Img describes a widget that contains a bitmap image.
The size of the control depends on the value of Width and Height. The fields Width and Height may be left uninitialized, in which case they will be modified in-place. If both of these fields are left as zero, then the size will be calculated from the image's size assuming that its resolution is 92 DPI. If only one dimension is zero, then it will be calculate to maintain the aspect ratio of the image.
func (*Img) Kind ¶
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*Img) Mount ¶
Mount creates an image control in the GUI. The newly created widget will be a child of the widget specified by parent.
func (*Img) UpdateDimensions ¶
func (w *Img) UpdateDimensions()
UpdateDimensions calculates default values for Width and Height if either or zero based on the image dimensions. The member Image cannot be nil.
type Insets ¶
Insets describe padding that should be added around a widget.
func DefaultInsets ¶
func DefaultInsets() Insets
DefaultInsets returns the (perhaps platform-dependent) default insets for widgets inside of a top-level window.
func UniformInsets ¶
UniformInsets returns a padding description where the padding is equal on all four sides.
type IntInput ¶
type IntInput struct { Value int64 // Value is the current value for the field Placeholder string // Placeholder is a descriptive text that can be displayed when the field is empty Disabled bool // Disabled is a flag indicating that the user cannot interact with this field Min, Max int64 // Min and Max set the range of Value OnChange func(value int64) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the field receives the keyboard focus OnBlur func() // OnBlur will be called whenever the field loses the keyboard focus OnEnterKey func(value int64) // OnEnterKey will be called whenever the use hits the enter key }
IntInput describes a widget that users input or update a single integer value. The model for the value is a int64.
If the field Min and Max are both zero, then a default range will be initialized covering the entire range of int64. Note that on some platforms, the control internally is a float64, so the entire range of int64 cannot be covered without lose of precision.
func (*IntInput) Kind ¶
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*IntInput) Mount ¶
Mount creates a text field in the GUI. The newly created widget will be a child of the widget specified by parent.
func (*IntInput) UpdateRange ¶
func (w *IntInput) UpdateRange()
UpdateRange sets a default range when the fields Min and Max are both default initialized. The default range matches the range of int64.
func (*IntInput) UpdateValue ¶
func (w *IntInput) UpdateValue()
UpdateValue clamps the field Value to the range [Min,Max].
type Label ¶
type Label struct {
Text string // Text is the contents of the label
}
Label describes a widget that provides a descriptive label for other fields.
Labels should not be empty, and should not contain leading or trailing spaces. If violated, the behaviour of the Label will depend on the GUI platform targeted.
type MainAxisAlign ¶
type MainAxisAlign uint8
MainAxisAlign identifies the different types of alignment that are possible along the main axis for a vertical box or horizontal box layout.
const ( MainStart MainAxisAlign = iota // Children will be packed together at the top or left of the box MainCenter // Children will be packed together and centered in the box. MainEnd // Children will be packed together at the bottom or right of the box SpaceAround // Children will be spaced apart SpaceBetween // Children will be spaced apart, but the first and last children will but the ends of the box. Homogeneous // Children will be allocated equal space. )
Allowed values for alignment of the main axis in a vertical box (VBox) or horizontal box (HBox).
func (MainAxisAlign) IsPacked ¶
func (a MainAxisAlign) IsPacked() bool
IsPacked returns true if the main axis alignment is a one where children will be packed together.
type P ¶
type P struct { Text string // Text is the content of the paragraph Align TextAlignment // Align is the text alignment for the paragraph }
P describes a widget that contains significant text, which can reflow if necessary.
For a short run of text, the widget will try to match the size of the text. For longer runs of text, the widget will try to keep the width between 20em and 80em.
type Padding ¶
type Padding struct { Insets Insets // Space between edge of element and the child element. Child base.Widget // Child widget. }
Padding describes a widget that adds some space around a single child widget.
The size of the control will match the size of the child element, although padding will be added between the border of the padding and the child element as specified by the field Insets.
type Progress ¶
type Progress struct { Value int // Value is the current value to be displayed Min, Max int // Min and Max set the range of Value }
Progress describes a widget that shows a progress bar. The model for the value is an int.
If both Min and Max are zero, then Max will be updated to 100. Other cases where Min == Max are not allowed.
func (*Progress) Kind ¶
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*Progress) Mount ¶
Mount creates a progress control in the GUI. The newly created widget will be a child of the widget specified by parent.
func (*Progress) UpdateRange ¶
func (w *Progress) UpdateRange()
UpdateRange sets a default range when the fields Min and Max are both default initialized.
func (*Progress) UpdateValue ¶
func (w *Progress) UpdateValue()
UpdateValue clamps the field Value to the range [Min,Max].
type SelectInput ¶
type SelectInput struct { Items []string // Items is an array of strings representing the user's possible choices Value int // Value is the index of the currently selected item Unset bool // Unset is a flag indicating that no choice has yet been made Disabled bool // Disabled is a flag indicating that the user cannot interact with this field OnChange func(value int) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the field receives the keyboard focus OnBlur func() // OnBlur will be called whenever the field loses the keyboard focus }
SelectInput describes a widget that users can click to select one from a fixed list of choices.
func (*SelectInput) Kind ¶
func (*SelectInput) Kind() *base.Kind
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*SelectInput) Mount ¶
Mount creates a select control (combobox) in the GUI. The newly created widget will be a child of the widget specified by parent.
func (*SelectInput) UpdateValue ¶
func (w *SelectInput) UpdateValue()
UpdateValue will ensure that the Value is within the range of choices provided by w.Items.
type Slider ¶
type Slider struct { Value float64 // Value is the current value for the field Disabled bool // Disabled is a flag indicating that the user cannot interact with this field Min, Max float64 // Min and Max set the range of Value OnChange func(float64) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the slider receives the keyboard focus. OnBlur func() // OnBlur will be called whenever the slider loses the keyboard focus. }
Slider describes a widget that users input or update a single real value. The model for the value is a float64.
If both Min and Max are zero, then Max will be updated to 100. Other cases where Min == Max are not allowed.
Example ¶
value := 0.0 // In a full application, this variable would be updated to point to // the main window for the application. var mainWindow *Window // These functions are used to update the GUI. See below var update func() var render func() base.Widget // Update function update = func() { err := mainWindow.SetChild(render()) if err != nil { panic(err) } } // Render function generates a tree of Widgets to describe the desired // state of the GUI. render = func() base.Widget { // Prep - text for the button text := "Value: " + strconv.FormatFloat(value, 'f', 1, 64) // The GUI contains a single widget, this button. return &VBox{ AlignMain: MainCenter, AlignCross: CrossCenter, Children: []base.Widget{ &Label{Text: text}, &Slider{ Value: value, OnChange: func(v float64) { value = v update() }, }, }, } } err := loop.Run(func() error { w, err := NewWindow("Slider", render()) if err != nil { return err } mainWindow = w return nil }) if err != nil { fmt.Println("Error:", err) } else { fmt.Println("OK") }
Output:
func (*Slider) Kind ¶
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*Slider) Mount ¶
Mount creates a slider control in the GUI. The newly created widget will be a child of the widget specified by parent.
If both fields Min and Max are zero, a default range will be created going from 0 to 100.
The field Value will be updated to lie within the range.
func (*Slider) UpdateRange ¶
func (w *Slider) UpdateRange()
UpdateRange sets a default range when the fields Min and Max are both default initialized.
func (*Slider) UpdateValue ¶
func (w *Slider) UpdateValue()
UpdateValue clamps the field Value to the range [Min,Max].
type TabItem ¶
type TabItem struct { Caption string // Text to describe the contents of this tab Child base.Widget // Child widget for the tab }
TabItem describes a tab for a Tab widget.
type Tabs ¶
type Tabs struct { Value int // Index of the selected tab Children []TabItem // Description of the tabs Insets Insets // Space between edge of element and the child element. OnChange func(int) // OnChange will be called whenever the user selects a different tab }
Tabs describes a widget that shows a tabs.
The size of the control will match the size of the currently selected child element, although padding will added as required to provide space for the border and the tabs. However, when the user switches tabs, a relayout of the entire window is not forced.
When calling UpdateProps, setting Value to an integer less than zero will leave the currently selected tab unchanged.
func (*Tabs) Kind ¶
Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.
func (*Tabs) Mount ¶
Mount creates a tabs control in the GUI. The newly created widget will be a child of the widget specified by parent.
func (*Tabs) UpdateValue ¶
func (w *Tabs) UpdateValue()
UpdateValue ensures that the index for the currently selected tab is with the allowed range.
type TextAlignment ¶
type TextAlignment uint8
TextAlignment identifies the different types of text alignment that are possible.
const ( JustifyLeft TextAlignment = iota // Text aligned to the left (ragged right) JustifyCenter // Text aligned to the center JustifyRight // Text aligned to the right (ragged left) JustifyFull // Text justified so that both left and right are flush )
Allowed values for text alignment for text in paragraphs.
type TextArea ¶
type TextArea struct { Value string // Values is the current string for the field Placeholder string // Placeholder is a descriptive text that can be displayed when the field is empty Disabled bool // Disabled is a flag indicating that the user cannot interact with this field ReadOnly bool // ReadOnly is a flag indicate that the contents cannot be modified by the user MinLines int // MinLines describes the minimum number of lines that should be visible for layout OnChange func(value string) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the field receives the keyboard focus OnBlur func() // OnBlur will be called whenever the field loses the keyboard focus }
TextArea describes a widget that users input or update a multi-line of text. The model for the value is a string value.
Using a placeholder may not be supported on all platforms. No errors will be generated, but the placeholder text may not appear on screen.
type TextInput ¶
type TextInput struct { Value string // Value is the current string for the field Placeholder string // Placeholder is a descriptive text that can be displayed when the field is empty Disabled bool // Disabled is a flag indicating that the user cannot interact with this field Password bool // Password is a flag indicating that the characters should be hidden ReadOnly bool // ReadOnly is a flag indicate that the contents cannot be modified by the user OnChange func(value string) // OnChange will be called whenever the user changes the value for this field OnFocus func() // OnFocus will be called whenever the field receives the keyboard focus OnBlur func() // OnBlur will be called whenever the field loses the keyboard focus OnEnterKey func(value string) // OnEnterKey will be called whenever the use hits the enter key }
TextInput describes a widget that users input or update a single line of text. The model for the value is a string value.
Note that changing the value of the field Password is not supported on all platforms.
Example ¶
// In a full application, this variable would be updated to point to // the main window for the application. var mainWindow *Window // These functions are used to update the GUI. See below var update func() var render func() base.Widget // Update function update = func() { err := mainWindow.SetChild(render()) if err != nil { panic(err) } } // Render function generates a tree of Widgets to describe the desired // state of the GUI. render = func() base.Widget { // Prep - text for the button // The GUI contains a single widget, this button. return &VBox{Children: []base.Widget{ &Label{Text: "Enter you text below:"}, &TextInput{ Value: "", Placeholder: "Enter your data here", OnChange: func(value string) { fmt.Println("Change: ", value) // In a real example, you would update your data, and then // need to render the window again. update() }, }, }} }
Output:
type VBox ¶
type VBox struct { AlignMain MainAxisAlign AlignCross CrossAxisAlign Children []base.Widget }
VBox describes a layout widget that arranges its child widgets into a column. Children are positioned in order from the top towards the bottom. The main axis for alignment is therefore vertical, with the cross axis for alignment is horizontal.
The size of the box will try to set a width sufficient to contain all of its children. Extra space will be distributed according to the value of AlignMain. Subject to the box constraints during layout, the height should match the largest minimum height of the child widgets.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents a top-level window that contain other widgets.
func NewWindow ¶
NewWindow create a new top-level window for the application.
Example ¶
// All calls that modify GUI objects need to be schedule ont he GUI thread. // This callback will be used to create the top-level window. createWindow := func() error { // Create a top-level window. mw, err := NewWindow("Test", &VBox{ Children: []base.Widget{ &Button{Text: "Click me!"}, }, }) if err != nil { // This error will be reported back up through the call to // Run below. No need to print or log it here. return err } // We can start a goroutine, but note that we can't modify GUI objects // directly. go func() { fmt.Println("Up") time.Sleep(50 * time.Millisecond) fmt.Println("Down") // Note: No work after this call to Do, since the call to Run may be // terminated when the call to Do returns. _ = loop.Do(func() error { mw.Close() return nil }) }() return nil } // Start the GUI thread. err := loop.Run(createWindow) if err != nil { fmt.Println("Error: ", err) }
Output: Up Down
func (*Window) Child ¶
Child returns the mounted child for the window. In general, this method should not be used.
func (*Window) Close ¶
func (w *Window) Close()
Close destroys the window, and releases all associated resources.
func (*Window) Message ¶
Message returns a builder that can be used to construct a message dialog, and then show that dialog.
Example ¶
// All calls that modify GUI objects need to be schedule ont he GUI thread. // This callback will be used to create the top-level window. createWindow := func() error { // Create a top-level window. mw, err := NewWindow("Test", &Button{Text: "Click me!"}) if err != nil { // This error will be reported back up through the call to // Run below. No need to print or log it here. return err } // We can start a goroutine, but note that we can't modify GUI objects // directly. go func() { // Show the error message. _ = loop.Do(func() error { return mw.Message("This is an example message.").WithInfo().Show() }) // Note: No work after this call to Do, since the call to Run may be // terminated when the call to Do returns. _ = loop.Do(func() error { mw.Close() return nil }) }() return nil } // Start the GUI thread. err := loop.Run(createWindow) if err != nil { fmt.Println("Error: ", err) }
Output:
func (*Window) MinSize ¶ added in v0.9.0
MinSize returns the minimum size required to layout the child. The minimum size depends on the child, but also on what dimensions are allowed to scroll.
func (*Window) OnDeleteEvent ¶
func (w *Window) OnDeleteEvent() bool
func (*Window) OnSizeAllocate ¶
func (w *Window) OnSizeAllocate(width, height int)
func (*Window) OpenFileDialog ¶
OpenFileDialog returns a builder that can be used to construct an open file dialog, and then show that dialog.
func (*Window) SaveFileDialog ¶
SaveFileDialog returns a builder that can be used to construct a save file dialog, and then show that dialog.
func (*Window) Screenshot ¶
Screenshot returns an image of the window, as displayed on screen.
func (*Window) Scroll ¶
Scroll returns the flags that determine whether scrolling is allowed in the horizontal and vertical directions.
func (*Window) SetChild ¶
SetChild changes the child widget of the window. As necessary, GUI widgets will be created or destroyed so that the GUI widgets match the widgets described by the parameter children. The position of contained widgets will be updated to match the new layout properties.
func (*Window) SetIcon ¶
SetIcon changes the icon associated with the window.
On Cocoa, individual windows do not have icons. Instead, there is a single icon for the entire application.
func (*Window) SetOnClosing ¶
SetOnClosing changes the event callback for when the user tries to close the window. This callback can also be used to save or close any resources before the window is closed.
Returning true from the callback will prevent the window from closing.
func (*Window) SetScroll ¶
SetScroll sets whether scrolling is allowed in the horizontal and vertical directions.
Source Files ¶
- align.go
- button.go
- button_gtk.go
- checkbox.go
- checkbox_gtk.go
- dateinput.go
- dateinput_gtk.go
- decoration.go
- decoration_gtk.go
- doc.go
- empty.go
- expand.go
- hbox.go
- hr.go
- hr_gtk.go
- img.go
- img_gtk.go
- intinput.go
- intinput_gtk.go
- label.go
- label_gtk.go
- layout.go
- length.go
- mainwindow.go
- mainwindow_gtk.go
- padding.go
- paragraph.go
- paragraph_gtk.go
- progress.go
- progress_gtk.go
- screenshot.go
- selectinput.go
- selectinput_gtk.go
- slider.go
- slider_gtk.go
- tabs.go
- tabs_gtk.go
- textarea.go
- textarea_gtk.go
- textinput.go
- textinput_gtk.go
- vbox.go
- widget_gtk.go
Directories ¶
Path | Synopsis |
---|---|
Package animate provides animation for GUIs built using the package goey.
|
Package animate provides animation for GUIs built using the package goey. |
Package base provides interfaces for the description, creation, and updating of GUI widgets.
|
Package base provides interfaces for the description, creation, and updating of GUI widgets. |
Package dialog provides common dialog boxes, such as message boxes, and open and save file dialogs.
|
Package dialog provides common dialog boxes, such as message boxes, and open and save file dialogs. |
example
|
|
align
This package provides an example application built using the goey package that shows use of the Align layout widget.
|
This package provides an example application built using the goey package that shows use of the Align layout widget. |
closing
This package provides an example application built using the goey package that demonstrates using the OnClosing callback for windows.
|
This package provides an example application built using the goey package that demonstrates using the OnClosing callback for windows. |
colour
This package provides an example application built using the goey package that demonstrates using the Image widget.
|
This package provides an example application built using the goey package that demonstrates using the Image widget. |
controls
This package provides an example application built using the goey package that demonstrates most of the controls that are available.
|
This package provides an example application built using the goey package that demonstrates most of the controls that are available. |
debounce
This package provides an example application built using the goey package that shows how an event be debounced.
|
This package provides an example application built using the goey package that shows how an event be debounced. |
decoration
This package provides an example application built using the goey package that demontrates using the Decoration widget.
|
This package provides an example application built using the goey package that demontrates using the Decoration widget. |
feettometer
This package provides an example application built using the goey package that rebuilds the classic Tcl/Tk tutorial application.
|
This package provides an example application built using the goey package that rebuilds the classic Tcl/Tk tutorial application. |
icons
This package provides an application built using the goey package that demonstrates using a custom widget.
|
This package provides an application built using the goey package that demonstrates using a custom widget. |
menu
This package provides an example application built using the goey package that shows a sidebar an array of buttons.
|
This package provides an example application built using the goey package that shows a sidebar an array of buttons. |
messagebox
This package provides an example application built using the goey package that shows the use of message boxes.
|
This package provides an example application built using the goey package that shows the use of message boxes. |
onebutton
This package provides an example application built using the goey package that shows a single button.
|
This package provides an example application built using the goey package that shows a single button. |
paragraph
This package provides an example application built using the goey package that demonstrates using the Image widget.
|
This package provides an example application built using the goey package that demonstrates using the Image widget. |
threebuttons
This package provides an example application built using the goey package that demonstrates three buttons with different behaviours.
|
This package provides an example application built using the goey package that demonstrates three buttons with different behaviours. |
todos
This package provides an example application built using the goey package that rebuilds the classic Todos tutorial application.
|
This package provides an example application built using the goey package that rebuilds the classic Todos tutorial application. |
twofields
This package provides an example application built using the goey package that demonstrates two multiline text fields.
|
This package provides an example application built using the goey package that demonstrates two multiline text fields. |
wipe
This package provides an example application built using the goey package that demonstrates using animation.
|
This package provides an example application built using the goey package that demonstrates using animation. |
Package icons provides a widget that displays a single icon from the Material Design Icons set.
|
Package icons provides a widget that displays a single icon from the Material Design Icons set. |
internal
|
|
cocoa
Package cocoa provides platform-dependent routines required to support the package goey when targeting Cocoa or GNUstep.
|
Package cocoa provides platform-dependent routines required to support the package goey when targeting Cocoa or GNUstep. |
cocoaloop
Package cocoaloop provides an API wrapper around C calls to Cocoa.
|
Package cocoaloop provides an API wrapper around C calls to Cocoa. |
gtk
Package gtk provides an API wrapper around C calls to GTK.
|
Package gtk provides an API wrapper around C calls to GTK. |
gtkloop
Package gtkloop provides an API wrapper around C calls to GTK.
|
Package gtkloop provides an API wrapper around C calls to GTK. |
nopanic
Package nopanic provides a utility to wrap function to prevent any panics from escaping.
|
Package nopanic provides a utility to wrap function to prevent any panics from escaping. |
windows
Package windows provides platform-dependent routines required to support the package goey.
|
Package windows provides platform-dependent routines required to support the package goey. |
logo
Module
|
|
Package loop provides a GUI event loop.
|
Package loop provides a GUI event loop. |
Package mock provides a mock widget to be used for testing the layout algorithms of container widgets.
|
Package mock provides a mock widget to be used for testing the layout algorithms of container widgets. |