Exemple #1
0
func main() {
	qt5.Main(func() {
		go ui_main()
		qt5.Run()
		exit <- true
	})
}
Exemple #2
0
func main() {
	qt5.Main(func() {
		w := qt5.NewWidget()

		w.OnPaintEvent(func(e *qt5.PaintEvent) {
			paint := qt5.NewPainter()
			defer paint.Close()
			paint.Begin(w)
			pen := qt5.NewPen()
			pen.SetColor(color.RGBA{255, 128, 0, 0})
			pen.SetWidth(2)
			fmt.Println(pen, pen.Color(), pen.Width())
			paint.SetPen(pen)
			brush := qt5.NewBrush()
			brush.SetStyle(qt5.SolidPattern)
			brush.SetColor(color.RGBA{128, 128, 0, 255})
			paint.SetBrush(brush)
			paint.DrawRect(qt5.Rect{10, 10, 100, 100})
		})

		w.SetSize(qt5.Size{400, 400})
		w.Show()

		qt5.Run()
	})
}
Exemple #3
0
func main() {
	fmt.Println(qt5.Version())
	qt5.Main(func() {
		go main_ui()
		qt5.Run()
		exit <- true
	})
}
Exemple #4
0
func main() {
	qt5.Main(func() {
		w := qt5.NewWidget()
		w.SetWindowTitle(qt5.Version())
		w.SetSizev(300, 200)
		defer w.Close()
		w.Show()
		qt5.Run()
	})
}
Exemple #5
0
func main() {
	qt5.Main(func() {
		lcd := qt5.NewLCDNumber()
		lcd.SetWindowTitle("LCDNumber")
		lcd.SetSizev(200, 50)
		lcd.SetSegmentStyle(1)
		lcd.DisplayWithString("2016")
		defer lcd.Close()
		lcd.Show()
		qt5.Run()
	})
}
Exemple #6
0
func main() {
	qt5.Main(func() {
		p := qt5.NewProgressBar()
		p.SetWindowTitle("ProgressBar")
		//p.SetOrientation(qt5.Vertical)
		p.SetRange(0, 100)
		p.SetValue(50)
		p.SetFormat("%v/%m")
		p.SetGeometryv(30, 40, 200, 25)
		//p.SetTextVisible(false)
		//p.SetSizev(300, 200)
		defer p.Close()
		p.Show()
		qt5.Run()
	})
}
Exemple #7
0
func ui_main() {
	exit := make(chan bool)
	go func() {
		fmt.Println("vfc/ui")
		qt5.OnInsertObject(func(v interface{}) {
			fmt.Println("add item", v)
		})
		qt5.OnRemoveObject(func(v interface{}) {
			fmt.Println("remove item", v)
		})
		w := new(MainWindow).Init()
		defer w.Close()

		w.SetSizev(400, 300)
		w.OnCloseEvent(func(e *qt5.CloseEvent) {
			fmt.Println("close", e)
		})
		w.Show()
		<-exit
	}()
	qt5.Run()
	exit <- true
}
Exemple #8
0
func ui_main() {
	w := qt5.NewWidget()
	defer w.Close()
	list := qt5.NewListWidget()
	vbox := qt5.NewVBoxLayout()
	vbox.AddWidget(list)
	w.SetLayout(vbox)
	go func() {
		list.OnCurrentItemChanged(func(item, old *qt5.ListWidgetItem) {
			go func() {
				fmt.Println(item.Attr("text"))
			}()
		})

		item := qt5.NewListWidgetItem()
		item.SetText("Item1")
		list.AddItem(item)
		list.AddItem(qt5.NewListWidgetItemWithText("Item2"))
	}()

	w.Show()

	qt5.Run()
}
Exemple #9
0
func main() {
	py.InitializeEx(false)
	defer py.Finalize()
	e := backend.GetEditor()
	log4go.AddFilter("stdout", log4go.DEBUG, log4go.NewConsoleLogWriter())

	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
		log4go.Debug("scheme: %v", scheme)
	}

	backend.OnNewWindow.Add(new_window)
	backend.OnNew.Add(new_view)
	backend.OnModified.Add(view_modified)
	go e.Init()
	qt5.Main(func() {
		w := e.NewWindow()
		w.OpenFile("main.go", 0)
		w.OpenFile("../../backend/editor.go", 0)
		qt5.Run()
	})
}
Exemple #10
0
func ui_main() {
	w := qt5.NewWidget()
	defer w.Close()
	w.SetWindowTitle("Rose")

	rose := qt5.NewWidget()
	rose.SetMinimumSize(qt5.Sz(510, 510))

	img := qt5.NewImageWithSize(500, 500)
	defer img.Close()

	imgPainter := qt5.NewPainterWithImage(img)
	imgPainter.InitFrom(rose)
	defer imgPainter.Close()

	var timerid int = -1
	var count int
	var timerValue int = 50

	rose.OnTimerEvent(func(e *qt5.TimerEvent) {
		if e.TimerId() == timerid {
			draw(imgPainter)
			rose.Update()
			count++
			if count >= max {
				w.KillTimer(timerid)
			}
			w.SetWindowTitle(fmt.Sprintf("Rose: %d*1e4", count))
		}
	})
	rose.OnPaintEvent(func(e *qt5.PaintEvent) {
		painter := qt5.NewPainter()
		defer painter.Close()
		painter.Begin(rose)
		painter.DrawImageEx(qt5.Point{0, 0}, img, img.Rect())
		painter.End()
	})

	load := func() {
		if timerid != -1 {
			rose.KillTimer(timerid)
		}
		for k, _ := range m {
			delete(m, k)
		}
		img.Fill(rgb(255, 255, 255))
		count = 0
		timerid = rose.StartTimer(timerValue)
	}
	stop := func() {
		rose.KillTimer(timerid)
		timerid = -1
	}

	vbox := qt5.NewVBoxLayout()

	hbox := qt5.NewHBoxLayout()
	vbox.AddWidget(rose)
	vbox.AddLayout(hbox)

	loadBtn := qt5.NewButtonWithText("Reload")
	stopBtn := qt5.NewButtonWithText("Stop")
	exitBtn := qt5.NewButtonWithText("Exit")
	timerLabel := qt5.NewLabelWithText("Timer: 50 ")
	timerSlider := qt5.NewSlider()
	timerSlider.SetRange(1, 600)
	timerSlider.SetValue(50)
	timerSlider.OnValueChanged(func(v int) {
		timerValue = v
		timerLabel.SetText(fmt.Sprintf("Timer:%4d ", v))
	})
	maxLabel := qt5.NewLabelWithText("Max: 1024 ")
	maxSlider := qt5.NewSlider()
	maxSlider.SetRange(10, 10240)
	maxSlider.SetValue(1024)
	maxSlider.OnValueChanged(func(v int) {
		max = v
		maxLabel.SetText(fmt.Sprintf("Max:%5d ", v))
	})
	hbox.AddWidget(maxLabel)
	hbox.AddWidget(maxSlider)
	hbox.AddSpacing(10)
	hbox.AddWidget(timerLabel)
	hbox.AddWidget(timerSlider)
	hbox.AddSpacing(10)
	hbox.AddWidget(loadBtn)
	hbox.AddWidget(stopBtn)
	hbox.AddStretch(0)
	hbox.AddWidget(exitBtn)

	loadBtn.OnClicked(load)
	stopBtn.OnClicked(stop)
	exitBtn.OnClicked(func() {
		w.Close()
	})

	w.SetLayout(vbox)
	w.Show()

	w.OnCloseEvent(func(e *qt5.CloseEvent) {
		rose.KillTimer(timerid)
	})

	load()

	qt5.Run()
}
Exemple #11
0
func ui_main() {

	w := qt5.NewWidget()

	lbox := qt5.NewVBoxLayout()
	lbl1 := qt5.NewLabel()
	lbl1.SetText("This is a info1")
	lbl2 := qt5.NewLabel()
	lbl2.SetText("This is a info2")

	ed1 := qt5.NewLineEdit()

	printInfo := func() {
		info := qt5.Value("info")
		ed1.SetText(fmt.Sprint(info))
	}

	lbox.AddWidget(lbl1)
	lbox.AddWidget(lbl2)
	lbox.AddWidget(ed1)

	rbox := qt5.NewVBoxLayout()

	btn1 := qt5.NewButton()
	btn1.SetText("Change")

	btn2 := qt5.NewButton()
	btn2.SetText("Value")

	btn3 := qt5.NewButton()
	btn3.SetText("SetValue")

	rbox.AddWidget(btn1)
	rbox.AddWidget(btn2)
	rbox.AddWidget(btn3)

	b := true
	btn1.OnClicked(func() {
		var text string
		if b {
			qt5.SetKey(lbl1, "info", "text")
			text = "info1"
		} else {
			qt5.SetKey(lbl2, "info", "text")
			text = "info2"
		}
		b = !b
		btn1.SetText(text)
	})

	btn2.OnClicked(printInfo)
	btn3.OnClicked(setInfo)

	hbox := qt5.NewHBoxLayout()
	hbox.AddLayout(lbox)
	hbox.AddLayout(rbox)

	w.SetLayout(hbox)

	w.Show()

	qt5.Run()
}
Exemple #12
0
func main_ui() {
	qt5.OnInsertObject(func(v interface{}) {
		fmt.Println("add item", v)
	})
	qt5.OnRemoveObject(func(v interface{}) {
		fmt.Println("remove item", v)
	})
	w := qt5.NewMainWindow()
	defer w.Close()
	go func() {
		dock := qt5.NewDockWidgetWithTitle("Dock")
		dock.SetDock(qt5.NewButtonWithText("Hello"))
		w.AddDockWidget(qt5.LeftDockWidgetArea, dock)
		btn := qt5.NewButtonWithText("HideDock")
		w.SetCentralWidget(btn)
		w.SetSize(qt5.Sz(200, 200))

		tb := qt5.NewToolBarWithTitle("Standard")
		tb.AddWidget(qt5.NewButtonWithText("ok"))
		w.AddToolBar(tb)

		tb.OnCloseEvent(func(e *qt5.CloseEvent) {
			fmt.Println("tb close", e)
		})
		sb := qt5.NewStatusBar()
		w.SetStatusBar(sb)
		sb.OnCloseEvent(func(e *qt5.CloseEvent) {
			fmt.Println("sb close", e)
		})

		btn.OnClicked(func() {
			dock.Hide()
			runtime.GC()
			btn.SetText(btn.Text())
		})
		dock.OnCloseEvent(func(e *qt5.CloseEvent) {
			fmt.Println(e)
		})

		go func() {
			for {
				timer := time.NewTimer(1)
				select {
				case <-timer.C:
					btn.SetText(btn.Text())
					btn.SetText(btn.Text())
					btn.SetText(btn.Text())
					fmt.Println(">", btn.Text())
					if btn.Text() != "HideDock" {
						panic("close")
					}
				}
			}
		}()

		dock.OnVisibilityChanged(func(b bool) {
			fmt.Println(b)
			if !b {
				time.AfterFunc(1e9, func() {
					if dock.IsValid() {
						dock.Show()
					}
				})
			}
		})

		w.Show()
	}()

	qt5.Run()
}