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

Golang gtk.NewHBox函数代码示例

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

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



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

示例1: accountWindow

func accountWindow() {
	// window settings
	window_account := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window_account.SetPosition(gtk.WIN_POS_CENTER)
	window_account.SetTitle("Add Account")

	// main container
	container_main := gtk.NewVBox(false, 10)
	container_user := gtk.NewHBox(false, 0)
	container_pass := gtk.NewHBox(false, 0)
	container_buttons := gtk.NewHBox(false, 5)
	container_main.SetBorderWidth(10)

	// username
	user_label := gtk.NewLabel("Username")
	user_entry := gtk.NewEntry()

	// password
	pass_label := gtk.NewLabel("Password")
	pass_entry := gtk.NewEntry()
	pass_entry.SetVisibility(false)

	// login and cancel buttons
	button_login := gtk.NewButtonWithLabel("Add")
	button_cancel := gtk.NewButtonWithLabel("Cancel")

	// login
	button_login.Clicked(func() {
		username := user_entry.GetText()
		password := pass_entry.GetText()
		profile, err := CreateProfile(username, password)
		if err == nil && profile != nil {
			println("[*] Login successful")
			window_account.Destroy()
		}
	})

	// cancel
	button_cancel.Clicked(func() {
		window_account.Destroy()
	})

	// add elements to containers
	container_buttons.Add(button_login)
	container_buttons.Add(button_cancel)
	container_user.PackStart(user_label, false, false, 20)
	container_user.PackEnd(user_entry, true, true, 1)
	container_pass.PackStart(pass_label, false, false, 20)
	container_pass.PackEnd(pass_entry, true, true, 1)
	container_main.PackStart(container_user, false, false, 1)
	container_main.PackStart(container_pass, false, false, 1)
	container_main.PackStart(container_buttons, false, false, 1)

	window_account.Add(container_main)
	window_account.SetSizeRequest(350, 150)
	window_account.SetResizable(false)
	window_account.ShowAll()
}
开发者ID:kisom,项目名称:socialgopher,代码行数:58,代码来源:app.go


示例2: init_Calc

// Frame - Calculation
// This frame contains radix(16,10,8) and result labels
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
func (this *UI) init_Calc() {
	// In this function, the designated frame is Calc_Frame
	_Frame := this.Calc_Frame
	if _Frame == nil {
		panic("UI::init_Calc() : nil Frame received")
	}

	// (inner) Box of Calculation
	fm_calc_box := gtk.NewHBox(false, 1)
	if fm_calc_box == nil {
		panic("UI::init_Calc() : HBox allocation Failed")
	}

	_Frame.Add(fm_calc_box)

	// Box for Radix Buttons.
	box_rdx := gtk.NewVBox(false, 1)
	if box_rdx == nil {
		panic("UI::init_Calc() : VBox allocation Failed")
	}

	btn_hex := button("Hex") // [Hex] : Hexadecimal
	btn_dec := button("Dec") // [Dec] : Decimal
	btn_oct := button("Oct") // [Oct] : Octal
	box_rdx.Add(btn_hex)
	box_rdx.Add(btn_dec)
	box_rdx.Add(btn_oct)

	// Insert radix buttons into the map
	this.Btn_map["Hex"] = btn_hex
	this.Btn_map["Dec"] = btn_dec
	this.Btn_map["Oct"] = btn_oct

	// Box for Result Labels
	box_labels := gtk.NewVBox(false, 1)
	if box_labels == nil {
		panic("UI::init_Calc() : VBox allocation Failed")
	}

	// Place previous result
	box_labels.Add(this.Lbl_prev)

	// Place left and right operand
	box_LnR := gtk.NewHBox(false, 3)
	if box_LnR == nil {
		panic("UI::init_Calc() : HBox allocation Failed")
	}
	box_LnR.Add(this.Lbl_lhs)
	box_LnR.Add(this.Lbl_rhs)
	box_labels.Add(box_LnR)

	// Add both Boxes (Radix & Result) to frame box
	fm_calc_box.Add(box_rdx)
	fm_calc_box.Add(box_labels)

	fmt.Println("UI::init_Calc() done.")
}
开发者ID:gophergala2016,项目名称:0x_Calc,代码行数:60,代码来源:layout.go


示例3: mkSidebar

func (g *GUI) mkSidebar() *gtk.ScrolledWindow {
	sbVBox := gtk.NewVBox(false, 0)

	sbVBox.PackStart(labelCustomFont("Tools", "Sans Bold 14"), false, false, 3)

	g.showbiomes = gtk.NewCheckButtonWithLabel("Show Biomes")
	g.showbiomes.SetActive(true)
	g.showbiomes.Connect("toggled", g.showbiomesToggled)
	sbVBox.PackStart(g.showbiomes, false, false, 3)

	g.fixSnowIce = gtk.NewCheckButtonWithLabel("Fix Snow/Ice")
	g.fixSnowIce.SetTooltipText("Add Snow/Ice for Taiga/Ice Plains. Remove Snow/Ice for other biomes.")
	g.fixSnowIce.Connect("toggled", g.fixSnowIceToggled)
	sbVBox.PackStart(g.fixSnowIce, false, false, 3)

	fill := gtk.NewRadioButtonWithLabel(nil, "Fill")
	fill.SetActive(true)
	fill.Connect("toggled", g.mkUpdateToolFx(fill, NewFillTool()))

	draw := gtk.NewRadioButtonWithLabel(fill.GetGroup(), "Draw")
	drawRadius := gtk.NewSpinButtonWithRange(1, 20, 1)
	drawHBox := gtk.NewHBox(false, 0)
	drawHBox.PackStart(draw, true, true, 0)
	drawHBox.PackStart(gtk.NewLabel("Radius:"), false, false, 3)
	drawHBox.PackEnd(drawRadius, false, false, 3)
	draw.Connect("toggled", g.mkUpdateToolFx(draw, NewDrawTool(func() int { return drawRadius.GetValueAsInt() })))

	sbVBox.PackStart(fill, false, false, 3)
	sbVBox.PackStart(drawHBox, false, false, 3)

	sbVBox.PackStart(gtk.NewHSeparator(), false, false, 3)
	bioHeaderHBox := gtk.NewHBox(false, 0)
	bioHeaderHBox.PackStart(labelCustomFont("Biomes", "Sans Bold 14"), true, false, 0)
	editBiomesBtn := gtk.NewButton()
	editBiomesBtn.Add(gtk.NewImageFromStock(gtk.STOCK_EDIT, gtk.ICON_SIZE_SMALL_TOOLBAR))
	editBiomesBtn.Connect("clicked", g.biomeEditor)
	editBiomesBtn.SetTooltipText("Configure Biomes")
	bioHeaderHBox.PackStart(editBiomesBtn, false, false, 0)
	sbVBox.PackStart(bioHeaderHBox, false, false, 3)

	g.bioVBoxWrap = gtk.NewVBox(false, 0)
	g.bioVBox = gtk.NewVBox(false, 0)
	g.bioVBoxWrap.PackStart(g.bioVBox, false, false, 0)
	sbVBox.PackStart(g.bioVBoxWrap, false, false, 3)
	g.updateBiomeInfo()

	scrolled := gtk.NewScrolledWindow(nil, nil)
	scrolled.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
	scrolled.AddWithViewPort(sbVBox)
	return scrolled
}
开发者ID:kch42,项目名称:biomed,代码行数:51,代码来源:main.go


示例4: main

func main() {
	gtk.Init(&os.Args)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("GTK Notebook")
	window.Connect("destroy", gtk.MainQuit)

	notebook := gtk.NewNotebook()
	for n := 1; n <= 10; n++ {
		page := gtk.NewFrame("demo" + strconv.Itoa(n))
		notebook.AppendPage(page, gtk.NewLabel("demo"+strconv.Itoa(n)))

		vbox := gtk.NewHBox(false, 1)

		prev := gtk.NewButtonWithLabel("go prev")
		prev.Clicked(func() {
			notebook.PrevPage()
		})
		vbox.Add(prev)

		next := gtk.NewButtonWithLabel("go next")
		next.Clicked(func() {
			notebook.NextPage()
		})
		vbox.Add(next)

		page.Add(vbox)
	}

	window.Add(notebook)
	window.SetSizeRequest(400, 200)
	window.ShowAll()

	gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:34,代码来源:notebook.go


示例5: Init

func (g *GUI) Init() {
	g.biomes = ReadDefaultBiomes()

	g.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	g.window.SetTitle("biomed")

	g.accel = gtk.NewAccelGroup()
	g.window.AddAccelGroup(g.accel)

	menubar := g.mkMenuBar()
	vbox := gtk.NewVBox(false, 0)
	vbox.PackStart(menubar, false, false, 0)

	hbox := gtk.NewHBox(false, 0)

	g.mapw = NewMapWidget(GUICallbacks{g.reportError, g.updateInfo, g.setBusy}, MkBiomeLookup(g.biomes))
	hbox.PackStart(g.mapw.DArea(), true, true, 3)

	sidebar := g.mkSidebar()
	hbox.PackEnd(sidebar, false, false, 3)

	vbox.PackStart(hbox, true, true, 0)

	g.statusbar = gtk.NewStatusbar()
	g.statusContext = g.statusbar.GetContextId("mapinfo")
	vbox.PackEnd(g.statusbar, false, false, 0)

	g.window.Add(vbox)
	g.window.SetDefaultSize(800, 600)

	g.window.Connect("destroy", g.exitApp)

	g.setTool(NewFillTool())
}
开发者ID:kch42,项目名称:biomed,代码行数:34,代码来源:main.go


示例6: CreateGuiController

func CreateGuiController() *GuiController {
	guiController := &GuiController{}
	guiController.buttons = make([]*gtk.Button, 0)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GTK Go!")
	window.SetIconName("gtk-dialog-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		fmt.Println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "foo")

	buttonsBox := gtk.NewHBox(false, 1)

	black := gdk.NewColorRGB(0, 0, 0)

	for i := 0; i < 8; i++ {
		button := gtk.NewButtonWithLabel(fmt.Sprint(i))

		button.ModifyBG(gtk.STATE_NORMAL, black)
		guiController.buttons = append(guiController.buttons, button)
		buttonsBox.Add(button)
	}

	window.Add(buttonsBox)
	window.SetSizeRequest(600, 600)
	window.ShowAll()

	return guiController
}
开发者ID:uvgroovy,项目名称:dmx,代码行数:30,代码来源:dmxd.go


示例7: main

func main() {
	gtk.Init(&os.Args)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Arrow Buttons")
	window.Connect("destroy", gtk.MainQuit)

	box := gtk.NewHBox(false, 0)
	box.Show()
	window.Add(box)

	up := createArrowButton(gtk.ARROW_UP, gtk.SHADOW_IN)
	down := createArrowButton(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
	left := createArrowButton(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
	right := createArrowButton(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)

	box.PackStart(up, false, false, 3)
	box.PackStart(down, false, false, 3)
	box.PackStart(left, false, false, 3)
	box.PackStart(right, false, false, 3)

	up.Clicked(func() { println("↑") })
	down.Clicked(func() { println("↓") })
	left.Clicked(func() { println("←") })
	right.Clicked(func() { println("→") })

	window.Show()
	gtk.Main()
}
开发者ID:mattn,项目名称:go-gtk,代码行数:29,代码来源:arrow.go


示例8: 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


示例9: newBiomeList

func newBiomeList() *biomeList {
	bl := &biomeList{
		HBox:     gtk.NewHBox(false, 0),
		treeview: gtk.NewTreeView(),
		lStore:   gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING),
		addBtn:   gtk.NewButton(),
		delBtn:   gtk.NewButton(),
		upBtn:    gtk.NewButton(),
		downBtn:  gtk.NewButton(),
	}

	scroll := gtk.NewScrolledWindow(nil, nil)
	scroll.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
	scroll.Add(bl.treeview)
	bl.PackStart(scroll, true, true, 3)

	bl.treeview.SetModel(bl.lStore)
	bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Color", gtk.NewCellRendererText(), "background", 0))
	bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("ID", gtk.NewCellRendererText(), "text", 1))
	bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Snowline", gtk.NewCellRendererText(), "text", 2))
	bl.treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Name", gtk.NewCellRendererText(), "text", 3))

	bl.treeview.GetSelection().SetMode(gtk.SELECTION_SINGLE)
	bl.treeview.Connect("cursor-changed", bl.onCursorChanged)

	vbox := gtk.NewVBox(false, 0)

	bl.addBtn.Add(gtk.NewImageFromStock(gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR))
	bl.delBtn.Add(gtk.NewImageFromStock(gtk.STOCK_DELETE, gtk.ICON_SIZE_SMALL_TOOLBAR))
	bl.upBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_SMALL_TOOLBAR))
	bl.downBtn.Add(gtk.NewImageFromStock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_SMALL_TOOLBAR))

	bl.addBtn.Connect("clicked", bl.onAdd)
	bl.delBtn.Connect("clicked", bl.onDel)
	bl.upBtn.Connect("clicked", bl.onUp)
	bl.downBtn.Connect("clicked", bl.onDown)

	bl.delBtn.SetSensitive(false)
	bl.upBtn.SetSensitive(false)
	bl.downBtn.SetSensitive(false)

	vbox.PackStart(bl.addBtn, false, false, 3)
	vbox.PackStart(bl.delBtn, false, false, 3)
	vbox.PackStart(bl.upBtn, false, false, 3)
	vbox.PackStart(bl.downBtn, false, false, 3)

	bl.PackStart(vbox, false, false, 0)

	return bl
}
开发者ID:kch42,项目名称:biomed,代码行数:50,代码来源:biome_info_editor.go


示例10: 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


示例11: newBiomeEditFrame

func newBiomeEditFrame() *biomeEditFrame {
	frm := &biomeEditFrame{
		Frame:         gtk.NewFrame("Edit Biome"),
		applyBtn:      gtk.NewButtonWithLabel("Apply"),
		idInput:       gtk.NewEntry(),
		snowLineInput: gtk.NewEntry(),
		nameInput:     gtk.NewEntry(),
		colorInput:    gtk.NewColorButton(),
	}

	frm.idInput.SetSizeRequest(40, -1)
	frm.snowLineInput.SetSizeRequest(40, -1)

	frm.idInput.Connect("changed", frm.unlockApply)
	frm.nameInput.Connect("changed", frm.unlockApply)
	frm.snowLineInput.Connect("changed", frm.unlockApply)
	frm.applyBtn.SetSensitive(false)

	vbox := gtk.NewVBox(false, 0)
	hbox := gtk.NewHBox(false, 0)

	frm.idInput.SetTooltipText("The data value of the Biome [0-255]")
	frm.snowLineInput.SetTooltipText(fmt.Sprintf("Height (Y coordinate) at which snowfall starts (-1 or %d for no snowfall, 0 for always snowy)", mcmap.ChunkSizeY))

	hbox.PackStart(gtk.NewLabel("Color:"), false, false, 0)
	hbox.PackStart(frm.colorInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("ID:"), false, false, 0)
	hbox.PackStart(frm.idInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("Snowline:"), false, false, 0)
	hbox.PackStart(frm.snowLineInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("Name:"), false, false, 0)
	hbox.PackStart(frm.nameInput, true, true, 3)

	vbox.PackStart(hbox, false, false, 0)
	vbox.PackStart(frm.applyBtn, false, false, 3)
	frm.Add(vbox)

	frm.applyBtn.Connect("clicked", frm.doApply)

	return frm
}
开发者ID:kch42,项目名称:biomed,代码行数:41,代码来源:biome_info_editor.go


示例12: updateBiomeInfo

func (g *GUI) updateBiomeInfo() {
	vbox := gtk.NewVBox(false, 0)
	var grp *glib.SList

	for _, biome := range g.biomes {
		biohbox := gtk.NewHBox(false, 0)
		cbox := colorBox(gdk.NewColor(biome.Color))
		cbox.SetSizeRequest(20, 20)
		biohbox.PackStart(cbox, false, false, 3)
		rbutton := gtk.NewRadioButtonWithLabel(grp, biome.Name)
		grp = rbutton.GetGroup()
		rbutton.Connect("toggled", g.mkUpdateBiomeFx(rbutton, biome.ID))
		biohbox.PackEnd(rbutton, true, true, 3)
		vbox.PackStart(biohbox, false, false, 3)
	}

	g.bioVBoxWrap.Remove(g.bioVBox)
	g.bioVBoxWrap.PackStart(vbox, false, false, 3)
	vbox.ShowAll()
	g.bioVBox = vbox

	g.mapw.updateBioLookup(MkBiomeLookup(g.biomes))
}
开发者ID:kch42,项目名称:biomed,代码行数:23,代码来源:main.go


示例13: NewBiomeInfoEditor

func NewBiomeInfoEditor(biomes []BiomeInfo) *BiomeInfoEditor {
	ed := &BiomeInfoEditor{
		Dialog:  gtk.NewDialog(),
		biolist: newBiomeList(),
	}

	ed.SetModal(true)

	vbox := ed.GetVBox()

	btnHBox := gtk.NewHBox(true, 0)

	resetBtn := gtk.NewButtonWithLabel("Reset to defaults")
	resetBtn.Connect("clicked", ed.reset)
	loadBtn := gtk.NewButtonWithLabel("Load from file ...")
	loadBtn.Connect("clicked", ed.load)
	saveBtn := gtk.NewButtonWithLabel("Save to file ...")
	saveBtn.Connect("clicked", ed.save)

	btnHBox.PackStart(resetBtn, true, true, 3)
	btnHBox.PackStart(loadBtn, true, true, 3)
	btnHBox.PackStart(saveBtn, true, true, 3)
	vbox.PackStart(btnHBox, false, false, 3)

	ed.biolist.SetBiomes(biomes)
	vbox.PackStart(ed.biolist, true, true, 3)

	editFrame := newBiomeEditFrame()
	connectBiomeListEditFrame(ed.biolist, editFrame)
	vbox.PackStart(editFrame, false, false, 3)

	ed.AddButton("Cancel", gtk.RESPONSE_CANCEL)
	ed.AddButton("OK", gtk.RESPONSE_OK)
	ed.ShowAll()
	return ed
}
开发者ID:kch42,项目名称:biomed,代码行数:36,代码来源:biome_info_editor.go


示例14: main

func main() {
	runtime.LockOSThread()
	gtk.Init(&os.Args)
	gdk.ThreadsInit()

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("DMS GUI")
	window.Connect("destroy", gtk.MainQuit)

	vbox := gtk.NewVBox(false, 0)
	window.Add(vbox)

	hbox := gtk.NewHBox(false, 0)
	vbox.PackStart(hbox, false, true, 0)

	hbox.PackStart(gtk.NewLabel("Shared directory: "), false, true, 0)

	dialog := gtk.NewFileChooserDialog(
		"Select directory to share", window, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
		gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
		gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)

	button := gtk.NewFileChooserButtonWithDialog(dialog)
	hbox.Add(button)

	logView := gtk.NewTextView()
	logView.SetEditable(false)
	logView.ModifyFontEasy("monospace")
	logView.SetWrapMode(gtk.WRAP_WORD_CHAR)
	logViewScroller := gtk.NewScrolledWindow(nil, nil)
	logViewScroller.Add(logView)
	logViewScroller.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
	vbox.PackEnd(logViewScroller, true, true, 0)

	getPath := func() string {
		return button.GetFilename()
	}

	window.ShowAll()
	if dialog.Run() != gtk.RESPONSE_ACCEPT {
		return
	}
	go func() {
		dmsServer := dms.Server{
			RootObjectPath: getPath(),
		}
		if err := dmsServer.Serve(); err != nil {
			log.Fatalln(err)
		}
		defer dmsServer.Close()
		runtime.LockOSThread()
		gdk.ThreadsEnter()
		button.Connect("selection-changed", func() {
			dmsServer.RootObjectPath = getPath()
		})
		gdk.ThreadsLeave()
		runtime.UnlockOSThread()
		dmsServer.Serve()
	}()
	gtk.Main()
	runtime.UnlockOSThread()
}
开发者ID:ronindev,项目名称:dms,代码行数:62,代码来源:main.go


示例15: win_start

func win_start() {
	defer catch() // Panic Handler
	// Initiate GTK
	gtk.Init(&os.Args)

	// Window Setup
	// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

	// Create the Main Window
	// Set title & size
	win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	win.SetTitle("0x_Calc")

	// on Exit -> Quit the program
	win.Connect("destroy", gtk.MainQuit)

	box_win := gtk.NewVBox(Homogeneous, Default_Spacing)

	// Menu Bar
	// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

	/*
			// Vertical Box for menu
			box_menu := gtk.NewVBox(false, 1)
			// MenuBar - menu
			mb_menu := gtk.NewMenuBar()
			box_menu.PackStart(mb_menu, false, false, 0)

			// Menu Items

			// [File]
			mi_file := gtk.NewMenuItemWithMnemonic("_File2")
			mb_menu.Append(mi_file)
			// Submenu for [File]
			subm_file := gtk.NewMenu()
			mi_file.SetSubmenu(subm_file)

			mi_exit := gtk.NewMenuItemWithMnemonic("_Exit2")
			mb_menu.Append(mi_exit)

			mi_exit.Connect("activate", func() {
				gtk.MainQuit()
			})

		// Add the menubox
		win.Add(box_menu)
	*/

	// Frame - Calculation
	// This frame contains radix(16,10,8) and result labels
	// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
	fm_calc := gtk.NewFrame("Calculation")
	// (inner) Box of Calculation
	fm_calc_box := gtk.NewHBox(false, 1)
	fm_calc.Add(fm_calc_box)

	// Box for Radix Buttons.
	box_rdx := gtk.NewVBox(false, 1)
	btn_hex := button("Hex")                 // [Hex] : Hexadecimal
	btn_dec := gtk.NewButtonWithLabel("Dec") // [Dec] : Decimal
	btn_oct := gtk.NewButtonWithLabel("Oct") // [Oct] : Octal
	box_rdx.Add(btn_hex)
	box_rdx.Add(btn_dec)
	box_rdx.Add(btn_oct)

	// Box for Result Labels
	box_labels := gtk.NewVBox(false, 1)
	lbl_prev := gtk.NewLabel("Previous Result") // Previous Calculation
	lbl_late := gtk.NewLabel("Current Result")  // Latest Calculaltion
	box_labels.Add(lbl_prev)
	box_labels.Add(lbl_late)

	// Add both Boxes (Radix & Result) to frame box
	fm_calc_box.Add(box_rdx)
	fm_calc_box.Add(box_labels)

	// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

	// Frame - Numbers
	// This frame contains number buttons for calculation
	//  	Hexadecimal	: 0 ~ 9, A ~ F
	//  	Decimal   	: 0 ~ 9
	//  	Octal     	: 0 ~ 7
	// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====
	fm_nums := gtk.NewFrame("Numbers")
	// (inner) Box of Numbers
	fm_nums_box := gtk.NewVBox(false, 1)
	fm_nums.Add(fm_nums_box)

	// Table Initialization
	// ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
	tbl_nums := gtk.NewTable(5, 4, false)

	// Jagged slice of buttons
	// nums := [][]*gtk.Button{}

	// Button for Number
	num := [17]*gtk.Button{
		// 0~7 : Oct
		button("0"), button("1"), button("2"), button("3"),
//.........这里部分代码省略.........
开发者ID:KarasYa7a,项目名称:0x_Calc,代码行数:101,代码来源:layout.go


示例16: main

func main() {
	gtk.Init(nil)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GoMADScan")
	window.SetIconName("GoMADScan-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		// fmt.Println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "")

	//--------------------------------------------------------
	// GtkVBox
	//--------------------------------------------------------
	vbox := gtk.NewVBox(false, 1)

	//--------------------------------------------------------
	// GtkMenuBar
	//--------------------------------------------------------
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	//--------------------------------------------------------
	// GtkVPaned
	//--------------------------------------------------------
	vpaned := gtk.NewVPaned()
	vbox.Add(vpaned)

	//--------------------------------------------------------
	// GtkFrame
	//--------------------------------------------------------
	frame1 := gtk.NewFrame("")
	framebox1 := gtk.NewVBox(false, 1)
	frame1.Add(framebox1)

	frame2 := gtk.NewFrame("Column index for search (0: all columns)")
	framebox2 := gtk.NewVBox(false, 1)
	frame2.Add(framebox2)

	vpaned.Pack1(frame1, false, false)
	vpaned.Pack2(frame2, false, false)

	//--------------------------------------------------------
	// GtkImage
	//--------------------------------------------------------
	dir := os.Getenv("GOPATH")
	if dir == "" {
		dir = filepath.Join(os.Getenv("HOME"), "/go")
	}
	imagefile := filepath.Join(dir, "/src/github.com/carushi/GoMADScan/image/logo.png")
	label := gtk.NewLabel("Go-based Modification associated database scanner")
	label.ModifyFontEasy("DejaVu Serif 15")
	framebox1.PackStart(label, false, true, 0)
	image := gtk.NewImageFromFile(imagefile)
	framebox1.Add(image)

	//--------------------------------------------------------
	// Data input and output filename
	//--------------------------------------------------------
	arg := arguments{
		0,
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/Sample_modification_site"),
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/Ras_gene_synonym.txt"),
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/output.txt"),
		false,
		true,
		"\t"}

	//--------------------------------------------------------
	// GtkScale
	//--------------------------------------------------------
	scale := gtk.NewHScaleWithRange(0, 20, 1)
	scale.Connect("value-changed", func() {
		arg.column = int(scale.GetValue())
		// fmt.Println("scale:", int(scale.GetValue()))
	})
	framebox2.Add(scale)

	//--------------------------------------------------------
	// InputArea
	//--------------------------------------------------------
	ientry := gtk.NewEntry()
	ientry.SetText(arg.inputPath)
	inputs := gtk.NewHBox(false, 1)
	button := gtk.NewButtonWithLabel("Choose input file")
	button.Clicked(func() {
		//--------------------------------------------------------
		// GtkFileChooserDialog
		//--------------------------------------------------------
		filechooserdialog := gtk.NewFileChooserDialog(
			"Choose File...",
			button.GetTopLevelAsWindow(),
			gtk.FILE_CHOOSER_ACTION_OPEN,
			gtk.STOCK_OK,
			gtk.RESPONSE_ACCEPT)
		filter := gtk.NewFileFilter()
		filter.AddPattern("*")
		filechooserdialog.AddFilter(filter)
		filechooserdialog.Response(func() {
//.........这里部分代码省略.........
开发者ID:carushi,项目名称:GoMADScan,代码行数:101,代码来源:GoMADScan.go


示例17: main

func main() {
	var autoupdating bool = false
	var autoticker *time.Ticker
	var entries [][]*gtk.Entry = make([][]*gtk.Entry, entitylimit)
	for i := 0; i < entitylimit; i++ {
		entries[i] = make([]*gtk.Entry, entityfields)
	}
	var entities []*physics.Entity = initentities(entries)

	// Initialize gtk
	gtk.Init(nil)

	// WINDOW
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("Gravity Visualization")

	// Connect top window closing to gtk main loop closing
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		gtk.MainQuit()
	})

	// TOP VERTICAL BOX
	topvbox := gtk.NewVBox(false, 1)

	// NOTEBOOK FOR TABS
	notebook := gtk.NewNotebook()

	// DRAWING AREA VERTICAL BOX
	davbox := gtk.NewVBox(false, 1)

	// DRAWING AREA
	drawingarea = gtk.NewDrawingArea()
	drawingarea.SetSizeRequest(width, height)
	drawingarea.ModifyBG(gtk.STATE_NORMAL, gdk.NewColor("white"))
	drawingarea.Connect("expose_event", func() {
		drawentities(entities)
	})
	davbox.PackStart(drawingarea, true, true, 0)

	// TICK SPEED SLIDER
	ticksliderhbox := gtk.NewHBox(false, 1)

	ticksliderlabel := gtk.NewLabel("Time between ticks (ms)")
	ticksliderhbox.Add(ticksliderlabel)

	tickslider := gtk.NewHScaleWithRange(1, 1000, 100)
	// Default value of 10 ms
	tickslider.SetValue(10)
	ticksliderhbox.Add(tickslider)
	davbox.Add(ticksliderhbox)

	// BUTTONS
	buttons := gtk.NewHBox(false, 1)

	// RESET MENU ITEM
	resetbutton := gtk.NewButtonWithLabel("Reset")
	resetbutton.Clicked(func() {
		entities = initentities(entries)
		drawingarea.QueueDraw()
	})
	buttons.Add(resetbutton)

	// TICK MENU ITEM
	tickbutton := gtk.NewButtonWithLabel("Tick")
	tickbutton.Clicked(func() {
		updateentities(entities)
	})
	buttons.Add(tickbutton)

	// AUTOUPDATE MENU ITEM
	autotickbutton := gtk.NewToggleButtonWithLabel("AutoUpdate")
	autotickbutton.Clicked(func() {
		// Stop the previous ticker if it exists
		if autoticker != nil {
			autoticker.Stop()
		}

		if autoupdating {
			// Toggle autoupdating state
			autoupdating = false
		} else {
			// Start the ticker
			autoticker = time.NewTicker(time.Duration(tickslider.GetValue()) * time.Millisecond)

			// Spawn a goroutine that will run update entities every tick
			go func() {
				for _ = range autoticker.C {
					updateentities(entities)
				}
			}()

			// Toggle autoupdating state
			autoupdating = true
		}
	})
	buttons.Add(autotickbutton)
	davbox.Add(buttons)

	notebook.AppendPage(davbox, gtk.NewLabel("Simulation"))
//.........这里部分代码省略.........
开发者ID:tkajder,项目名称:gtk-gravitysimulation,代码行数:101,代码来源:app.go


示例18: main

func main() {
	gtk.Init(&os.Args)
	display = gtk.NewEntry()
	display.SetAlignment(1.0)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Simple Go Calculator")
	window.Connect("destroy", Quit)

	// Vertical box containing all components
	vbox := gtk.NewVBox(false, 1)

	// Menu bar
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	// Add calculator display to vertical box
	display.SetCanFocus(false) // disable focus on calcuator display
	vbox.Add(display)

	// Menu items
	filemenu := gtk.NewMenuItemWithMnemonic("_File")
	menubar.Append(filemenu)
	filesubmenu := gtk.NewMenu()
	filemenu.SetSubmenu(filesubmenu)

	aboutmenuitem := gtk.NewMenuItemWithMnemonic("_About")
	aboutmenuitem.Connect("activate", func() {
		messagedialog := gtk.NewMessageDialog(
			window.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			"Simple Go Calculator")
		messagedialog.Response(func() {})
		messagedialog.Run()
		messagedialog.Destroy()
	},
		nil)
	filesubmenu.Append(aboutmenuitem)

	resetmenuitem := gtk.NewMenuItemWithMnemonic("_Reset")
	resetmenuitem.Connect("activate", func() { Reset(); display.SetText("0") })
	filesubmenu.Append(resetmenuitem)

	exitmenuitem := gtk.NewMenuItemWithMnemonic("E_xit")
	exitmenuitem.Connect("activate", Quit)
	filesubmenu.Append(exitmenuitem)

	// Vertical box containing all buttons
	buttons := gtk.NewVBox(false, 5)

	bmap := map[string]*gtk.Button{}

	for i := 0; i < 4; i++ {
		hbox := gtk.NewHBox(false, 5) // a horizontal box for each 4 buttons
		for j := 0; j < 4; j++ {
			b := gtk.NewButtonWithLabel(string(nums[i*4+j]))
			b.Clicked(Input(b)) //add click event
			hbox.Add(b)
			bmap[string(nums[i*4+j])] = b
		}
		buttons.Add(hbox) // add horizonatal box to vertical buttons' box
	}

	vbox.Add(buttons)

	window.Connect("key-press-event", func(ctx *glib.CallbackContext) bool {
		arg := ctx.Args(0)
		kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))
		c := (string(uint8(kev.Keyval % 0xff)))
		if kev.Keyval == gdk.KEY_Return {
			c = "="
			return true
		}
		if b, ok := bmap[c]; ok {
			Input(b)()
			b.GrabFocus()
		} else if kev.Keyval == gdk.KEY_Delete {
			Reset()
			display.SetText("0")
			return true
		}
		return false
	})

	window.Add(vbox)
	window.SetSizeRequest(250, 250)
	window.ShowAll()
	gtk.Main()
}
开发者ID:mattn,项目名称:gocalc,代码行数:90,代码来源:gui.go


示例19: main

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GTK Go!")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		gtk.MainQuit()
	}, "")

	vbox := gtk.NewVBox(false, 0)

	toolbar := gtk.NewToolbar()
	toolbar.SetStyle(gtk.TOOLBAR_ICONS)
	vbox.PackStart(toolbar, false, false, 5)

	btnnew := gtk.NewToolButtonFromStock(gtk.STOCK_NEW)
	btnclose := gtk.NewToolButtonFromStock(gtk.STOCK_CLOSE)
	separator := gtk.NewSeparatorToolItem()
	btncustom := gtk.NewToolButton(nil, "Custom")
	btnmenu := gtk.NewMenuToolButtonFromStock("gtk.STOCK_CLOSE")
	btnmenu.SetArrowTooltipText("This is a tool tip")

	btnnew.OnClicked(onToolButtonClicked)
	btnclose.OnClicked(onToolButtonClicked)
	btncustom.OnClicked(onToolButtonClicked)

	toolmenu := gtk.NewMenu()
	menuitem := gtk.NewMenuItemWithMnemonic("8")
	menuitem.Show()
	toolmenu.Append(menuitem)
	menuitem = gtk.NewMenuItemWithMnemonic("16")
	menuitem.Show()
	toolmenu.Append(menuitem)
	menuitem = gtk.NewMenuItemWithMnemonic("32")
	menuitem.Show()
	toolmenu.Append(menuitem)
	btnmenu.SetMenu(toolmenu)

	toolbar.Insert(btnnew, -1)
	toolbar.Insert(btnclose, -1)
	toolbar.Insert(separator, -1)
	toolbar.Insert(btncustom, -1)
	toolbar.Insert(btnmenu, -1)

	hbox := gtk.NewHBox(false, 0)
	vbox.PackStart(hbox, true, true, 0)

	toolbar2 := gtk.NewToolbar()
	toolbar2.SetOrientation(gtk.ORIENTATION_VERTICAL)
	hbox.PackStart(toolbar2, false, false, 5)
	btnhelp := gtk.NewToolButtonFromStock(gtk.STOCK_HELP)
	btnhelp.OnClicked(onToolButtonClicked)
	toolbar2.Insert(btnhelp, -1)

	btntoggle := gtk.NewToggleToolButton()
	btntoggle2 := gtk.NewToggleToolButtonFromStock(gtk.STOCK_ITALIC)
	toolbar2.Insert(btntoggle, -1)
	toolbar2.Insert(btntoggle2, -1)

	for i := 0; i < toolbar.GetNItems(); i++ {
		gti := toolbar.GetNthItem(i)
		switch gti.(type) {
		case *gtk.ToolButton:
			fmt.Printf("toolbar[%d] is a *gtk.ToolButton\n", i)
			w := gti.(*gtk.ToolButton).GetIconWidget()
			gti.(*gtk.ToolButton).SetIconWidget(w)
		case *gtk.ToggleToolButton:
			fmt.Printf("toolbar[%d] is a *gtk.ToggleToolButton\n", i)
			gti.(*gtk.ToggleToolButton).SetActive(true)
		case *gtk.SeparatorToolItem:
			fmt.Printf("toolbar[%d] is a *gtk.SeparatorToolItem\n", i)
		default:
			fmt.Printf("toolbar: Item is of unknown type\n")
		}
	}

	for i := 0; i < toolbar2.GetNItems(); i++ {
		gti := toolbar2.GetNthItem(i)
		switch gti.(type) {
		case *gtk.ToolButton:
			fmt.Printf("toolbar2[%d] is a *gtk.ToolButton\n", i)
		case *gtk.ToggleToolButton:
			fmt.Printf("toolbar2[%d] is a *gtk.ToggleToolButton\n", i)
			gti.(*gtk.ToggleToolButton).SetActive(true)
		case *gtk.SeparatorToolItem:
			fmt.Printf("toolbar2[%d] is a *gtk.SeparatorToolItem\n", i)
		default:
			fmt.Printf("toolbar2: Item is of unknown type\n")
		}
	}

	window.Add(vbox)
	window.SetSizeRequest(600, 600)
	window.ShowAll()
	gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:96,代码来源:toolbar.go


示例20: main

func main() {
	gtk.Init(&os.Args)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("GoTalk")
	window.Connect("destroy", func() {
		gtk.MainQuit()
	})
	vbox := gtk.NewVBox(false, 1)
	scrolledwin := gtk.NewScrolledWindow(nil, nil)
	textview := gtk.NewTextView()
	textview.SetEditable(false)
	textview.SetCursorVisible(false)
	scrolledwin.Add(textview)
	vbox.Add(scrolledwin)

	buffer := textview.GetBuffer()

	entry := gtk.NewEntry()
	vbox.PackEnd(entry, false, false, 0)

	window.Add(vbox)
	window.SetSizeRequest(300, 400)
	window.ShowAll()

	dialog := gtk.NewDialog()
	dialog.SetTitle(window.GetTitle())
	sgroup := gtk.NewSizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

	hbox := gtk.NewHBox(false, 1)
	dialog.GetVBox().Add(hbox)
	label := gtk.NewLabel("username:")
	sgroup.AddWidget(label)
	hbox.Add(label)
	username := gtk.NewEntry()
	hbox.Add(username)

	hbox = gtk.NewHBox(false, 1)
	dialog.GetVBox().Add(hbox)
	label = gtk.NewLabel("password:")
	sgroup.AddWidget(label)
	hbox.Add(label)
	password := gtk.NewEntry()
	password.SetVisibility(false)
	hbox.Add(password)

	dialog.AddButton(gtk.STOCK_OK, gtk.RESPONSE_OK)
	dialog.AddButton(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
	dialog.SetDefaultResponse(int(gtk.RESPONSE_OK))
	dialog.SetTransientFor(window)
	dialog.ShowAll()
	res := dialog.Run()
	username_ := username.GetText()
	password_ := password.GetText()
	dialog.Destroy()
	if res != gtk.RESPONSE_OK {
		os.Exit(0)
	}

	talk, err := xmpp.NewClient("talk.google.com:443", username_, password_)
	if err != nil {
		log.Fatal(err)
	}

	entry.Connect("activate", func() {
		text := entry.GetText()
		tokens := strings.SplitN(text, " ", 2)
		if len(tokens) == 2 {
			func() {
				defer recover()
				talk.Send(xmpp.Chat{Remote: tokens[0], Type: "chat", Text: tokens[1]})
				entry.SetText("")
			}()
		}
	})

	go func() {
		for {
			func() {
				defer recover()
				chat, err := talk.Recv()
				if err != nil {
					log.Fatal(err)
				}

				var iter gtk.TextIter
				buffer.GetStartIter(&iter)
				if msg, ok := chat.(xmpp.Chat); ok {
					buffer.Insert(&iter, msg.Remote+": "+msg.Text+"\n")
				}
			}()
		}
	}()

	gtk.Main()
}
开发者ID:AudioAddict,项目名称:go-xmpp,代码行数:96,代码来源:example-gui.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gtk.NewLabel函数代码示例发布时间:2022-05-23
下一篇:
Golang gtk.NewEntry函数代码示例发布时间: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