• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gtk.VBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.VBox的典型用法代码示例。如果您正苦于以下问题:Golang VBox类的具体用法?Golang VBox怎么用?Golang VBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VBox类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: CreateActivatableDemo

func CreateActivatableDemo(vbox *gtk.VBox) {
	action_entry := gtk.NewAction("ActionEntry",
		"Button attached to Action", "", gtk.STOCK_INFO)
	action_entry.Connect("activate", func() {
		fmt.Println("Action clicked")
	})
	frame1 := gtk.NewFrame("GtkActivatable interface demonstration")
	frame1.SetBorderWidth(5)
	hbox2 := gtk.NewHBox(false, 5)
	hbox2.SetSizeRequest(400, 50)
	hbox2.SetBorderWidth(5)
	button1 := gtk.NewButton()
	button1.SetSizeRequest(250, 0)
	button1.SetRelatedAction(action_entry)
	hbox2.PackStart(button1, false, false, 0)
	hbox2.PackStart(gtk.NewVSeparator(), false, false, 0)
	button2 := gtk.NewButtonWithLabel("Hide Action")
	button2.SetSizeRequest(150, 0)
	button2.Connect("clicked", func() {
		action_entry.SetVisible(false)
		fmt.Println("Hide Action")
	})
	hbox2.PackStart(button2, false, false, 0)
	button3 := gtk.NewButtonWithLabel("Unhide Action")
	button3.SetSizeRequest(150, 0)
	button3.Connect("clicked", func() {
		action_entry.SetVisible(true)
		fmt.Println("Show Action")
	})
	hbox2.PackStart(button3, false, false, 0)
	frame1.Add(hbox2)
	vbox.PackStart(frame1, false, true, 0)
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:33,代码来源:action.go


示例2: 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)
}
开发者ID:Khady,项目名称:gomoku,代码行数:55,代码来源:display.go


示例3: 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)
}
开发者ID:spaghetty,项目名称:gunnify,代码行数:42,代码来源:gunnify.go


示例4: CreateMenuAndToolbar

func CreateMenuAndToolbar(w *gtk.Window, vbox *gtk.VBox) {
	action_group := gtk.NewActionGroup("my_group")
	ui_manager := CreateUIManager()
	accel_group := ui_manager.GetAccelGroup()
	w.AddAccelGroup(accel_group)
	AddFileMenuActions(action_group)
	AddEditMenuActions(action_group)
	AddChoicesMenuActions(action_group)
	ui_manager.InsertActionGroup(action_group, 0)
	menubar := ui_manager.GetWidget("/MenuBar")
	vbox.PackStart(menubar, false, false, 0)
	toolbar := ui_manager.GetWidget("/ToolBar")
	vbox.PackStart(toolbar, false, false, 0)
	eventbox := gtk.NewEventBox()
	vbox.PackStart(eventbox, false, false, 0)
	//    label := gtk.NewLabel("Right-click to see the popup menu.")
	//    vbox.PackStart(label, false, false, 0)
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:18,代码来源:action.go


示例5: menu_bar

func menu_bar(vbox *gtk.VBox) {
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	buttons := gtk.NewAlignment(0, 0, 0, 0)
	checkbox := gtk.NewAlignment(1, 0, 0, 0)
	newPlayerGameButton := gtk.NewButtonWithLabel("Player vs Player")
	newIaGameButton := gtk.NewButtonWithLabel("Player vs AI")
	info = gtk.NewLabel("Hint: Not yet")
	threeCheckBox := gtk.NewCheckButtonWithLabel("Three and three")
	endCheckBox := gtk.NewCheckButtonWithLabel("Unbreakable end")
	hintCheckBox := gtk.NewCheckButtonWithLabel("Hint")
	hbox := gtk.NewHBox(false, 1)
	hbox0 := gtk.NewHBox(false, 1)
	hbox1 := gtk.NewHBox(false, 1)
	hbox0.Add(newPlayerGameButton)
	hbox0.Add(newIaGameButton)
	hbox1.Add(hintCheckBox)
	hbox1.Add(threeCheckBox)
	hbox1.Add(endCheckBox)
	buttons.Add(hbox0)
	checkbox.Add(hbox1)
	hbox.Add(buttons)
	hbox.Add(info)
	hbox.Add(checkbox)
	vbox.PackStart(hbox, false, true, 0)

	cascademenu := gtk.NewMenuItemWithMnemonic("_Game")
	menubar.Append(cascademenu)
	submenu := gtk.NewMenu()
	cascademenu.SetSubmenu(submenu)
	playermenuitem := gtk.NewMenuItemWithMnemonic("_Player Vs Player")
	playermenuitem.Connect("activate", func() {
		gc.SetRgbFgColor(gdk.NewColor("grey"))
		pixmap.GetDrawable().DrawRectangle(gc, true, 0, 0, -1, -1)
		game = Gomoku{make([]int, 361), true, game.endgameTake, game.doubleThree, 1, [2]int{10, 10}, 0}
		player = 1
		countTake = 0
		iamode = false
		display_init_grid(gc, pixmap)
		drawingarea.Hide()
		drawingarea.Show()
		stopGame = false
		stopClick = false
		context_id := statusbar.GetContextId("go-gtk")
		statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!")
	})
	submenu.Append(playermenuitem)
	newPlayerGameButton.Clicked(func() {
		playermenuitem.Activate()
	})
	iamenuitem := gtk.NewMenuItemWithMnemonic("_Player Vs AI")
	iamenuitem.Connect("activate", func() {
		gc.SetRgbFgColor(gdk.NewColor("grey"))
		pixmap.GetDrawable().DrawRectangle(gc, true, 0, 0, -1, -1)
		game = Gomoku{make([]int, 361), true, game.endgameTake, game.doubleThree, 1, [2]int{10, 10}, 0}
		player = 1
		countTake = 0
		iamode = true
		display_init_grid(gc, pixmap)
		drawingarea.Hide()
		drawingarea.Show()
		stopGame = false
		stopClick = false
		context_id := statusbar.GetContextId("go-gtk")
		statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!")
	})
	submenu.Append(iamenuitem)
	newIaGameButton.Clicked(func() {
		iamenuitem.Activate()
	})
	menuitem = gtk.NewMenuItemWithMnemonic("E_xit")
	menuitem.Connect("activate", func() {
		gtk.MainQuit()
	})
	submenu.Append(menuitem)

	threeCheckBox.Connect("toggled", func() {
		if game.doubleThree == false {
			game.doubleThree = true
		} else {
			game.doubleThree = false
		}
	})

	endCheckBox.Connect("toggled", func() {
		if game.endgameTake == false {
			game.endgameTake = true
		} else {
			game.endgameTake = false
		}
	})

	hintCheckBox.Connect("toggled", func() {
		if hint == false {
			hint = true
			calcHint <- true
		} else {
			hint = false
		}
//.........这里部分代码省略.........
开发者ID:Khady,项目名称:gomoku,代码行数:101,代码来源:display.go


示例6: status_bar

func status_bar(vbox *gtk.VBox) {
	statusbar = gtk.NewStatusbar()
	context_id := statusbar.GetContextId("go-gtk")
	statusbar.Push(context_id, "(not so) Proudly propulsed by the inglorious Gomoku Project, with love, and Golang!")
	vbox.PackStart(statusbar, false, false, 0)
}
开发者ID:Khady,项目名称:gomoku,代码行数:6,代码来源:display.go



注:本文中的github.com/mattn/go-gtk/gtk.VBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang oleutil.CallMethod函数代码示例发布时间:2022-05-23
下一篇:
Golang gtk.TextIter类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap