本文整理汇总了Golang中github.com/gotk3/gotk3/gtk.WindowNew函数的典型用法代码示例。如果您正苦于以下问题:Golang WindowNew函数的具体用法?Golang WindowNew怎么用?Golang WindowNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WindowNew函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 label widget to show in the window.
list, err := gtk.ListBoxNew()
if err != nil {
log.Fatal("Unable to create label:", err)
}
gtkList = list
// Add the label to the window.
win.Add(gtkList)
// Set the default window size.
win.SetDefaultSize(640/2, 1136/2)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
go getEntries()
gtk.Main()
}
开发者ID:MobiusHorizons,项目名称:GoStudentNews,代码行数:35,代码来源:main.go
示例2: uiSetup
func uiSetup() {
var err error
cssProvider, err = gtk.CssProviderNew()
e.Exit(err)
err = cssProvider.LoadFromData(css)
e.Exit(err)
w.count, err = gtk.SpinButtonNewWithRange(1, 999, 1)
e.Exit(err)
w.count.SetValue(1)
shuffle, err := gtk.ButtonNewWithLabel("Shuffle")
e.Exit(err)
w.showActionsText, err = gtk.CheckButtonNewWithMnemonic("Show actions _text")
e.Exit(err)
w.showPermutation, err = gtk.CheckButtonNewWithMnemonic("Show _permutation")
e.Exit(err)
w.cellSize, err = gtk.SpinButtonNewWithRange(1, 999, 1)
e.Exit(err)
w.cellSize.SetValue(32)
cellSizeLabel, err := gtk.LabelNew("Cell size:")
e.Exit(err)
w.count.Connect("changed", uiShuffle)
w.count.Connect("activate", uiShuffle)
shuffle.Connect("clicked", uiShuffle)
w.showActionsText.Connect("toggled", uiReset)
w.showPermutation.Connect("toggled", uiReset)
w.cellSize.Connect("changed", uiReset)
panel, err := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
e.Exit(err)
panel.SetSpacing(5)
panel.Add(w.count)
panel.Add(shuffle)
panel.Add(w.showActionsText)
panel.Add(w.showPermutation)
panel.Add(cellSizeLabel)
panel.Add(w.cellSize)
w.fieldWindow, err = gtk.ScrolledWindowNew(nil, nil)
e.Exit(err)
layout, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
e.Exit(err)
layout.Add(panel)
layout.PackStart(w.fieldWindow, true, true, 0)
window, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
e.Exit(err)
window.SetTitle(title)
window.Add(layout)
window.Connect("destroy", gtk.MainQuit)
uiShuffle()
window.ShowAll()
}
开发者ID:orivej,项目名称:manual-shuffle,代码行数:60,代码来源:main.go
示例3: 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:adrien3d,项目名称:gobox,代码行数:10,代码来源:boolprops.go
示例4: NewWindowMain
// NewWindowMain creates a new toplevel window, set size and pack the main widget.
//
func NewWindowMain(widget gtk.IWidget, w, h int) *gtk.Window {
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
// log.Fatal("Unable to create window:", err)
return nil
}
win.SetDefaultSize(w, h)
win.Add(widget)
win.ShowAll()
return win
}
开发者ID:sqp,项目名称:godock,代码行数:13,代码来源:common.go
示例5: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
panicIfNotNil(err)
win.Connect("destroy", func() {
gtk.MainQuit()
})
win.SetDefaultSize(1280, 720)
win.SetTitle("mauIRC Desktop")
// Create a new grid widget to arrange child widgets
grid, err := gtk.GridNew()
panicIfNotNil(err)
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
loginLabel, err := gtk.LabelNew("Log in to mauIRC")
panicIfNotNil(err)
email, err := gtk.EntryNew()
panicIfNotNil(err)
password, err := gtk.EntryNew()
panicIfNotNil(err)
password.SetVisibility(false)
btn, err := gtk.ButtonNewWithLabel("Log in")
panicIfNotNil(err)
grid.Attach(loginLabel, 0, 2, 1, 1)
grid.Attach(email, 0, 3, 1, 1)
grid.Attach(password, 0, 4, 1, 1)
grid.Attach(btn, 0, 5, 1, 1)
//grid.Attach(nb, 1, 1, 1, 2)
//nb.SetHExpand(true)
//nb.SetVExpand(true)
/*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)*/
win.Add(grid)
win.ShowAll()
gtk.Main()
}
开发者ID:tulir293,项目名称:mauirc-desktop,代码行数:53,代码来源:mauirc.go
示例6: 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:gotk3,项目名称:gotk3-examples,代码行数:13,代码来源:stack.go
示例7: 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:yamnikov-oleg,项目名称:gotk3-examples,代码行数:51,代码来源:goroutines.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())
win.ShowAll()
gtk.Main()
}
开发者ID:adrien3d,项目名称:gobox,代码行数:16,代码来源:signals.go
示例9: NewWindow
// NewWindow creates a new config window with its widget, ready to use.
//
func NewWindow(data datatype.Source, log cdtype.Logger) (*GuiConfigure, error) {
win, e := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if e != nil {
return nil, e
}
win.SetDefaultSize(WindowWidth, WindowHeight)
win.SetTitle(WindowTitle)
win.SetWMClass(WindowClass, WindowTitle)
win.SetIconFromFile(data.AppIcon())
widget := NewWidget(data, log)
widget.SetWindow(win)
win.Add(widget)
win.ShowAll()
return widget, nil
}
开发者ID:sqp,项目名称:godock,代码行数:21,代码来源:confgui.go
示例10: NewMainWindow
func NewMainWindow() *MainWindow {
self := new(MainWindow)
var err error
self.Window, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Failed to load GTK")
}
self.Board = board.NewBoard()
self.InitializeWidgets()
self.Window.Connect("destroy", func() {
gtk.MainQuit()
})
self.Window.SetDefaultSize(640, 560)
return self
}
开发者ID:juanfgs,项目名称:checkers,代码行数:20,代码来源:ui.go
示例11: main
func main() {
gtk.Init(nil)
win, e := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if e != nil {
println(e.Error())
return
}
path, isTest := vdata.TestPathDefault()
var saveCall func(cftype.Builder)
if isTest {
saveCall = cfprint.Updated
} else {
saveCall = func(build cftype.Builder) { cfprint.Default(build, true) }
}
source := vdata.New(log.NewLog(log.Logs), win, saveCall)
build := vdata.TestInit(source, path)
source.SetGrouper(build)
glib.IdleAdd(packWindow(win, source, build))
gtk.Main()
}
开发者ID:sqp,项目名称:godock,代码行数:22,代码来源:confgui.go
示例12: main
func main() {
gtk.Init(&os.Args)
// Declarations
Window, _ = gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
RootBox, _ = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 6)
TreeView, _ = gtk.TreeViewNew()
Entry, _ = gtk.EntryNew()
ListStore, _ = gtk.ListStoreNew(glib.TYPE_STRING)
// Window properties
Window.SetTitle("Products written in Go")
Window.Connect("destroy", gtk.MainQuit)
// TreeView properties
{
renderer, _ := gtk.CellRendererTextNew()
column, _ := gtk.TreeViewColumnNewWithAttribute("Value", renderer, "text", 0)
TreeView.AppendColumn(column)
}
TreeView.SetModel(ListStore)
// TreeView selection properties
sel, _ := TreeView.GetSelection()
sel.SetMode(gtk.SELECTION_MULTIPLE)
sel.Connect("changed", SelectionChanged)
// Packing
RootBox.PackStart(TreeView, true, true, 0)
RootBox.PackStart(Entry, false, false, 0)
Window.Add(RootBox)
// Populating list
// TODO: Add more values to the list
AppendMultipleToList("Go", "Docker", "CockroachDB")
Window.ShowAll()
gtk.Main()
}
开发者ID:yamnikov-oleg,项目名称:gotk3-examples,代码行数:39,代码来源:treeselection.go
示例13: 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:yamnikov-oleg,项目名称:gotk3-examples,代码行数:38,代码来源:game.go
示例14: main
func main() {
gtk.Init(nil)
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Impossible de créer la fenêtre :", err)
}
win.SetTitle("GoBox a0.1")
win.Connect("destroy", func() {
gtk.MainQuit()
})
grid, err := gtk.GridNew()
if err != nil {
log.Fatal("Impossible de créer la grille :", err)
}
label1, err := gtk.LabelNew("Adresse IP / Port : ")
if err != nil {
log.Fatal("Impossible de créer le label IP :", err)
}
label3, err := gtk.LabelNew("Dossier à synchroniser : ")
if err != nil {
log.Fatal("Impossible de créer le label Dossier :", err)
}
entry1, err := gtk.EntryNew()
if err != nil {
log.Fatal("Impossible de créer le champ IP :", err)
}
entry2, err := gtk.EntryNew()
if err != nil {
log.Fatal("Impossible de créer le champ Port :", err)
}
entry3, err := gtk.EntryNew()
if err != nil {
log.Fatal("Impossible de créer le champ Dossier :", err)
}
btn, err := gtk.ButtonNewWithLabel("Lancer la synchronisation")
if err != nil {
log.Fatal("Impossible de créer le bouton synchronisation :", err)
}
/*btn2, err := gtk.FileChooserButtonNew("Choix")
if err != nil {
log.Fatal("Impossible de créer le bouton choix :", err)
}*/
grid.SetOrientation(gtk.ORIENTATION_HORIZONTAL)
//Attach(child IWidget, left, top, width, height int)
grid.Add(label1)
grid.SetOrientation(gtk.ORIENTATION_HORIZONTAL)
grid.Add(entry1)
grid.Add(entry2)
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
grid.Add(label3)
grid.Add(entry3)
grid.Attach(btn, 1, 2, 1, 2)
btn.Connect("clicked", func() {
/*dialog, _ := gtk.DialogNew()
filechooser, _ := gtk.FileChooserWidgetNew(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
dialog.AddButton("Valider", gtk.RESPONSE_ACCEPT)
dialog.AddButton("Annuler", gtk.RESPONSE_CANCEL)
dialog.SetTitle("Choisir le dossier a synchroniser")
box, _ := dialog.GetContentArea()
box.Add(filechooser)
box.ShowAll()
log.Print("Clic lancer synchro")*/
filechooserdialog, _ := gtk.FileChooserDialogNewWith1Button(
"Choisissez un fichier ...",
//btn.GetTopLevelAsWindow(),
win,
gtk.FILE_CHOOSER_ACTION_OPEN,
"Valider",
gtk.RESPONSE_ACCEPT)
/*filter := gtk.NewFileFilter()
filter.AddPattern("*.go")
filechooserdialog.AddFilter(filter)*/
filechooserdialog.Response(func() {
println(filechooserdialog.GetFilename())
filechooserdialog.Destroy()
})
filechooserdialog.Run()
})
/*
nbChildAll, err := gtk.LabelNew("Tous mes fichiers sont ici")
if err != nil {
log.Fatal("Unable to create button:", err)
}
nbTabAll, err := gtk.LabelNew("Tout")
if err != nil {
log.Fatal("Unable to create label:", err)
}
//.........这里部分代码省略.........
开发者ID:adrien3d,项目名称:gobox,代码行数:101,代码来源:gtk3.go
示例15: Window
// Window creates a *gtk.Window.
func Window(t gtk.WindowType) *gtk.Window {
w, _ := gtk.WindowNew(t)
return w
}
开发者ID:sqp,项目名称:godock,代码行数:5,代码来源:newgtk.go
示例16: 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:adrien3d,项目名称:gobox,代码行数:99,代码来源:grid.go
注:本文中的github.com/gotk3/gotk3/gtk.WindowNew函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论