func (p *MainWindow) createStdTab() *ui.Widget { w := ui.NewWidget() vbox := ui.NewVBoxLayout() w.SetLayout(vbox) ed := ui.NewLineEdit() ed.SetInputMask("0000-00-00") ed.SetText("2012-01-12") lbl := ui.NewLabel() lbl.SetText("Label") btn := ui.NewButton() btn.SetText("Button") chk := ui.NewCheckBox() chk.SetText("CheckBox") radio := ui.NewRadio() radio.SetText("Radio") cmb := ui.NewComboBox() cmb.AddItem("001") cmb.AddItem("002") cmb.AddItem("003") cmb.SetCurrentIndex(2) fmt.Println(cmb.CurrentIndex()) cmb.OnCurrentIndexChanged(func(v int) { fmt.Println(cmb.ItemText(v)) }) slider := ui.NewSlider() slider.SetTickInterval(50) slider.SetTickPosition(ui.TicksBothSides) slider.SetSingleStep(1) scl := ui.NewScrollBar() fmt.Println(slider.Range()) dial := ui.NewDial() dial.SetNotchesVisible(true) dial.SetNotchTarget(10) fmt.Println(dial.NotchSize()) vbox.AddWidget(ed) vbox.AddWidget(lbl) vbox.AddWidget(btn) vbox.AddWidget(chk) vbox.AddWidget(radio) vbox.AddWidget(cmb) vbox.AddWidget(slider) vbox.AddWidget(scl) vbox.AddWidget(dial) vbox.AddStretch(0) return w }
func (p *MainWindow) Init() *MainWindow { if p.Widget.Init() == nil { return nil } p.SetWindowTitle("MainWindow") p.tab = ui.NewTabWidget() p.tab.AddTab(p.createStdTab(), "Standard", nil) p.tab.AddTab(p.createMyTab(), "Custom", nil) p.tab.AddTab(p.createToolBox(), "ToolBox", nil) p.sbar = ui.NewStatusBar() menubar := ui.NewMenuBar() menu := ui.NewMenuWithTitle("&File") //menu.SetTitle("&File") menubar.AddMenu(menu) act := ui.NewAction() act.SetText("&Quit") act.OnTriggered(func(bool) { p.Close() }) ic := ui.NewIconWithFile("images/close.png") //defer ic.Close() act.SetIcon(ic) menu.AddAction(act) toolBar := ui.NewToolBar() toolBar.AddAction(act) toolBar.AddSeparator() cmb := ui.NewComboBox() cmb.AddItem("test1") cmb.AddItem("test2") cmb.SetToolTip("ComboBox") cmbAct := toolBar.AddWidget(cmb) fmt.Println(cmbAct) vbox := ui.NewVBoxLayout() vbox.SetMargin(0) vbox.SetSpacing(0) vbox.SetMenuBar(menubar) vbox.AddWidget(toolBar) vbox.AddWidget(p.tab) vbox.AddWidget(p.sbar) p.SetLayout(vbox) p.tab.OnCurrentChanged(func(index int) { p.sbar.ShowMessage("current: "+p.tab.TabText(index), 0) }) systray := ui.NewSystemTray() systray.SetContextMenu(menu) systray.SetIcon(ic) systray.SetVisible(true) systray.ShowMessage("hello", "this is a test", ui.Information, 1000) ic2 := systray.Icon() fmt.Println(ic2) p.SetWindowIcon(ic2) return p }