Dear friends...
I am trying to develop a very simple application by using GO and Fyne. I use modular-programming-method by separate the sourcecode into 3 files ("main.go", "jendelalogin.go", "jendelautama.go").
But I have problem in creating and showing-up a window from inside a window.
For example from "main.go" I can ShowAndRun a window of "jendelalogin.go",
but I can not display a window (by ShowAndRun) of "jendelautama.go" from "jendelalogin.go".
If button of "tombol" is pressed then comes-out this error-message below.
The error-message is: "panic: Run() or ShowAndRun() must be called from main goroutine".
Is there any other ways to launch Window from the "jendelalogin.go"?
Anybody so nice giving me some advises? Please advice me....
====
// ./main.go
package main
import (
"fmt"
JendelaLogin "main/jendelalogin"
)
func main() {
fmt.Println("myERP _ GO+Fyne => MainClass")
JendelaLogin.Muncul()
}
=====
// ./jendelalogin/jendelalogin.go
package jendelalogin
import (
"fmt"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
JendelaUtama "main/jendelautama"
)
func Muncul() {
fmt.Println("myERP _ GO+Fyne => Formulir-Login")
myappJendelaLogin := app.New()
tombol := widget.NewButton("Launch jendelautama", func() {
JendelaUtama.Muncul()
})
kontener := container.New(layout.NewHBoxLayout(), tombol)
jendelalogin := myappJendelaLogin.NewWindow("myERP _ GO+Fyne => Formulir-Login")
jendelalogin.SetContent(kontener)
jendelalogin.ShowAndRun()
}
=====
// ./jendelautama/jendelautama.go
package jendelautama
import (
"fmt"
"fyne.io/fyne/v2/app"
)
func Muncul() {
fmt.Println("myERP _ GO+Fyne >> MainWindow")
myapp := app.New()
jendelautama := myapp.NewWindow("myERP _ GO+Fyne => MainWindow")
jendelautama.ShowAndRun()
}
===
Error-message:
"
ceo[sementara]$ go run main.go
myERP _ GO+Fyne => MainClass
myERP _ GO+Fyne => Formulir-Login
myERP _ GO+Fyne >> MainWindow
panic: Run() or ShowAndRun() must be called from main goroutine
goroutine 7 [running]:
fyne.io/fyne/v2/internal/driver/glfw.(gLDriver).Run(0xc000324000)
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/internal/driver/glfw/driver.go:159 +0x50
fyne.io/fyne/v2/internal/driver/glfw.(window).ShowAndRun(0xc000324000)
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/internal/driver/glfw/window.go:230 +0x2c
main/jendelautama.Muncul()
/fileserver/SoftDev/go/sementara/jendelautama/jendelautama.go:14 +0x86
main/jendelalogin.Muncul.func1()
/fileserver/SoftDev/go/sementara/jendelalogin/jendelalogin.go:19 +0x17
fyne.io/fyne/v2/widget.(Button).Tapped(0xc000374be0, 0xc00000c201)
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/widget/button.go:194 +0x53
fyne.io/fyne/v2/internal/driver/glfw.(window).mouseClickedHandleTapDoubleTap.func1()
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/internal/driver/glfw/window.go:634 +0x26
fyne.io/fyne/v2/internal/driver/common.(Window).RunEventQueue(0x0)
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/internal/driver/common/window.go:35 +0x3e
created by fyne.io/fyne/v2/internal/driver/glfw.(gLDriver).createWindow.func1
/fileserver/SoftDev/go/pkg/mod/fyne.io/fyne/v2@v2.2.1/internal/driver/glfw/window.go:942 +0x13b
exit status 2
ceo[sementara]$
"
ceo[sementara]$ cat go.mod
module main
go 1.17
require fyne.io/fyne/v2 v2.2.1
require (
fyne.io/systray v1.10.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564 // indirect
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
github.com/stretchr/testify v1.7.2 // indirect
github.com/tevino/abool v1.2.0 // indirect
github.com/yuin/goldmark v1.4.0 // indirect
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)
ceo[sementara]$