本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.NewVBox函数的典型用法代码示例。如果您正苦于以下问题:Golang NewVBox函数的具体用法?Golang NewVBox怎么用?Golang NewVBox使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewVBox函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: initPage
func initPage(title string, uri string, size_x int, size_y int) {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle(title)
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
webview := webkit.NewWebView()
webview.LoadUri(uri)
swin.Add(webview)
vbox.Add(swin)
window.Add(vbox)
window.SetSizeRequest(size_x, size_y)
window.ShowAll()
proxy := os.Getenv("HTTP_PROXY")
if len(proxy) > 0 {
soup_uri := webkit.SoupUri(proxy)
webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
soup_uri.Free()
}
gtk.Main()
}
示例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.")
}
示例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
}
示例4: 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())
}
示例5: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Clock")
vbox := gtk.NewVBox(false, 1)
label := gtk.NewLabel("")
vbox.Add(label)
window.Add(vbox)
window.SetDefaultSize(300, 20)
window.ShowAll()
timer, _ := uv.TimerInit(nil)
timer.Start(func(h *uv.Handle, status int) {
label.SetLabel(fmt.Sprintf("%v", time.Now()))
}, 1000, 1000)
idle, _ := uv.IdleInit(nil)
idle.Start(func(h *uv.Handle, status int) {
gtk.MainIterationDo(false)
})
window.Connect("destroy", func() {
timer.Close(nil)
idle.Close(nil)
})
uv.DefaultLoop().Run()
}
示例6: NewBrowser
// NewBrowser returns a new browser component
func NewBrowser(uri string) *Browser {
vbox := gtk.NewVBox(false, 1)
urlBarEntry := gtk.NewEntry()
urlBarEntry.SetText(uri)
urlBarEntry.GrabFocus()
vbox.PackStart(urlBarEntry, false, false, 0)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
webview := webkit.NewWebView()
swin.Add(webview)
vbox.Add(swin)
// urlBarEntry.Connect("activate", func() {
// webview.LoadUri(urlBarEntry.GetText())
// })
//return vbox
browser := &Browser{
VBox: vbox,
WebView: webview,
URLEntry: urlBarEntry,
Link: "",
}
browser.connectSignals()
urlBarEntry.Emit("activate")
return browser
}
示例7: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Hello GTK+Go world!")
window.SetIconName("gtk-dialog-info")
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, "foo")
vbox := gtk.NewVBox(false, 1)
button := gtk.NewButtonWithLabel("Hello world!")
button.SetTooltipMarkup("Say Hello World to everybody!")
button.Clicked(func() {
messagedialog := gtk.NewMessageDialog(
button.GetTopLevelAsWindow(),
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
"Hello!")
messagedialog.Response(func() {
messagedialog.Destroy()
})
messagedialog.Run()
})
vbox.PackStart(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(300, 50)
window.ShowAll()
gtk.Main()
}
示例8: put_frames
// Locate frames on the window
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
func (this *UI) put_frames() {
box_win := gtk.NewVBox(Homogeneous, Default_Spacing)
if box_win == nil {
panic("UI::put_frames() : VBox allocation Failed")
}
vpan1 := gtk.NewVPaned()
if vpan1 == nil {
panic("UI::put_frames() : VPaned allocation failed")
}
vpan1.Pack1(this.Calc_Frame, No_Resize, No_Shrink) // Calc : Top half
hpan1 := gtk.NewHPaned()
if hpan1 == nil {
panic("UI::put_frames() : HPaned allocation failed")
}
hpan1.Pack1(this.Nums_Frame, No_Resize, No_Shrink) // Nums : Bottom-Left
hpan1.Pack2(this.Oper_Frame, No_Resize, No_Shrink) // Oper : Bottom-Right
vpan1.Pack2(hpan1, No_Resize, No_Shrink)
box_win.Add(vpan1)
if this.Win == nil {
panic("UI::put_frames() : nil Window received")
}
// Place all Layout
this.Win.Add(box_win)
fmt.Println("UI::put_frames() done.")
}
示例9: board_display
func board_display() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("Gomoku")
window.SetResizable(false)
window.Connect("destroy", gtk.MainQuit)
player = 1
game = Gomoku{make([]int, 361), true, false, false, 1, [2]int{10, 10}, 0}
vbox := gtk.NewVBox(false, 1)
menu_bar(vbox)
configure_board(vbox)
status_bar(vbox)
hintx, hinty, lastx, lasty = -1, -1, -1, -1
go calc_hint()
window.Add(vbox)
window.SetSizeRequest(WIDTH+40, HEIGHT+50)
window.ShowAll()
gtk.Main()
}
示例10: main
func main() {
mc := memcache.New("127.0.0.1:11211")
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("memcachedclient")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
swin := gtk.NewScrolledWindow(nil, nil)
textview := gtk.NewTextView()
textview.SetEditable(false)
textview.SetCursorVisible(false)
textview.ModifyFontEasy("monospace 12")
swin.Add(textview)
vbox.Add(swin)
buffer := textview.GetBuffer()
input := gtk.NewEntry()
input.SetEditable(true)
vbox.PackEnd(input, false, false, 0)
tag := buffer.CreateTag("red", map[string]string{"foreground": "#FF0000"})
input.Connect("activate", func() {
var iter gtk.TextIter
tokens := strings.SplitN(input.GetText(), " ", 3)
if len(tokens) == 2 && strings.ToUpper(tokens[0]) == "GET" {
if t, err := mc.Get(tokens[1]); err == nil {
buffer.GetEndIter(&iter)
buffer.Insert(&iter, string(t.Value)+"\n")
} else {
buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
}
input.SetText("")
} else if len(tokens) == 3 && strings.ToUpper(tokens[0]) == "SET" {
if err := mc.Set(
&memcache.Item{
Key: tokens[1],
Value: []byte(tokens[2]),
}); err == nil {
buffer.GetEndIter(&iter)
buffer.InsertWithTag(&iter, "OK\n", tag)
} else {
buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
}
input.SetText("")
}
})
input.GrabFocus()
window.Add(vbox)
window.SetSizeRequest(300, 500)
window.ShowAll()
gtk.Main()
}
示例11: main
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("webkit")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
entry := gtk.NewEntry()
entry.SetText("http://golang.org/")
vbox.PackStart(entry, false, false, 0)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
webview := webkit.NewWebView()
webview.Connect("load-committed", func() {
entry.SetText(webview.GetUri())
})
swin.Add(webview)
vbox.Add(swin)
entry.Connect("activate", func() {
webview.LoadUri(entry.GetText())
})
button := gtk.NewButtonWithLabel("load String")
button.Clicked(func() {
webview.LoadString("hello Go GTK!", "text/plain", "utf-8", ".")
})
vbox.PackStart(button, false, false, 0)
button = gtk.NewButtonWithLabel("load HTML String")
button.Clicked(func() {
webview.LoadHtmlString(HTML_STRING, ".")
})
vbox.PackStart(button, false, false, 0)
button = gtk.NewButtonWithLabel("Google Maps")
button.Clicked(func() {
webview.LoadHtmlString(MAP_EMBED, ".")
})
vbox.PackStart(button, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(600, 600)
window.ShowAll()
proxy := os.Getenv("HTTP_PROXY")
if len(proxy) > 0 {
soup_uri := webkit.SoupUri(proxy)
webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
soup_uri.Free()
}
entry.Emit("activate")
gtk.Main()
}
示例12: 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()
}
示例13: CreateWindow
func CreateWindow() *gtk.Window {
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetDefaultSize(700, 300)
vbox := gtk.NewVBox(false, 1)
CreateMenuAndToolbar(window, vbox)
CreateActivatableDemo(vbox)
window.Add(vbox)
return window
}
示例14: main
func main() {
FreeConsole()
gtk.Init(nil)
screenHeight := gdk.ScreenHeight()
screenWidth := gdk.ScreenWidth()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("mgc")
window.SetIconName("gtk-about")
window.Connect("destroy", func() {
gtk.MainQuit()
})
vbox := gtk.NewVBox(false, 0)
menubar := gtk.NewMenuBar()
vbox.PackStart(menubar, false, false, 0)
menu := gtk.NewMenuItemWithMnemonic("_File")
menubar.Append(menu)
submenu := gtk.NewMenu()
menu.SetSubmenu(submenu)
menuitem := gtk.NewMenuItemWithMnemonic("E_xit")
menuitem.Connect("activate", func() {
gtk.MainQuit()
})
submenu.Append(menuitem)
hpaned := gtk.NewHPaned()
leftFrame := gtk.NewFrame("")
rightFrame := gtk.NewFrame("")
leftLabel := gtk.NewLabel("Left")
rightLabel := gtk.NewLabel("Right")
leftFrame.Add(leftLabel)
rightFrame.Add(rightLabel)
hpaned.Pack1(leftFrame, true, false)
hpaned.Pack2(rightFrame, true, false)
vbox.Add(hpaned)
window.Add(vbox)
window.SetSizeRequest(screenWidth/4*3, screenHeight/4*3)
window.ShowAll()
gtk.Main()
}
示例15: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("GTK DrawingArea")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
targets := []gtk.TargetEntry{
{"text/uri-list", 0, 0},
{"STRING", 0, 1},
{"text/plain", 0, 2},
}
dest := gtk.NewLabel("drop me file")
dest.DragDestSet(
gtk.DEST_DEFAULT_MOTION|
gtk.DEST_DEFAULT_HIGHLIGHT|
gtk.DEST_DEFAULT_DROP,
targets,
gdk.ACTION_COPY)
dest.DragDestAddUriTargets()
dest.Connect("drag-data-received", func(ctx *glib.CallbackContext) {
sdata := gtk.SelectionDataFromNative(unsafe.Pointer(ctx.Args(3)))
if sdata != nil {
a := (*[2000]uint8)(sdata.GetData())
files := strings.Split(string(a[0:sdata.GetLength()-1]), "\n")
for i := range files {
filename, _, _ := glib.FilenameFromUri(files[i])
files[i] = filename
}
dialog := gtk.NewMessageDialog(
window,
gtk.DIALOG_MODAL,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
strings.Join(files, "\n"))
dialog.SetTitle("D&D")
dialog.Response(func() {
dialog.Destroy()
})
dialog.Run()
}
})
vbox.Add(dest)
window.Add(vbox)
window.SetSizeRequest(300, 100)
window.ShowAll()
gtk.Main()
}