<--SyntaxHighlighter--> SyntaxHighlighter.all();

Fyne를 이용하여 Layout 구성하는 예제입니다.

//Fyne Layout Test

package main

import (
	"fmt"

	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/layout"
	"fyne.io/fyne/widget"
)

func main() {
	f := app.New()
	w := f.NewWindow("")

	//상단에 넣을 위젯 및 레이아웃 - NewFormLayout
	lb_db_addr := widget.NewLabel("DB Address")
	tf_db_addr := widget.NewEntry()
	tf_db_addr.SetPlaceHolder("database@databaseservr.com:1526/orcl")

	lbUser := widget.NewLabel("Username")
	tfUser := widget.NewEntry()

	lbPass := widget.NewLabel("Password")
	tfPass := widget.NewPasswordEntry()

	qry := widget.NewEntry()
	btn_go := widget.NewButton("Go", func() { fmt.Println("Go Button") })

	ret := fyne.NewContainerWithLayout(layout.NewFormLayout())
	ret.AddObject(lb_db_addr)
	ret.AddObject(tf_db_addr)
	ret.AddObject(lbUser)
	ret.AddObject(tfUser)
	ret.AddObject(lbPass)
	ret.AddObject(tfPass)
	ret.AddObject(btn_go)
	ret.AddObject(qry)

	//하단에 넣을 위젯 및 전체 레이아웃 구성 - NewBorderLayout
	label2 := widget.NewLabel("Simple Data Search")
	labox2 := fyne.NewContainerWithLayout(layout.NewCenterLayout(), label2)

	b1 := widget.NewButton("Go1", func() { fmt.Println("Go1 Button") })
	b1.ExtendBaseWidget(b1)

	b2 := widget.NewButton("Go2", func() { fmt.Println("Go2 Button") })
	b2.ExtendBaseWidget(b2)

	out_entry := widget.NewEntry()
	out_entry.SetPlaceHolder("Results...")
	out_entry.ExtendBaseWidget(out_entry)

	frm := fyne.NewContainerWithLayout(layout.NewBorderLayout(ret, labox2, nil, nil)) //상, 하, 좌(없음), 우(없음)
	frm.AddObject(ret)                                                                //상단
	frm.AddObject(labox2)                                                             //하단
	frm.AddObject(out_entry)                                                          //좌-우가 없으므로 5번째에(center) 추가됨

	w.SetContent(frm)
	w.Resize(fyne.Size{Height: 640, Width: 480})
	w.ShowAndRun()

}

 

 

 

  1. HTML6 2020.04.07 15:47 신고

    오늘도 좋은 포스팅 잘 보고갑니다!^^

  2. ◇◆■□ 2020.04.09 01:04 신고

    어려운 내용이지만 잘 보고 갑니다 ㅎㅎ

+ Recent posts