本文整理汇总了Golang中github.com/conformal/gotk3/gtk.WindowNew函数的典型用法代码示例。如果您正苦于以下问题:Golang WindowNew函数的具体用法?Golang WindowNew怎么用?Golang WindowNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WindowNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
// Initialize GTK without parsing any command line arguments.
gtk.Init(nil)
// Create a new toplevel window, set its title, and connect it to the
// "destroy" signal to exit the GTK main loop when it is destroyed.
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Simple Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new socket:
s, err := gtkx.SocketNew()
if err != nil {
log.Fatal("Unable to create socket:", err)
}
//Adding the socket to the window:
win.Add(s)
// Getting the socketId:
sId := s.GetId()
fmt.Printf("Our socket: %v\n", sId)
//Building a Plug for our Socket:
p, err := gtkx.PlugNew(sId)
if err != nil {
log.Fatal("Unable to create plug:", err)
}
//Building a Button for our Plug:
b, err := gtk.ButtonNewWithLabel("Click me .)")
if err != nil {
log.Fatal("Unable to create button:", err)
}
//Click events for the Button:
b.Connect("clicked", func() {
fmt.Printf("Yeah, such clicks!\n")
})
//Adding the Button to the Plug:
p.Add(b)
//Displaying the Plug:
p.ShowAll()
// Set the default window size.
win.SetDefaultSize(800, 600)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
开发者ID:runjak,项目名称:gotk3,代码行数:60,代码来源:selfplug.go
示例2: init
func (ui *Ui) init() {
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
win.SetTitle("GNOMEConnect")
win.SetDefaultSize(800, 600)
win.Connect("destroy", func() {
gtk.MainQuit()
ui.Quit <- true
})
ui.win = win
hbox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
win.Add(hbox)
scroller := ui.initDevicesList()
hbox.PackStart(scroller, false, true, 0)
sep, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
hbox.PackStart(sep, false, true, 0)
box := ui.initDeviceView()
hbox.PackEnd(box, true, true, 0)
titlebar := ui.initTitlebar()
win.SetTitlebar(titlebar)
win.ShowAll()
ui.selectDevice(nil)
}
开发者ID:emersion,项目名称:gnomeconnect,代码行数:28,代码来源:ui.go
示例3: main
func main() {
// Initialize GTK without parsing any command line arguments.
gtk.Init(nil)
// Create a new toplevel window, set its title, and connect it to the
// "destroy" signal to exit the GTK main loop when it is destroyed.
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Simple Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new label widget to show in the window.
l, err := gtk.LabelNew("Hello, gotk3!")
if err != nil {
log.Fatal("Unable to create label:", err)
}
// Add the label to the window.
win.Add(l)
// Set the default window size.
win.SetDefaultSize(800, 600)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
开发者ID:alimy,项目名称:gotk3,代码行数:34,代码来源:simple.go
示例4: setupWindow
// Setup the Window.
func setupWindow() *gtk.Window {
w, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
w.Connect("destroy", gtk.MainQuit)
w.SetDefaultSize(500, 300)
w.SetPosition(gtk.WIN_POS_CENTER)
w.SetTitle("TextView properties example")
return w
}
开发者ID:alimy,项目名称:gotk3,代码行数:10,代码来源:boolprops.go
示例5: RunErrorMessage
func RunErrorMessage(format string, args ...interface{}) error {
dummy, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return err
}
dialog := gtk.MessageDialogNew(dummy, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, fmt.Sprint("ERROR: ", format), args...)
dialog.Run()
dialog.Destroy()
return nil
}
开发者ID:cslinmiso,项目名称:goline-gotk3,代码行数:10,代码来源:utilites.go
示例6: main
func main() {
/*
We set an environment variable so that we don't get bothered by xterm accessibility warnings
like "** (xterm:16917): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-QznzMfGEXB: Connection refused"
See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15154
*/
os.Setenv("NO_AT_BRIDGE", "1")
// Initialize GTK without parsing any command line arguments.
gtk.Init(nil)
// Create a new toplevel window, set its title, and connect it to the
// "destroy" signal to exit the GTK main loop when it is destroyed.
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Simple Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new socket:
s, err := gtkx.SocketNew()
if err != nil {
log.Fatal("Unable to create socket:", err)
}
//Adding the socket to the window:
win.Add(s)
// Getting the socketId:
sId := s.GetId()
fmt.Printf("Our socket: %v\n", sId)
// Embedding something in the socket:
xterm := exec.Command("xterm", "-into", gtkx.WindowIdToString(sId))
go func() {
xterm.Run()
}()
// Set the default window size.
win.SetDefaultSize(800, 600)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
开发者ID:runjak,项目名称:gotk3,代码行数:52,代码来源:xterm.go
示例7: setup_window
func setup_window(title string) *gtk.Window {
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle(title)
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.SetDefaultSize(800, 600)
win.SetPosition(gtk.WIN_POS_CENTER)
return win
}
开发者ID:alimy,项目名称:gotk3,代码行数:13,代码来源:textview.go
示例8: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.Add(windowWidget())
// Native GTK is not thread safe, and thus, gotk3's GTK bindings may not
// be used from other goroutines. Instead, glib.IdleAdd() must be used
// to add a function to run in the GTK main loop when it is in an idle
// state.
//
// Two examples of using glib.IdleAdd() are shown below. The first runs
// a user created function, LabelSetTextIdle, and passes it two
// arguments for a label and the text to set it with. The second calls
// (*gtk.Label).SetText directly, passing in only the text as an
// argument.
//
// If the function passed to glib.IdleAdd() returns one argument, and
// that argument is a bool, this return value will be used in the same
// manner as a native g_idle_add() call. If this return value is false,
// the function will be removed from executing in the GTK main loop's
// idle state. If the return value is true, the function will continue
// to execute when the GTK main loop is in this state.
go func() {
for {
time.Sleep(time.Second)
s := fmt.Sprintf("Set a label %d time(s)!", nSets)
_, err := glib.IdleAdd(LabelSetTextIdle, topLabel, s)
if err != nil {
log.Fatal("IdleAdd() failed:", err)
}
nSets++
s = fmt.Sprintf("Set a label %d time(s)!", nSets)
_, err = glib.IdleAdd(bottomLabel.SetText, s)
if err != nil {
log.Fatal("IdleAdd() failed:", err)
}
nSets++
}
}()
win.ShowAll()
gtk.Main()
}
开发者ID:alimy,项目名称:gotk3,代码行数:51,代码来源:goroutines.go
示例9: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.Add(windowWidget())
win.ShowAll()
gtk.Main()
}
开发者ID:kendellfab,项目名称:gotk3,代码行数:16,代码来源:signals.go
示例10: RunGUI
// RunGUI initializes GTK, creates the toplevel window and all child widgets,
// opens the pages for the default session, and runs the Glib main event loop.
// This function blocks until the toplevel window is destroyed and the event
// loop exits.
func RunGUI() {
gtk.Init(nil)
window, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy", func() {
gtk.MainQuit()
})
window.SetDefaultGeometry(defaultWinWidth, defaultWinHeight)
window.Show()
wc := wk2.DefaultWebContext()
wc.SetProcessModel(wk2.ProcessModelMultipleSecondaryProcesses)
session := []PageDescription{HomePage}
pm := NewPageManager(session)
window.Add(pm)
pm.Show()
gtk.Main()
}
开发者ID:jrick,项目名称:xombrero2,代码行数:24,代码来源:xombrero.go
示例11: main
func main() {
gtk.Init(nil)
// gui boilerplate
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
da, _ := gtk.DrawingAreaNew()
win.Add(da)
win.SetTitle("Arrow keys")
win.Connect("destroy", gtk.MainQuit)
win.ShowAll()
// Data
unitSize := 20.0
x := 0.0
y := 0.0
keyMap := map[uint]func(){
KEY_LEFT: func() { x-- },
KEY_UP: func() { y-- },
KEY_RIGHT: func() { x++ },
KEY_DOWN: func() { y++ },
}
// Event handlers
da.Connect("draw", func(da *gtk.DrawingArea, cr *cairo.Context) {
cr.SetSourceRGB(0, 0, 0)
cr.Rectangle(x*unitSize, y*unitSize, unitSize, unitSize)
cr.Fill()
})
win.Connect("key-press-event", func(win *gtk.Window, ev *gdk.Event) {
keyEvent := &gdk.EventKey{ev}
if move, found := keyMap[keyEvent.KeyVal()]; found {
move()
win.QueueDraw()
}
})
gtk.Main()
}
开发者ID:alimy,项目名称:gotk3,代码行数:38,代码来源:game.go
示例12: displayImage
// Displays image in a new Gtk window
// This function blocks until the window is closed
func displayImage(img image.Image) error {
// Copy img into a new gdk.Pixbuf
pixbuf, err := imageToPixbuf(img)
if err != nil {
return errors.New("Failed to create a pixbuf for image")
}
// Initialize GtkWindow
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return errors.New("Failed to create new window")
}
win.Connect("destroy", func() { gtk.MainQuit() })
// Create GtkImage widget from pixbuf
gimg, err := gtk.ImageNewFromPixbuf(pixbuf)
if err != nil {
return errors.New("Failed to load image into window")
}
win.Add(gimg)
win.ShowAll()
gtk.Main()
return nil
}
开发者ID:postfix,项目名称:kaggle--facial-keypoints,代码行数:25,代码来源:display.go
示例13: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("UDP client v0.0.1")
win.Connect("destroy", func() {
gtk.MainQuit()
})
var c client.Client
answers := make(chan string)
grid, err := gtk.GridNew()
if err != nil {
log.Fatal("Unable to create grid:", err)
}
messageHistory, err := gtk.TextViewNew()
if err != nil {
log.Fatal("Unable to create TextView:", err)
}
grid.Attach(messageHistory, 0, 0, 4, 1)
messageEntry, err := gtk.EntryNew()
if err != nil {
log.Fatal("Unable to create entry:", err)
}
grid.Attach(messageEntry, 0, 1, 1, 1)
privateEntry, err := gtk.EntryNew()
if err != nil {
log.Fatal("Unable to create entry:", err)
}
grid.Attach(privateEntry, 1, 1, 1, 1)
sendButton, err := gtk.ButtonNewWithLabel("Send")
if err != nil {
log.Fatal("Unable to create button:", err)
}
sendButton.Connect("clicked", func(btn *gtk.Button) {
lbl, _ := btn.GetLabel()
if lbl != "Send" {
return
}
log.Print(lbl)
msg, _ := messageEntry.GetText()
log.Print(msg)
c.Message(msg)
})
grid.Attach(sendButton, 0, 2, 1, 1)
privateButton, err := gtk.ButtonNewWithLabel("Private")
if err != nil {
log.Fatal("Unable to create button:", err)
}
privateButton.Connect("clicked", func(btn *gtk.Button) {
lbl, _ := btn.GetLabel()
if lbl != "Private" {
return
}
log.Print(lbl)
private, _ := privateEntry.GetText()
log.Print(private)
if private != "" {
msg, _ := messageEntry.GetText()
log.Print(msg)
c.Private(private, msg)
}
})
grid.Attach(privateButton, 1, 2, 1, 1)
listButton, err := gtk.ButtonNewWithLabel("List")
if err != nil {
log.Fatal("Unable to create button:", err)
}
listButton.Connect("clicked", func(btn *gtk.Button) {
lbl, _ := btn.GetLabel()
if lbl != "List" {
return
}
log.Print(lbl)
c.List()
log.Print(lbl)
})
grid.Attach(listButton, 2, 1, 1, 1)
leaveButton, err := gtk.ButtonNewWithLabel("Leave")
if err != nil {
log.Fatal("Unable to create button:", err)
}
leaveButton.Connect("clicked", func(btn *gtk.Button) {
lbl, _ := btn.GetLabel()
if lbl != "Leave" {
return
}
log.Print(lbl)
c.Leave()
//.........这里部分代码省略.........
开发者ID:fiddenmar,项目名称:netlabs,代码行数:101,代码来源:gui.go
示例14: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Grid Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new grid widget to arrange child widgets
grid, err := gtk.GridNew()
if err != nil {
log.Fatal("Unable to create grid:", err)
}
// gtk.Grid embeds an Orientable struct to simulate the GtkOrientable
// GInterface. Set the orientation from the default horizontal to
// vertical.
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
// Create some widgets to put in the grid.
lab, err := gtk.LabelNew("Just a label")
if err != nil {
log.Fatal("Unable to create label:", err)
}
btn, err := gtk.ButtonNewWithLabel("Button with label")
if err != nil {
log.Fatal("Unable to create button:", err)
}
entry, err := gtk.EntryNew()
if err != nil {
log.Fatal("Unable to create entry:", err)
}
spnBtn, err := gtk.SpinButtonNewWithRange(0.0, 1.0, 0.001)
if err != nil {
log.Fatal("Unable to create spin button:", err)
}
nb, err := gtk.NotebookNew()
if err != nil {
log.Fatal("Unable to create notebook:", err)
}
// Calling (*gtk.Container).Add() with a gtk.Grid will add widgets next
// to each other, in the order they were added, to the right side of the
// last added widget when the grid is in a horizontal orientation, and
// at the bottom of the last added widget if the grid is in a vertial
// orientation. Using a grid in this manner works similar to a gtk.Box,
// but unlike gtk.Box, a gtk.Grid will respect its child widget's expand
// and margin properties.
grid.Add(btn)
grid.Add(lab)
grid.Add(entry)
grid.Add(spnBtn)
// Widgets may also be added by calling (*gtk.Grid).Attach() to specify
// where to place the widget in the grid, and optionally how many rows
// and columns to span over.
//
// Additional rows and columns are automatically added to the grid as
// necessary when new widgets are added with (*gtk.Container).Add(), or,
// as shown in this case, using (*gtk.Grid).Attach().
//
// In this case, a notebook is added beside the widgets inserted above.
// The notebook widget is inserted with a left position of 1, a top
// position of 1 (starting at the same vertical position as the button),
// a width of 1 column, and a height of 2 rows (spanning down to the
// same vertical position as the entry).
//
// This example also demonstrates how not every area of the grid must
// contain a widget. In particular, the area to the right of the label
// and the right of spin button have contain no widgets.
grid.Attach(nb, 1, 1, 1, 2)
nb.SetHExpand(true)
nb.SetVExpand(true)
// Add a child widget and tab label to the notebook so it renders.
nbChild, err := gtk.LabelNew("Notebook content")
if err != nil {
log.Fatal("Unable to create button:", err)
}
nbTab, err := gtk.LabelNew("Tab label")
if err != nil {
log.Fatal("Unable to create label:", err)
}
nb.AppendPage(nbChild, nbTab)
// Add the grid to the window, and show all widgets.
win.Add(grid)
win.ShowAll()
gtk.Main()
}
开发者ID:alimy,项目名称:gotk3,代码行数:99,代码来源:grid.go
示例15: CreateWindow
// CreateWindow creates the toplevel window for the GUI.
func CreateWindow() (*gtk.Window, error) {
var err error
mainWindow, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return nil, err
}
mainWindow.SetTitle("btcgui")
mainWindow.Connect("destroy", func() {
gtk.MainQuit()
})
grid, err := gtk.GridNew()
if err != nil {
return nil, err
}
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
grid.Add(createMenuBar())
notebook, err := gtk.NotebookNew()
if err != nil {
return nil, err
}
notebook.SetHExpand(true)
notebook.SetVExpand(true)
grid.Add(notebook)
l, err := gtk.LabelNew("Overview")
if err != nil {
return nil, err
}
notebook.AppendPage(createOverview(), l)
l, err = gtk.LabelNew("Send Coins")
if err != nil {
return nil, err
}
notebook.AppendPage(createSendCoins(), l)
l, err = gtk.LabelNew("Receive Coins")
if err != nil {
return nil, err
}
notebook.AppendPage(createRecvCoins(), l)
l, err = gtk.LabelNew("Transactions")
if err != nil {
log.Fatal(err)
}
notebook.AppendPage(createTransactions(), l)
// TODO(jrick): Add back when address book is implemented.
/*
l, err = gtk.LabelNew("Address Book")
if err != nil {
log.Fatal(err)
}
notebook.AppendPage(createAddrBook(), l)
*/
grid.Add(createStatusbar())
mainWindow.Add(grid)
mainWindow.SetDefaultGeometry(800, 600)
return mainWindow, nil
}
开发者ID:hsk81,项目名称:btcgui,代码行数:69,代码来源:window.go
注:本文中的github.com/conformal/gotk3/gtk.WindowNew函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论