func main() { iup.Open() defer iup.Close() browserFunc := func(attr, val string) iup.ActionFunc { return (iup.ActionFunc)(func(ih *iup.Ihandle) int { iup.StoreAttribute(browser, attr, val) return iup.DEFAULT }) } urlentry = iup.Text("EXPAND=HORIZONTAL", (iup.KAnyFunc)(onUrlEntryKey)) browser = webbrowser.WebBrowser("EXPAND=YES", (webbrowser.NavigateFunc)(updateUrlEntry), (webbrowser.CompletedFunc)(updateUrlEntry)) backbutton := iup.Button("<<", browserFunc("BACKFORWARD", "-1")) forbutton := iup.Button(">>", browserFunc("BACKFORWARD", "1")) relbutton := iup.Button("Reload", browserFunc("RELOAD", "1")) gobutton := iup.Button("Go...", (iup.ActionFunc)(onGo)) stopbutton := iup.Button("Stop", browserFunc("STOP", "1")) toolbar := iup.SetAttrs(iup.Hbox(backbutton, forbutton, relbutton, urlentry, gobutton, stopbutton), "MARGIN", "5x5", "GAP", "3") dialog := iup.Dialog(iup.Vbox(toolbar, browser), "SIZE=500x300,TITLE=\"go-iup Web Browser\"") iup.Show(dialog) iup.StoreAttribute(browser, "VALUE", "http://github.com/jcowgar/go-iup") iup.MainLoop() }
func main() { iup.Open() defer iup.Close() p := pplot.Open("EXPAND=YES") iup.StoreAttribute(p, "TITLE", "Bar Mode") iup.StoreAttribute(p, "TITLEFONTSIZE", "16") iup.StoreAttribute(p, "MARGINTOP", "40") iup.StoreAttribute(p, "MARGINLEFT", "30") iup.StoreAttribute(p, "MARGINBOTTOM", "65") labels := []string{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} values := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} pplot.Begin(p, 1) for i := 0; i < len(labels); i++ { pplot.AddString(p, labels[i], values[i]) } pplot.End(p) iup.StoreAttribute(p, "DS_MODE", "BAR") iup.StoreAttribute(p, "DS_COLOR", "100 100 200") dlg := iup.Dialog(p, "SIZE=200x200,TITLE=\"PPlot Example\"") iup.Show(dlg) iup.StoreAttribute(p, "REDRAW", "") iup.MainLoop() }
func onRotate(ih *iup.Ihandle) int { content := iup.GetAttribute(text, "VALUE") content = rot13(content) iup.StoreAttribute(text, "VALUE", string(content)) return iup.DEFAULT }
func onLoadFile(ih *iup.Ihandle) int { dlg := iup.FileDlg("ALLOWNEW=NO,DIALOGTYPE=Open,TITLE=Open") iup.SetAttributeHandle(dlg, "PARENTDIALOG", mainDlg) iup.Popup(dlg, iup.CENTER, iup.CENTER) if iup.GetInt(dlg, "STATUS") == -1 { return iup.IGNORE } filename := iup.GetAttribute(dlg, "VALUE") iup.Destroy(dlg) content, err := ioutil.ReadFile(filename) if err != nil { iup.Message("Error", fmt.Sprintf("Error: %s", err)) return iup.IGNORE } iup.StoreAttribute(text, "VALUE", string(content)) return iup.IGNORE }
func onGo(ih *iup.Ihandle) int { iup.StoreAttribute(browser, "VALUE", iup.GetAttribute(urlentry, "VALUE")) return iup.DEFAULT }
func updateUrlEntry(ih *iup.Ihandle, url string) int { iup.StoreAttribute(urlentry, "VALUE", url) return iup.DEFAULT }