本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.NewLabel函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLabel函数的具体用法?Golang NewLabel怎么用?Golang NewLabel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLabel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例2: 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()
}
示例3: 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()
}
示例4: 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()
}
示例5: KeyboardHandler
// KeyboardHandler handle events from keyboard
func KeyboardHandler(event chan *keyhandler.KeyPressEvent, window *gtk.Window,
repl *gtk.Entry, URLEntry *gtk.Entry, notebook *gtk.Notebook) {
for {
kpe := <-event
log.Printf("[DEBUG] KeyPressEvent : %v", kpe)
gdk.ThreadsEnter()
switch kpe.KeyVal {
case gdk.KEY_Escape:
repl.SetVisible(false)
break
case gdk.KEY_colon:
if !repl.IsFocus() && !URLEntry.IsFocus() {
repl.SetVisible(true)
repl.GrabFocus()
repl.SetText(":")
repl.SetPosition(1)
}
break
case gdk.KEY_Return:
if repl.IsFocus() {
text := repl.GetText()
log.Printf("Repl text : %s", text)
if len(text) > 0 {
command.Run(text, window, "")
}
repl.SetText("")
}
break
// case gdk.KEY_w:
// if kpe.GetModifier() == keyhandler.CTRL {
// log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
// notebook.RemovePage(notebook.GetCurrentPage())
// log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
// }
// break
case gdk.KEY_t:
if kpe.GetModifier() == keyhandler.CTRL {
log.Printf("[DEBUG] New tab")
log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
log.Printf("[DEBUG] current : %d",
notebook.GetCurrentPage())
tab := ui.NewBrowser("")
page := gtk.NewFrame("")
//fmt.Sprintf("%d", notebook.GetNPages()+1))
notebook.AppendPage(page, gtk.NewLabel("New tab"))
page.Add(tab.VBox)
log.Printf("[DEBUG] nb : %d", notebook.GetNPages())
notebook.ShowAll()
}
break
case gdk.KEY_q:
if kpe.GetModifier() == keyhandler.CTRL {
gtk.MainQuit()
}
break
}
gdk.ThreadsLeave()
}
}
示例6: Construct
// Constructor function
// 1. Create Components
// 2. Setup Layout
// 3. Event - Callback
func (this *UI) Construct() {
defer catch()
// 1. Creating Components
// ---- ---- ---- ---- ---- ---- ---- ----
// Create the Main Window
// Set title & size
this.Win = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
if this.Win == nil {
panic("UI::Construct() : Window allocation Failed")
}
window := this.Win // Window aliasin
window.SetTitle("0x_Calculator") // SetTitle
this.Calc_Frame = gtk.NewFrame("Calculation")
this.Nums_Frame = gtk.NewFrame("Numbers")
this.Oper_Frame = gtk.NewFrame("Operation")
this.Lbl_prev = gtk.NewLabel("(Previous)")
this.Lbl_lhs = gtk.NewLabel("(LHS)")
this.Lbl_rhs = gtk.NewLabel("(RHS)")
this.Btn_map = make(map[string]*gtk.Button)
this.Ch_Event = make(chan interface{})
this.csr = NONE // There is no operator
this.radix = CVT_DEC // Decimal radix format
this.op_code = OP_XXX // Nothing
// 2. Setup Layout
// ---- ---- ---- ---- ---- ---- ---- ----
this.init_Calc()
this.init_Nums()
this.init_Oper()
this.put_frames()
// 3. Event - Callback connection
// ---- ---- ---- ---- ---- ---- ---- ----
this.init_Events()
// 4. Left overs
// ---- ---- ---- ---- ---- ---- ---- ----
window.SetSizeRequest(UI_Width, UI_Height)
window.ShowAll()
}
示例7: 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
}
示例8: Init
// Init acts as a constructor for the Status window struct
func (v *Status) Init(client, user string, minutes int) {
// Initialize variables
v.client = client
v.user = user
v.minutes = minutes
v.warned = false
v.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
// Inital Window configuration
v.window.SetKeepAbove(true)
v.window.SetTitle(client)
v.window.SetTypeHint(gdk.WINDOW_TYPE_HINT_MENU)
v.window.SetSizeRequest(200, 180)
v.window.SetResizable(false)
// Build GUI
userLabel := gtk.NewLabel(user)
v.timeLabel = gtk.NewLabel("")
v.timeLabel.SetMarkup("<span size='xx-large'>" + strconv.Itoa(v.minutes) + " min igjen</span>")
button := gtk.NewButtonWithLabel("Logg ut")
vbox := gtk.NewVBox(false, 20)
vbox.SetBorderWidth(5)
vbox.Add(userLabel)
vbox.Add(v.timeLabel)
vbox.Add(button)
v.window.Add(vbox)
// Connect GUI event signals to function callbacks
v.window.Connect("delete-event", func() bool {
// Don't allow user to quit by closing the window
return true
})
button.Connect("clicked", func() {
gtk.MainQuit()
})
return
}
示例9: 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()
}
示例10: main
func main() {
runtime.GOMAXPROCS(10)
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(false, 1)
label1 := gtk.NewLabel("")
vbox.Add(label1)
label2 := gtk.NewLabel("")
vbox.Add(label2)
window.Add(vbox)
window.SetSizeRequest(100, 100)
window.ShowAll()
time.Sleep(1000 * 1000 * 100)
go (func() {
for i := 0; i < 300000; i++ {
gdk.ThreadsEnter()
label1.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
go (func() {
for i := 300000; i >= 0; i-- {
gdk.ThreadsEnter()
label2.SetLabel(strconv.Itoa(i))
gdk.ThreadsLeave()
}
gtk.MainQuit()
})()
gtk.Main()
}
示例11: 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
}
示例12: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Alignment")
window.Connect("destroy", gtk.MainQuit)
notebook := gtk.NewNotebook()
window.Add(notebook)
align := gtk.NewAlignment(0.5, 0.5, 0.5, 0.5)
notebook.AppendPage(align, gtk.NewLabel("Alignment"))
button := gtk.NewButtonWithLabel("Hello World!")
align.Add(button)
fixed := gtk.NewFixed()
notebook.AppendPage(fixed, gtk.NewLabel("Fixed"))
button2 := gtk.NewButtonWithLabel("Pulse")
fixed.Put(button2, 30, 30)
progress := gtk.NewProgressBar()
fixed.Put(progress, 30, 70)
button.Connect("clicked", func() {
progress.SetFraction(0.1 + 0.9*progress.GetFraction()) //easter egg
})
button2.Connect("clicked", func() {
progress.Pulse()
})
window.ShowAll()
window.SetSizeRequest(200, 200)
gtk.Main()
}
示例13: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetSizeRequest(150, 50)
window.SetPosition(gtk.WIN_POS_CENTER)
window.Connect("destroy", func(ctx *glib.CallbackContext) {
gtk.MainQuit()
}, nil)
label := gtk.NewLabel("hello world")
window.Add(label)
window.ShowAll()
gtk.Main()
}
示例14: main
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("We love Expander")
window.Connect("destroy", gtk.MainQuit)
vbox := gtk.NewVBox(true, 0)
vbox.SetBorderWidth(5)
expander := gtk.NewExpander("dan the ...")
expander.Add(gtk.NewLabel("404 contents not found"))
vbox.PackStart(expander, false, false, 0)
window.Add(vbox)
window.ShowAll()
gtk.Main()
}
示例15: ShortTime
// ShortTime creates a GTK fullscreen window for the shorttime clients.
// No username/password required, only click 'start' button to log in
func ShortTime(client string, minutes int) (user string) {
// Inital window configuration
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
defer window.Destroy()
window.Fullscreen()
window.SetKeepAbove(true)
window.SetTitle("Mycel Login")
// Build GUI
frame := gtk.NewFrame("Logg deg på " + client)
frame.SetLabelAlign(0.5, 0.5)
var imageLoader *gdkpixbuf.Loader
imageLoader, _ = gdkpixbuf.NewLoaderWithMimeType("image/png")
imageLoader.Write(logo_png())
imageLoader.Close()
logo := gtk.NewImageFromPixbuf(imageLoader.GetPixbuf())
info := gtk.NewLabel("")
info.SetMarkup("<span foreground='red'>Dette er en korttidsmaskin\nMaks " +
strconv.Itoa(minutes) + " minutter!</span>")
button := gtk.NewButtonWithLabel("\nStart\n")
vbox := gtk.NewVBox(false, 20)
vbox.SetBorderWidth(20)
vbox.Add(logo)
vbox.Add(info)
vbox.Add(button)
frame.Add(vbox)
center := gtk.NewAlignment(0.5, 0.5, 0, 0)
center.Add(frame)
window.Add(center)
// Connect GUI event signals to function callbacks
button.Connect("clicked", func() {
gtk.MainQuit()
})
window.Connect("delete-event", func() bool {
return true
})
window.ShowAll()
gtk.Main()
return "Anonym"
}