当前位置: 首页>>代码示例>>Golang>>正文


Golang gtk.Init函数代码示例

本文整理汇总了Golang中github.com/gotk3/gotk3/gtk.Init函数的典型用法代码示例。如果您正苦于以下问题:Golang Init函数的具体用法?Golang Init怎么用?Golang Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()
}
开发者ID:ezoic,项目名称:webloop,代码行数:7,代码来源:webloop_test.go

示例2: 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

示例3: NewGTK

// NewGTK returns a new client for a GTK ui
func NewGTK(version string) UI {
	coyimVersion = version
	//*.mo files should be in ./i18n/locale_code.utf8/LC_MESSAGES/
	glib.InitI18n("coy", "./i18n")
	gtk.Init(argsWithApplicationName())

	ret := &gtkUI{
		commands: make(chan interface{}, 5),
		toggleConnectAllAutomaticallyRequest: make(chan bool, 100),
		setShowAdvancedSettingsRequest:       make(chan bool, 100),
	}

	var err error
	flags := glib.APPLICATION_FLAGS_NONE
	if *config.MultiFlag {
		flags = glib.APPLICATION_NON_UNIQUE
	}
	ret.app, err = gtk.ApplicationNew("im.coy.CoyIM", flags)
	if err != nil {
		panic(err)
	}

	ret.keySupplier = config.CachingKeySupplier(ret.getMasterPassword)

	ret.accountManager = newAccountManager(ret)

	return ret
}
开发者ID:tanujmathur,项目名称:coyim,代码行数:29,代码来源:ui.go

示例4: Example

func Example() {
	gtk.Init(nil)
	go func() {
		runtime.LockOSThread()
		gtk.Main()
	}()

	ctx := webloop.New()
	view := ctx.NewView()
	defer view.Close()
	view.Open("http://google.com")
	err := view.Wait()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to load URL: %s", err)
		os.Exit(1)
	}
	res, err := view.EvaluateJavaScript("document.title")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to run JavaScript: %s", err)
		os.Exit(1)
	}
	fmt.Printf("JavaScript returned: %q\n", res)
	// output:
	// JavaScript returned: "Google"
}
开发者ID:pasangsherpa,项目名称:webloop,代码行数:25,代码来源:example_test.go

示例5: main

func main() {
	gtk.Init(nil)
	window := ui.NewMainWindow()
	window.Window.ShowAll()

	gtk.Main()
}
开发者ID:juanfgs,项目名称:checkers,代码行数:7,代码来源:main.go

示例6: main

func main() {
	gtk.Init(nil)
	initIcons()

	win := setupWindow("Go Example Testreport")

	var iter1, iter2 *gtk.TreeIter

	treeView, treeStore := setupTreeView()
	win.Add(treeView)

	// Add some rows to the tree store
	iter1 = addRow(treeStore, imageOK, "Testsuite 1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-1")
	addSubRow(treeStore, iter2, imageOK, "test1-2-2")
	addSubRow(treeStore, iter2, imageOK, "test1-2-3")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test1-3")
	iter1 = addRow(treeStore, imageFAIL, "Testsuite 2")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-1")
	iter2 = addSubRow(treeStore, iter1, imageOK, "test2-2")
	iter2 = addSubRow(treeStore, iter1, imageFAIL, "test2-3")
	addSubRow(treeStore, iter2, imageOK, "test2-3-1")
	addSubRow(treeStore, iter2, imageFAIL, "test2-3-2")

	win.ShowAll()
	gtk.Main()
}
开发者ID:yamnikov-oleg,项目名称:gotk3-examples,代码行数:29,代码来源:treeview2.go

示例7: main

func main() {
	gtk.Init(nil)
	go func() {
		appdbus.StandAlone(TVPlay.NewApplet)
		gtk.MainQuit()
	}()
	gtk.Main()
}
开发者ID:sqp,项目名称:godock,代码行数:8,代码来源:applet.go

示例8: StartGTK

// StartGTK ensures that the GTK+ main loop has started. If it has already been
// started by StartGTK, it will not start it again. If another goroutine is
// already running the GTK+ main loop, StartGTK's behavior is undefined.
func (h *StaticRenderer) StartGTK() {
	startGTKOnce.Do(func() {
		gtk.Init(nil)
		go func() {
			runtime.LockOSThread()
			gtk.Main()
		}()
	})
}
开发者ID:ezoic,项目名称:webloop,代码行数:12,代码来源:static_renderer.go

示例9: InitGtk

// InitGtk provides GTK start and stop callbacks.
//
func InitGtk() (onstart, onstop func()) {
	gtkStart := func() {

		GRRTHREADS()

		// runtime.LockOSThread()
		gtk.Init(nil)
		gtk.Main()
	}
	return gtkStart, gtk.MainQuit
}
开发者ID:sqp,项目名称:godock,代码行数:13,代码来源:common.go

示例10: 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

示例11: 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

示例12: TestConfig

func TestConfig(t *testing.T) {
	gtk.Init(nil)

	build := vdata.TestInit(vdata.New(log.NewLog(log.Logs), nil, nil), vdata.PathTestConf())
	if build == nil {
		return
	}
	build.BuildAll(pageswitch.New())

	assert.Equal(t, countChanged(t, build), 0, "Build unchanged")

	build.KeyWalk(vdata.TestValues)
	assert.Equal(t, countChanged(t, build), 32, "Build full change")
}
开发者ID:sqp,项目名称:godock,代码行数:14,代码来源:build_test.go

示例13: main

func main() {
	gtk.Init(nil)

	win := setup_window(winTitle)

	box := newStackFull()
	win.Add(box)

	// 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:gotk3,项目名称:gotk3-examples,代码行数:15,代码来源:stack.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.Connect("destroy", func() {
		gtk.MainQuit()
	})

	win.Add(windowWidget())
	win.ShowAll()

	gtk.Main()
}
开发者ID:adrien3d,项目名称:gobox,代码行数:16,代码来源:signals.go

示例15: Test_builderForDefinition_useGoFileIfXMLDoesntExists

func (s *UIReaderSuite) Test_builderForDefinition_useGoFileIfXMLDoesntExists(c *C) {
	gtk.Init(nil)
	removeFile("definitions/Test.xml")
	//writeTestFile("definitions/TestDefinition.xml", testFile)
	ui := "Test"

	builder := builderForDefinition(ui)

	win, getErr := builder.GetObject("conversation")
	if getErr != nil {
		fmt.Errorf("\nFailed to get window \n%s", getErr.Error())
		c.Fail()
	}
	w, h := win.(*gtk.Window).GetSize()
	c.Assert(h, Equals, 500)
	c.Assert(w, Equals, 400)
}
开发者ID:PMaynard,项目名称:coyim,代码行数:17,代码来源:ui_reader_test.go


注:本文中的github.com/gotk3/gotk3/gtk.Init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。