本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.VBox.Add方法的典型用法代码示例。如果您正苦于以下问题:Golang VBox.Add方法的具体用法?Golang VBox.Add怎么用?Golang VBox.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattn/go-gtk/gtk.VBox
的用法示例。
在下文中一共展示了VBox.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: configure_board
func configure_board(vbox *gtk.VBox) {
drawingarea = gtk.NewDrawingArea()
drawingarea.Connect("configure-event", func() {
if pixmap != nil {
pixmap.Unref()
}
var allocation gtk.Allocation
drawingarea.GetAllocation(&allocation)
pixmap = gdk.NewPixmap(drawingarea.GetWindow().GetDrawable(), allocation.Width, allocation.Height, 24)
gc = gdk.NewGC(pixmap.GetDrawable())
display_init_grid(gc, pixmap)
})
drawingarea.Connect("button-press-event", func(ctx *glib.CallbackContext) {
// Check if the game is running and if player click in the goban
if stopGame == true || stopClick == true {
return
}
if gdkwin == nil {
gdkwin = drawingarea.GetWindow()
}
arg := ctx.Args(0)
mev := *(**gdk.EventMotion)(unsafe.Pointer(&arg))
var mt gdk.ModifierType
var x, y int
if mev.IsHint != 0 {
gdkwin.GetPointer(&x, &y, &mt)
} else {
x, y = int(mev.X), int(mev.Y)
}
x = ((x - INTER/2) / INTER)
y = ((y - INTER/2) / INTER)
if x < 0 || x >= 19 || y < 0 || y >= 19 {
return
}
// end check
good, vic := event_play(x, y)
if good && iamode && stopGame == false && stopClick == false && vic == 0 {
calc_ai()
}
if good && !iamode && stopGame == false && stopClick == false && hint {
calcHint <- true
}
})
drawingarea.Connect("expose-event", func() {
if pixmap != nil {
drawingarea.GetWindow().GetDrawable().DrawDrawable(gc, pixmap.GetDrawable(), 0, 0, 0, 0, -1, -1)
}
})
drawingarea.SetEvents(int(gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.BUTTON_PRESS_MASK))
vbox.Add(drawingarea)
}
示例2: buildList
func (g *Gui) buildList(vbox *gtk.VBox) {
frame := gtk.NewFrame("Device List")
framebox := gtk.NewVBox(false, 1)
frame.Add(framebox)
vbox.Add(frame)
g.Status = gtk.NewStatusbar()
vbox.PackStart(g.Status, false, false, 0)
g.Store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING)
treeview := gtk.NewTreeView()
framebox.Add(treeview)
treeview.SetModel(g.Store)
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Device", gtk.NewCellRendererText(), "text", 0))
treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 1))
treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE)
controls := gtk.NewHBox(true, 0)
g.Start = gtk.NewButtonWithLabel("Start Sync")
g.Start.Clicked(func() {
var iter gtk.TreeIter
var device glib.GValue
selection := treeview.GetSelection()
if selection.CountSelectedRows() > 0 {
selection.GetSelected(&iter)
g.Store.GetValue(&iter, 0, &device)
MainGui.notify("Start Writing On: " + device.GetString())
doWrite(device.GetString())
} else {
MainGui.notify("No Active Selection")
}
})
controls.Add(g.Start)
g.Recheck = gtk.NewButtonWithLabel("Rescan")
g.Recheck.Clicked(func() {
devices := SearchValid()
MainGui.Store.Clear()
for _, x := range devices {
MainGui.appendItem("/dev/hidraw"+strconv.FormatUint(x.SeqNum(), 10), x.SysAttrValue("product"))
}
MainGui.notify("Scanning Done")
})
controls.Add(g.Recheck)
framebox.PackStart(controls, false, false, 0)
}