示例#1
0
文件: versions.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	fmt.Printf("go-iup Version=%s\n", iup.IupGoVersion)
	fmt.Printf("   Iup Version=%s\n", iup.Version())
}
示例#2
0
文件: pplot.go 项目: DaviWei/iup
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()
}
示例#3
0
文件: greeter.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	// Line one contains a name entry box and a hello button
	someone = iup.Text((iup.TextActionFunc)(nameKeyEntry))
	helloSomeone := iup.Button("Say Hello",
		(iup.ActionFunc)(sayHelloToSomeone))

	line1 := iup.Hbox(iup.Label("Name:"), someone, helloSomeone)
	iup.SetAttributes(line1, "ALIGNMENT=ACENTER,GAP=5")

	// Line two contains two pre-defined hello buttons
	helloJohn := iup.Button("Hello John",
		(iup.ActionFunc)(sayHello),
		"TO_WHO=\"John Doe\"")

	helloJim := iup.Button("Hello Jim",
		(iup.ActionFunc)(sayHello),
		"TO_WHO=\"Jim Doe\"")

	line2 := iup.Hbox(iup.Label("Predefined greeters:"), helloJohn, helloJim)
	iup.SetAttributes(line2, "ALIGNMENT=ACENTER,GAP=5")

	form := iup.Vbox(line1, line2)
	iup.SetAttributes(form, "GAP=5,MARGIN=3x3")

	dlg := iup.Dialog(form, "TITLE=Greeter")
	iup.Show(dlg)

	iup.MainLoop()
}
示例#4
0
文件: rot13.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	menu := iup.Menu(
		iup.Submenu("File",
			iup.Menu(
				iup.Item("Load File", (iup.ActionFunc)(onLoadFile)),
				iup.Item("Rotate", (iup.ActionFunc)(onRotate)),
				iup.Item("Quit", (iup.ActionFunc)(onQuit)))),
		iup.Submenu("Help",
			iup.Menu(
				iup.Item("About Iup", (iup.ActionFunc)(onAboutIup)),
				iup.Item("About go-iup", (iup.ActionFunc)(onAboutIupGo)))))

	text = iup.Text("MULTILINE=YES,EXPAND=YES,WORDWRAP=YES,SIZE=250x100,SCROLLBAR=YES")
	mainBox := iup.SetAttrs(iup.Vbox(
		iup.Label("Text to be rotated:"),
		text,
		iup.SetAttrs(iup.Hbox(
			iup.Button("Load File", "PADDING=3x3", (iup.ActionFunc)(onLoadFile)),
			iup.Button("Rotate", "PADDING=3x3", (iup.ActionFunc)(onRotate)),
			iup.Button("Quit", "PADDING=3x3", (iup.ActionFunc)(onQuit)),
		), "MARGIN", "0x0"),
	), "MARGIN", "5x5", "GAP", "3")

	mainDlg = iup.SetAttrs(iup.Dialog(mainBox), "TITLE", "Rot 13")
	iup.SetAttributeHandle(mainDlg, "MENU", menu)
	iup.Show(mainDlg)

	iup.MainLoop()
}
示例#5
0
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()
}
示例#6
0
文件: getparam.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	abool := true
	aint := 10
	afloat := 1293.33
	aint2 := 192
	afloat2 := 0.5
	aangle := 90.0
	astr := "string text"
	aopt := 1  // opt/list defined in format string
	alist := 1 // this is the selected item
	afile := "hello.txt"
	acolor := "255 122 255"
	afont := "Courier, 24"
	astr2 := "hello\nworld"

	result := iup.GetParam("Sample",
		"Boolean: %b[No,Yes]\n"+
			"Integer 1: %i\n"+
			"Real 1: %r\n"+
			"Sep1 %t\n"+
			"Integer 2: %i[0,255]\n"+
			"Real 2: %r[-1.5,1.5,0.05]\n"+
			"Sep2 %t\n"+
			"Angle %a[0,360]\n"+
			"String: %s\n"+
			"Options: %o|item0|item1|item2|item3\n"+
			"List: %l|item0|item1|item2|item3\n"+
			"File: %f[OPEN|*.txt;*.asc|CURRENT|NO|NO]\n"+
			"Color: %c{Color Tip}\n"+
			"Font: %n\n"+
			"Sep3 %t\n"+
			"Multiline: %m\n",
		&abool, &aint, &afloat, &aint2, &afloat2, &aangle, &astr, &aopt, &alist, &afile,
		&acolor, &afont, &astr2)

	if result {
		fmt.Printf(
			"Boolean: %v\n"+
				"Integer 1: %v\n"+
				"Real 1: %v\n"+
				"Integer 2: %v\n"+
				"Real 2: %v\n"+
				"Angle %v\n"+
				"String: %v\n"+
				"Options: %v\n"+
				"List: %v\n"+
				"File: %v\n"+
				"Color: %v\n"+
				"Font: %v\n"+
				"Multiline: %v\n",
			abool, aint, afloat, aint2, afloat2, aangle, astr, aopt, alist, afile,
			acolor, afont, astr2)
	}
}
示例#7
0
文件: alarm.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	switch iup.Alarm("Question", "Are you enjoying go-iup?", "Yes!", "Of course!") {
	case 1:
		fmt.Printf("I knew you were!\n")

	case 2:
		fmt.Printf("Yeah, why wouldn't you be?\n")
	}
}
示例#8
0
文件: dlgs.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	//filename, code := iup.GetFile("./*.go")
	//fmt.Printf("code=%d, filename='%s'\n", code, filename)

	//r,g,b := iup.GetColor(0,0,150,180,200)
	//fmt.Printf("r=%d, g=%d, b=%d\n", r, g, b)

	//value, code := iup.GetText("Address", "123 Main St.\nSmall Town, TN 12345")
	//fmt.Printf("code=%d value='%s'\n", code, value)

	opts := []string{"John", "Doe", "Jim"}
	marks := []int{0, 0, 1}

	result, marks := iup.ListDialog(2, "Hello", opts, -1, 1, 10, marks)

	fmt.Printf("%v, %v\n", result, marks)
}
示例#9
0
文件: hello.go 项目: DaviWei/iup
func main() {
	iup.Open()
	defer iup.Close()

	iup.Message("Greetings", "Hello, World!")
}