• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gtk.Init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initPage

func initPage(title string, uri string, size_x int, size_y int) {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle(title)
	window.Connect("destroy", gtk.MainQuit)

	vbox := gtk.NewVBox(false, 1)

	swin := gtk.NewScrolledWindow(nil, nil)
	swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin.SetShadowType(gtk.SHADOW_IN)

	webview := webkit.NewWebView()
	webview.LoadUri(uri)
	swin.Add(webview)

	vbox.Add(swin)

	window.Add(vbox)
	window.SetSizeRequest(size_x, size_y)
	window.ShowAll()

	proxy := os.Getenv("HTTP_PROXY")
	if len(proxy) > 0 {
		soup_uri := webkit.SoupUri(proxy)
		webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
		soup_uri.Free()
	}
	gtk.Main()
}
开发者ID:nnoco,项目名称:GoLiathChat,代码行数:30,代码来源:Goliath.go


示例2: main

func main() {
	gtk.Init(&os.Args)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Arrow Buttons")
	window.Connect("destroy", gtk.MainQuit)

	box := gtk.NewHBox(false, 0)
	box.Show()
	window.Add(box)

	up := createArrowButton(gtk.ARROW_UP, gtk.SHADOW_IN)
	down := createArrowButton(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
	left := createArrowButton(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
	right := createArrowButton(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)

	box.PackStart(up, false, false, 3)
	box.PackStart(down, false, false, 3)
	box.PackStart(left, false, false, 3)
	box.PackStart(right, false, false, 3)

	up.Clicked(func() { println("↑") })
	down.Clicked(func() { println("↓") })
	left.Clicked(func() { println("←") })
	right.Clicked(func() { println("→") })

	window.Show()
	gtk.Main()
}
开发者ID:mattn,项目名称:go-gtk,代码行数:29,代码来源:arrow.go


示例3: main

func main() {
	gtk.Init(&os.Args)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("GTK Stock Icons")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.ScrolledWindow(nil, nil)

	store := gtk.ListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetGdkPixbufType())
	treeview := gtk.TreeView()
	swin.Add(treeview)

	treeview.SetModel(store.ToTreeModel())
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("name", gtk.CellRendererText(), "text", 0))
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("check", gtk.CellRendererToggle(), "active", 1))
	treeview.AppendColumn(gtk.TreeViewColumnWithAttributes("icon", gtk.CellRendererPixbuf(), "pixbuf", 2))
	n := 0
	gtk.GtkStockListIDs().ForEach(func(d interface{}, v interface{}) {
		id := glib.GPtrToString(d)
		var iter gtk.GtkTreeIter
		store.Append(&iter)
		store.Set(&iter, id, (n == 1), gtk.Image().RenderIcon(id, gtk.GTK_ICON_SIZE_SMALL_TOOLBAR, "").Pixbuf)
		n = 1 - n
	})

	window.Add(swin)
	window.SetSizeRequest(400, 200)
	window.ShowAll()

	gtk.Main()
}
开发者ID:caengcjd,项目名称:go-gtk,代码行数:31,代码来源:listview.go


示例4: main

func main() {

	gtk.Init(&os.Args)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)

	window.Connect("delete-event", func() {
		println("Delete-event occured\n")
	})

	window.Connect("destroy", func() { gtk.MainQuit() })

	button := gtk.ButtonWithLabel("Hello, World")

	button.Clicked(func() {
		println("Hello, World\n")
	})

	button.Clicked(func() {
		gtk.MainQuit()
	})

	window.Add(button)
	window.ShowAll()
	gtk.Main()
}
开发者ID:Dearth,项目名称:Character_Sheet,代码行数:25,代码来源:test.go


示例5: main

func main() {
	glib.ThreadInit(nil)
	gdk.ThreadsInit()
	gtk.Init(nil)
	runGUI([]string{os.Getenv("SHELL")})

}
开发者ID:nlamirault,项目名称:mert,代码行数:7,代码来源:mert.go


示例6: board_display

func board_display() {
	gtk.Init(&os.Args)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("Gomoku")
	window.SetResizable(false)
	window.Connect("destroy", gtk.MainQuit)

	player = 1
	game = Gomoku{make([]int, 361), true, false, false, 1, [2]int{10, 10}, 0}

	vbox := gtk.NewVBox(false, 1)

	menu_bar(vbox)
	configure_board(vbox)
	status_bar(vbox)

	hintx, hinty, lastx, lasty = -1, -1, -1, -1

	go calc_hint()

	window.Add(vbox)
	window.SetSizeRequest(WIDTH+40, HEIGHT+50)
	window.ShowAll()
	gtk.Main()
}
开发者ID:Khady,项目名称:gomoku,代码行数:26,代码来源:display.go


示例7: initWebView

func initWebView() *webkit.WebView {
	gtk.Init(nil)
	webview := webkit.NewWebView()
	webview.Connect("load-error", func() {
		fmt.Printf("Load Error: %s\n", webview.GetUri())
	})
	webview.Connect("onload-event", func() {
		fmt.Printf("Onload Event: %s\n", webview.GetUri())
	})
	webview.Connect("resource-load-finished", func(wv interface{}) {
		fmt.Printf("Resource Load Finished: %v\n", wv)
	})
	webview.Connect("load-committed", func() {
		//entry.SetText(webview.GetUri())
		fmt.Printf("Load Committed: %s\n", webview.GetUri())
	})
	webview.Connect("load-finished", func() {
		//entry.SetText(webview.GetUri())
		fmt.Printf("Load Finished: %s\n", webview.GetUri())
		//time.Sleep(time.Second)
		title := webview.GetTitle()
		webview.ExecuteScript("document.title=document.documentElement.innerHTML")
		str := webview.GetTitle()
		webview.ExecuteScript("document.title=" + title)
		fmt.Printf("Html: %s\n", str)
		gtk.MainQuit()
	})

	webview.LoadHtmlString(HTML_STRING, ".")
	gtk.Main()
	return webview
}
开发者ID:zackb,项目名称:code,代码行数:32,代码来源:webkit.go


示例8: main

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("Hello GTK+Go world!")
	window.SetIconName("gtk-dialog-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		gtk.MainQuit()
	}, "foo")
	vbox := gtk.NewVBox(false, 1)
	button := gtk.NewButtonWithLabel("Hello world!")
	button.SetTooltipMarkup("Say Hello World to everybody!")
	button.Clicked(func() {
		messagedialog := gtk.NewMessageDialog(
			button.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			"Hello!")
		messagedialog.Response(func() {
			messagedialog.Destroy()
		})
		messagedialog.Run()
	})
	vbox.PackStart(button, false, false, 0)
	window.Add(vbox)
	window.SetSizeRequest(300, 50)
	window.ShowAll()
	gtk.Main()
}
开发者ID:olecya,项目名称:goeg,代码行数:30,代码来源:golang_hello.go


示例9: main

func main() {
	gtk.Init(nil)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("Clock")
	vbox := gtk.VBox(false, 1)
	label := gtk.Label("")
	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:postfix,项目名称:go-uv,代码行数:28,代码来源:gui.go


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


示例11: main

func main() {
	gtk.Init(&os.Args)

	glib.SetApplicationName("go-gtk-statusicon-example")

	mi := gtk.NewMenuItemWithLabel("Popup!")
	mi.Connect("activate", func() {
		gtk.MainQuit()
	})
	nm := gtk.NewMenu()
	nm.Append(mi)
	nm.ShowAll()

	si := gtk.NewStatusIconFromStock(gtk.STOCK_FILE)
	si.SetTitle("StatusIcon Example")
	si.SetTooltipMarkup("StatusIcon Example")
	si.Connect("popup-menu", func(cbx *glib.CallbackContext) {
		nm.Popup(nil, nil, gtk.StatusIconPositionMenu, si, uint(cbx.Args(0)), uint(cbx.Args(1)))
	})

	println(`
Can you see statusicon in systray?
If you don't see it and if you use 'unity', try following.

# gsettings set com.canonical.Unity.Panel systray-whitelist \
  "$(gsettings get com.canonical.Unity.Panel systray-whitelist \|
  sed -e "s/]$/, 'go-gtk-statusicon-example']/")"
`)

	gtk.Main()
}
开发者ID:JessonChan,项目名称:go-gtk,代码行数:31,代码来源:statusicon.go


示例12: main

func main() {
	gtk.Init(&os.Args)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("GTK Icon View")
	window.Connect("destroy", gtk.MainQuit)

	swin := gtk.NewScrolledWindow(nil, nil)

	store := gtk.NewListStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING)
	iconview := gtk.NewIconViewWithModel(store)
	iconview.SetPixbufColumn(0)
	iconview.SetTextColumn(1)
	swin.Add(iconview)

	gtk.StockListIDs().ForEach(func(d unsafe.Pointer, v interface{}) {
		id := glib.GPtrToString(d)
		var iter gtk.TreeIter
		store.Append(&iter)
		store.Set(&iter,
			gtk.NewImage().RenderIcon(id, gtk.ICON_SIZE_SMALL_TOOLBAR, "").GPixbuf,
			id)
	})

	window.Add(swin)
	window.SetSizeRequest(500, 200)
	window.ShowAll()

	gtk.Main()
}
开发者ID:pocke,项目名称:go-gtk,代码行数:29,代码来源:iconview.go


示例13: main

func main() {
	gtk.Init(nil)
	window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
	window.SetTitle("Click me")
	label := gtk.Label("There have been no clicks yet")
	var clicks int
	button := gtk.ButtonWithLabel("click me")
	button.Clicked(func() {
		clicks++
		if clicks == 1 {
			label.SetLabel("Button clicked 1 time")
		} else {
			label.SetLabel(fmt.Sprintf("Button clicked %d times",
				clicks))
		}
	})
	vbox := gtk.VBox(false, 1)
	vbox.Add(label)
	vbox.Add(button)
	window.Add(vbox)
	window.Connect("destroy", func() {
		gtk.MainQuit()
	})
	window.ShowAll()
	gtk.Main()
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:26,代码来源:simple-windowed-application.go


示例14: main

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("webkit")
	window.Connect("destroy", gtk.MainQuit)

	vbox := gtk.NewVBox(false, 1)

	entry := gtk.NewEntry()
	entry.SetText("http://golang.org/")
	vbox.PackStart(entry, false, false, 0)

	swin := gtk.NewScrolledWindow(nil, nil)
	swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin.SetShadowType(gtk.SHADOW_IN)

	webview := webkit.NewWebView()
	webview.Connect("load-committed", func() {
		entry.SetText(webview.GetUri())
	})
	swin.Add(webview)

	vbox.Add(swin)

	entry.Connect("activate", func() {
		webview.LoadUri(entry.GetText())
	})
	button := gtk.NewButtonWithLabel("load String")
	button.Clicked(func() {
		webview.LoadString("hello Go GTK!", "text/plain", "utf-8", ".")
	})
	vbox.PackStart(button, false, false, 0)

	button = gtk.NewButtonWithLabel("load HTML String")
	button.Clicked(func() {
		webview.LoadHtmlString(HTML_STRING, ".")
	})
	vbox.PackStart(button, false, false, 0)

	button = gtk.NewButtonWithLabel("Google Maps")
	button.Clicked(func() {
		webview.LoadHtmlString(MAP_EMBED, ".")
	})
	vbox.PackStart(button, false, false, 0)

	window.Add(vbox)
	window.SetSizeRequest(600, 600)
	window.ShowAll()

	proxy := os.Getenv("HTTP_PROXY")
	if len(proxy) > 0 {
		soup_uri := webkit.SoupUri(proxy)
		webkit.GetDefaultSession().Set("proxy-uri", soup_uri)
		soup_uri.Free()
	}
	entry.Emit("activate")
	gtk.Main()
}
开发者ID:bright-sparks,项目名称:go-webkit,代码行数:58,代码来源:webview.go


示例15: main

func main() {
	mc := memcache.New("127.0.0.1:11211")

	gtk.Init(nil)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("memcachedclient")
	window.Connect("destroy", gtk.MainQuit)

	vbox := gtk.NewVBox(false, 1)

	swin := gtk.NewScrolledWindow(nil, nil)
	textview := gtk.NewTextView()
	textview.SetEditable(false)
	textview.SetCursorVisible(false)
	textview.ModifyFontEasy("monospace 12")
	swin.Add(textview)
	vbox.Add(swin)

	buffer := textview.GetBuffer()

	input := gtk.NewEntry()
	input.SetEditable(true)
	vbox.PackEnd(input, false, false, 0)

	tag := buffer.CreateTag("red", map[string]string{"foreground": "#FF0000"})
	input.Connect("activate", func() {
		var iter gtk.TextIter
		tokens := strings.SplitN(input.GetText(), " ", 3)
		if len(tokens) == 2 && strings.ToUpper(tokens[0]) == "GET" {
			if t, err := mc.Get(tokens[1]); err == nil {
				buffer.GetEndIter(&iter)
				buffer.Insert(&iter, string(t.Value)+"\n")
			} else {
				buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
			}
			input.SetText("")
		} else if len(tokens) == 3 && strings.ToUpper(tokens[0]) == "SET" {
			if err := mc.Set(
				&memcache.Item{
					Key:   tokens[1],
					Value: []byte(tokens[2]),
				}); err == nil {
				buffer.GetEndIter(&iter)
				buffer.InsertWithTag(&iter, "OK\n", tag)
			} else {
				buffer.InsertWithTag(&iter, err.Error()+"\n", tag)
			}
			input.SetText("")
		}
	})
	input.GrabFocus()

	window.Add(vbox)
	window.SetSizeRequest(300, 500)
	window.ShowAll()
	gtk.Main()
}
开发者ID:mattn,项目名称:memcachedclient,代码行数:58,代码来源:memcachedclient.go


示例16: main

func main() {
	gtk.Init(nil)
	gdk.ThreadsInit()
	MainGui.buildSplash()
	MainGui.buildGUI()
	MainGui.SplashWindow.ShowAll()
	go unlinked_main()
	gtk.Main()
}
开发者ID:spaghetty,项目名称:gunnify,代码行数:9,代码来源:gunnify.go


示例17: trayIconInit

func trayIconInit() *gtk.StatusIcon {
	gtk.Init(nil)
	glib.SetApplicationName("gobatt")

	icon := gtk.NewStatusIcon()
	icon.SetTitle("gobatt")

	return icon
}
开发者ID:solusipse,项目名称:gobatt,代码行数:9,代码来源:gobatt.go


示例18: main

func main() {
	if false == init_args() {
		return
	}
	load_options()
	defer save_options()
	gtk.Init(nil)
	init_tabby()
	gtk.Main()
}
开发者ID:mattn,项目名称:tabby,代码行数:10,代码来源:main.go


示例19: main

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("Hello world!")
	window.SetIconName("Hello go!")
	window.Connect("destroy", gtk.MainQuit)
	window.SetSizeRequest(800, 800)
	window.ShowAll()
	gtk.Main()
}
开发者ID:davidamin,项目名称:VanGo,代码行数:11,代码来源:window.go


示例20: main

func main() {
	gtk.Init(nil)
	window := CreateWindow()
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		fmt.Println("destroy pending...")
		gtk.MainQuit()
	}, "foo")
	window.ShowAll()
	gtk.Main()
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:11,代码来源:action.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gtk.Main函数代码示例发布时间:2022-05-23
下一篇:
Golang glib.GValue类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap