本文整理汇总了Golang中github.com/mattn/go-gtk/gtk.NewLabel函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLabel函数的具体用法?Golang NewLabel怎么用?Golang NewLabel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLabel函数的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: 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()
}
开发者ID:vsannikov,项目名称:mgc,代码行数:54,代码来源:main.go
示例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()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:34,代码来源:notebook.go
示例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()
}
开发者ID:zchee,项目名称:gouv,代码行数:28,代码来源:gui.go
示例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()
}
}
开发者ID:nlamirault,项目名称:actarus,代码行数:60,代码来源:keyboard.go
示例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()
}
开发者ID:gophergala2016,项目名称:0x_Calc,代码行数:49,代码来源:layout.go
示例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
}
开发者ID:kch42,项目名称:biomed,代码行数:41,代码来源:biome_info_editor.go
示例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
}
开发者ID:digibib,项目名称:mycel-client,代码行数:41,代码来源:status.go
示例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()
}
开发者ID:JessonChan,项目名称:go-gtk,代码行数:52,代码来源:dnd.go
示例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()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:39,代码来源:threads.go
示例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
}
开发者ID:kch42,项目名称:biomed,代码行数:51,代码来源:main.go
示例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()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:36,代码来源:alignment.go
示例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()
}
开发者ID:ecdhe,项目名称:various_language_examples,代码行数:16,代码来源:go_gogtk.go
示例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()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:17,代码来源:expander.go
示例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"
}
开发者ID:digibib,项目名称:mycel-client,代码行数:47,代码来源:shorttime.go
示例16: main
func main() {
gtk.Init(&os.Args)
dialog := gtk.NewDialog()
dialog.SetTitle("number input")
vbox := dialog.GetVBox()
label := gtk.NewLabel("Numnber:")
vbox.Add(label)
input := gtk.NewEntry()
input.SetEditable(true)
vbox.Add(input)
input.Connect("insert-text", func(ctx *glib.CallbackContext) {
a := (*[2000]uint8)(unsafe.Pointer(ctx.Args(0)))
p := (*int)(unsafe.Pointer(ctx.Args(2)))
i := 0
for a[i] != 0 {
i++
}
s := string(a[0:i])
if s == "." {
if *p == 0 {
input.StopEmission("insert-text")
}
} else {
_, err := strconv.ParseFloat(s, 64)
if err != nil {
input.StopEmission("insert-text")
}
}
})
button := gtk.NewButtonWithLabel("OK")
button.Connect("clicked", func() {
println(input.GetText())
gtk.MainQuit()
})
vbox.Add(button)
dialog.ShowAll()
gtk.Main()
}
开发者ID:JessonChan,项目名称:go-gtk,代码行数:45,代码来源:number.go
示例17: main
func main() {
flag.Parse()
common.SetDefaultGtkTheme()
runtime.GOMAXPROCS(runtime.NumCPU())
rclient = &remoton.Client{Prefix: "/remoton", TLSConfig: &tls.Config{}}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGABRT, syscall.SIGKILL, syscall.SIGTERM)
go func() {
<-sigs
chatSrv.Terminate()
tunnelSrv.Terminate()
}()
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetTitle("REMOTON SUPPORT")
window.Connect("destroy", func() {
gtk.MainQuit()
chatSrv.Terminate()
tunnelSrv.Terminate()
})
window.SetIcon(common.GetIconGdkPixbuf())
appLayout := gtk.NewVBox(false, 1)
menu := gtk.NewMenuBar()
appLayout.Add(menu)
cascademenu := gtk.NewMenuItemWithMnemonic("_Help")
menu.Append(cascademenu)
submenu := gtk.NewMenu()
cascademenu.SetSubmenu(submenu)
menuitem := gtk.NewMenuItemWithMnemonic("_About")
menuitem.Connect("activate", func() {
dialog := common.GtkAboutDialog()
dialog.SetProgramName("Support Desktop")
dialog.Run()
dialog.Destroy()
})
submenu.Append(menuitem)
hpaned := gtk.NewHPaned()
appLayout.Add(hpaned)
//---
//CHAT
//---
frameChat := gtk.NewFrame("Chat")
chatBox := gtk.NewVBox(false, 1)
frameChat.Add(chatBox)
swinChat := gtk.NewScrolledWindow(nil, nil)
chatHistory := gtk.NewTextView()
swinChat.Add(chatHistory)
chatEntry := gtk.NewEntry()
chatEntry.Connect("key-press-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
event := *(**gdk.EventKey)(unsafe.Pointer(&arg))
if event.Keyval == gdk.KEY_Return {
msgToSend := chatEntry.GetText()
chatSrv.Send(msgToSend)
chatHistorySend(chatHistory, msgToSend)
chatEntry.SetText("")
}
})
chatSrv.OnRecv(func(msg string) {
log.Println(msg)
chatHistoryRecv(chatHistory, msg)
})
chatBox.Add(chatEntry)
chatBox.Add(swinChat)
//---
//CONTROL
//---
frameControl := gtk.NewFrame("Control")
controlBox := gtk.NewVBox(false, 1)
frameControl.Add(controlBox)
controlBox.Add(gtk.NewLabel("Machine ID"))
machineIDEntry := gtk.NewEntry()
controlBox.Add(machineIDEntry)
controlBox.Add(gtk.NewLabel("Machine AUTH"))
machineAuthEntry := gtk.NewEntry()
controlBox.Add(machineAuthEntry)
controlBox.Add(gtk.NewLabel("Server"))
serverEntry := gtk.NewEntry()
serverEntry.SetText("localhost:9934")
if os.Getenv("REMOTON_SERVER") != "" {
serverEntry.SetText(os.Getenv("REMOTON_SERVER"))
serverEntry.SetEditable(false)
//.........这里部分代码省略.........
开发者ID:bit4bit,项目名称:remoton,代码行数:101,代码来源:main.go
示例18: runGUI
func runGUI() {
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle(getApplicationTitle())
window.Connect("destroy", gtk.MainQuit)
keyboardEventsChan := make(chan *keyhandler.KeyPressEvent)
window.Connect("key-press-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))
kpe := keyhandler.KeyPressEvent{int(kev.Keyval), 0}
if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 {
kpe.Modifier = gdk.CONTROL_MASK
}
keyboardEventsChan <- &kpe
})
// motionEvent := make(chan interface{})
// window.Connect("motion-notify-event", func(ctx *glib.CallbackContext) {
// arg := ctx.Args(0)
// motionEvent <- *(**gdk.EventMotion)(unsafe.Pointer(&arg))
// })
// go events.MotionHandler(motionEvent)
buttonEventChan := make(chan interface{})
window.Connect("button-press-event", func(ctx *glib.CallbackContext) {
arg := ctx.Args(0)
buttonEventChan <- *(**gdk.EventButton)(unsafe.Pointer(&arg))
})
go events.ButtonHandler(buttonEventChan)
setupProxy()
vbox := gtk.NewVBox(false, 1)
notebook := gtk.NewNotebook()
tab := ui.NewBrowser(homePage)
page := gtk.NewFrame("")
notebook.AppendPage(page, gtk.NewLabel("Home"))
page.Add(tab.VBox)
vbox.PackStart(notebook, true, true, 0)
statusbar := gtk.NewStatusbar()
contextID := statusbar.GetContextId("actarus")
statusbar.Push(contextID, "Welcome to Actarus.")
vbox.PackStart(statusbar, false, false, 0)
replEntry := gtk.NewEntry()
replEntry.Hide()
vbox.PackEnd(replEntry, false, false, 0)
window.Add(vbox)
window.SetSizeRequest(defaultWinWidth, defaultWinHeight)
window.ShowAll()
replEntry.GrabFocus()
replEntry.SetVisible(false)
// Handlers
go events.KeyboardHandler(
keyboardEventsChan,
window,
replEntry,
tab.URLEntry,
notebook)
gtk.Main()
}
开发者ID:nlamirault,项目名称:actarus,代码行数:70,代码来源:actarus.go
示例19: guiMain
func guiMain(confglobal string, conflocal string) {
var CallID string
ch := make(chan string, 100)
Config := ReadConfig(confglobal)
Configlocal := ReadConfiglocal(conflocal)
owner := Configlocal.Main.Owner
//prepare config for XSI
var xsiConfig xsi.ConfigT
xsiConfig.Main.User = Configlocal.Main.Owner
xsiConfig.Main.Password = Configlocal.Main.Password
xsiConfig.Main.Host = Config.Main.Host
xsiConfig.Main.HTTPHost = Config.Main.HTTPHost
xsiConfig.Main.HTTPPort = Config.Main.HTTPPort
def := xsi.MakeDef(xsiConfig)
//start main client
go clientMain(ch, Config)
//prepare config for OCI
var ociConfig ocip.ConfigT
ociConfig.Main.User = Configlocal.Main.Owner
ociConfig.Main.Password = Configlocal.Main.Password
ociConfig.Main.Host = Config.Main.Host
ociConfig.Main.OCIPPort = Config.Main.OCIPPort
//set unavailable at start app
ocip.OCIPsend(ociConfig, "UserCallCenterModifyRequest19", ConcatStr("", "userId=", owner), "agentACDState=Unavailable")
//prepare timer
timer := time.NewTimer(time.Second)
timer.Stop()
//init gthreads
glib.ThreadInit(nil)
gdk.ThreadsInit()
gdk.ThreadsEnter()
gtk.Init(nil)
//names
names := make(map[string]string)
for iter, target := range Config.Main.TargetID {
names[target] = Config.Main.Name[iter]
}
//icons to pixbuf map
pix := make(map[string]*gdkpixbuf.Pixbuf)
im_call := gtk.NewImageFromFile("ico/Call-Ringing-48.ico")
pix["call"] = im_call.GetPixbuf()
im_blank := gtk.NewImageFromFile("ico/Empty-48.ico")
pix["blank"] = im_blank.GetPixbuf()
im_green := gtk.NewImageFromFile("ico/Green-ball-48.ico")
pix["green"] = im_green.GetPixbuf()
im_grey := gtk.NewImageFromFile("ico/Grey-ball-48.ico")
pix["grey"] = im_grey.GetPixbuf()
im_yellow := gtk.NewImageFromFile("ico/Yellow-ball-48.ico")
pix["yellow"] = im_yellow.GetPixbuf()
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Call Center")
window.SetIcon(pix["call"])
window.SetPosition(gtk.WIN_POS_CENTER)
window.SetSizeRequest(350, 500)
window.SetDecorated(false)
window.SetResizable(true)
window.Connect("destroy", gtk.MainQuit)
swin := gtk.NewScrolledWindow(nil, nil)
swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin.SetShadowType(gtk.SHADOW_IN)
//owner
owner1 := gtk.NewLabel(names[owner])
owner2 := gtk.NewLabel("")
owner3 := gtk.NewImage()
//qstatus
qlabel1 := gtk.NewLabel("В очереди:")
qlabel2 := gtk.NewLabel("")
//buttons
b_av := gtk.NewButtonWithLabel("Доступен")
b_av.SetCanFocus(false)
b_av.Connect("clicked", func() {
ocip.OCIPsend(ociConfig, "UserCallCenterModifyRequest19", ConcatStr("", "userId=", owner), "agentACDState=Available")
})
b_un := gtk.NewButtonWithLabel("Недоступен")
b_un.SetCanFocus(false)
b_un.Connect("clicked", func() {
ocip.OCIPsend(ociConfig, "UserCallCenterModifyRequest19", ConcatStr("", "userId=", owner), "agentACDState=Unavailable")
})
b_wr := gtk.NewButtonWithLabel("Дообработка")
b_wr.SetCanFocus(false)
b_wr.Connect("clicked", func() {
ocip.OCIPsend(ociConfig, "UserCallCenterModifyRequest19", ConcatStr("", "userId=", owner), "agentACDState=Wrap-Up")
})
//main table
table := gtk.NewTable(3, 3, false)
table.Attach(owner1, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 1, 1)
table.Attach(owner3, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 1, 1)
table.Attach(owner2, 2, 3, 0, 1, gtk.FILL, gtk.FILL, 1, 1)
//.........这里部分代码省略.........
开发者ID:fffilimonov,项目名称:BW_CCC,代码行数:101,代码来源:gui.go
示例20: mainWindow
func mainWindow() {
gtk.Init(&os.Args)
// window settings
window_main := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window_main.SetPosition(gtk.WIN_POS_CENTER)
window_main.SetTitle("Social Gopher")
window_main.Connect("destroy", func() {
println("[!] Quit application")
gtk.MainQuit()
})
// images
image_profile := loadImageAsset("profile")
image_stream := loadImageAsset("stream")
image_mentions := loadImageAsset("mentions")
image_interactions := loadImageAsset("interactions")
image_stars := loadImageAsset("stars")
image_messages := loadImageAsset("messages")
image_settings := loadImageAsset("settings")
// containers
container_main := gtk.NewHBox(false, 1)
container_left := gtk.NewVBox(false, 1)
container_right := gtk.NewVBox(false, 5)
container_compose := gtk.NewHBox(false, 5)
container_profile := gtk.NewHBox(false, 5)
container_profile.Add(image_profile)
container_left.SetBorderWidth(5)
container_right.SetBorderWidth(5)
// toolbar
button_stream := gtk.NewToolButton(image_stream, "My Stream")
button_mentions := gtk.NewToolButton(image_mentions, "Mentions")
button_interactions := gtk.NewToolButton(image_interactions, "Interactions")
button_stars := gtk.NewToolButton(image_stars, "Stars")
button_messages := gtk.NewToolButton(image_messages, "Messages")
button_settings := gtk.NewToolButton(image_settings, "Settings")
button_separator := gtk.NewSeparatorToolItem()
toolbar := gtk.NewToolbar()
toolbar.SetOrientation(gtk.ORIENTATION_VERTICAL)
toolbar.Insert(button_stream, -1)
toolbar.Insert(button_mentions, -1)
toolbar.Insert(button_interactions, -1)
toolbar.Insert(button_stars, -1)
toolbar.Insert(button_messages, -1)
toolbar.Insert(button_separator, -1)
toolbar.Insert(button_settings, -1)
// stream list
list_swin := gtk.NewScrolledWindow(nil, nil)
list_swin.SetPolicy(-1, 1)
list_swin.SetShadowType(2)
list_textView := gtk.NewTextView()
list_textView.SetEditable(false)
list_textView.SetCursorVisible(false)
list_textView.SetWrapMode(2)
list_swin.Add(list_textView)
list_buffer := list_textView.GetBuffer()
// compose message
compose := gtk.NewTextView()
compose.SetEditable(true)
compose.SetWrapMode(2)
compose_swin := gtk.NewScrolledWindow(nil, nil)
compose_swin.SetPolicy(1, 1)
compose_swin.SetShadowType(1)
compose_swin.Add(compose)
compose_counter := gtk.NewLabel("256")
compose_buffer := compose.GetBuffer()
compose_buffer.Connect("changed", func() {
chars_left := 256 - compose_buffer.GetCharCount()
compose_counter.SetText(strconv.Itoa(chars_left))
})
// post button and counter
button_post := gtk.NewButtonWithLabel("Post")
container_post := gtk.NewVBox(false, 1)
container_post.Add(compose_counter)
container_post.Add(button_post)
// button functions
button_stream.OnClicked(func() {
list_buffer.SetText("My Stream")
})
button_mentions.OnClicked(func() {
list_buffer.SetText("Mentions")
})
button_interactions.OnClicked(func() {
list_buffer.SetText("Interactions")
})
button_stars.OnClicked(func() {
list_buffer.SetText("Stars")
})
button_messages.OnClicked(func() {
list_buffer.SetText("Messages")
})
button_settings.OnClicked(func() {
accountWindow()
//.........这里部分代码省略.........
开发者ID:kisom,项目名称:socialgopher,代码行数:101,代码来源:app.go
注:本文中的github.com/mattn/go-gtk/gtk.NewLabel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论