Пример #1
0
func initGUI(ir *gothic.Interpreter) {
	ir.UploadImage("bg", loadPNG("background.png"))
	ir.Eval(`ttk::label .l -image bg`)
	ir.Eval(`pack .l -expand true`)
}
Пример #2
0
func proc(ir *gothic.Interpreter, num string) {
	button := ".b" + num
	progress := ".p" + num
	channame := "proc" + num
	recv := make(chan int)

	// register channel and enable button
	ir.RegisterCommand(channame, func(_ string, arg int) {
		recv <- arg
	})
	ir.Eval(`%{} configure -state normal`, button)

	for {
		// wait for an event
		<-recv

		// simulate activity
		ir.Eval(`%{} configure -state disabled -text "In Progress %{}"`, button, num)
		for i := 0; i <= 100; i += 2 {
			ir.Eval(`%{%s} configure -value %{}`, progress, i)
			time.Sleep(5e7)
		}

		// reset button state and progress value
		ir.Eval(`%{} configure -value 0`, progress)
		ir.Eval(`%{} configure -state normal -text "Start %{}"`, button, num)
	}
}