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


Golang MenuItem.Connect方法代码示例

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


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

示例1: createMenu

func createMenu() *gtk.MenuBar {
	menubar := gtk.NewMenuBar()
	vpaned := gtk.NewVPaned()

	//--------------------------------------------------------
	// GtkMenuItem
	//--------------------------------------------------------
	cascademenu := gtk.NewMenuItemWithMnemonic("_File")
	menubar.Append(cascademenu)
	submenu := gtk.NewMenu()
	cascademenu.SetSubmenu(submenu)

	var menuitem *gtk.MenuItem
	menuitem = gtk.NewMenuItemWithMnemonic("E_xit")
	menuitem.Connect("activate", func() {
		gtk.MainQuit()
	})
	submenu.Append(menuitem)

	cascademenu = gtk.NewMenuItemWithMnemonic("_View")
	menubar.Append(cascademenu)
	submenu = gtk.NewMenu()
	cascademenu.SetSubmenu(submenu)

	checkmenuitem := gtk.NewCheckMenuItemWithMnemonic("_Disable")
	checkmenuitem.Connect("activate", func() {
		vpaned.SetSensitive(!checkmenuitem.GetActive())
	})
	submenu.Append(checkmenuitem)

	cascademenu = gtk.NewMenuItemWithMnemonic("_Help")
	menubar.Append(cascademenu)
	submenu = gtk.NewMenu()
	cascademenu.SetSubmenu(submenu)

	return menubar
}
开发者ID:paua-app,项目名称:curly-octo-moo,代码行数:37,代码来源:test002.go

示例2: main

func main() {
	var menuitem *gtk.MenuItem
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GTK Go!")
	window.SetIconName("gtk-dialog-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "foo")

	//--------------------------------------------------------
	// GtkVBox
	//--------------------------------------------------------
	vbox := gtk.NewVBox(false, 1)

	//--------------------------------------------------------
	// GtkMenuBar
	//--------------------------------------------------------
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	//--------------------------------------------------------
	// GtkVPaned
	//--------------------------------------------------------
	vpaned := gtk.NewVPaned()
	vbox.Add(vpaned)

	//--------------------------------------------------------
	// GtkFrame
	//--------------------------------------------------------
	frame1 := gtk.NewFrame("Demo")
	framebox1 := gtk.NewVBox(false, 1)
	frame1.Add(framebox1)

	frame2 := gtk.NewFrame("Demo")
	framebox2 := gtk.NewVBox(false, 1)
	frame2.Add(framebox2)

	vpaned.Pack1(frame1, false, false)
	vpaned.Pack2(frame2, false, false)

	//--------------------------------------------------------
	// GtkImage
	//--------------------------------------------------------
	dir, _ := path.Split(os.Args[0])
	imagefile := path.Join(dir, "../../data/go-gtk-logo.png")

	label := gtk.NewLabel("Go Binding for GTK")
	label.ModifyFontEasy("DejaVu Serif 15")
	framebox1.PackStart(label, false, true, 0)

	//--------------------------------------------------------
	// GtkEntry
	//--------------------------------------------------------
	entry := gtk.NewEntry()
	entry.SetText("Hello world")
	framebox1.Add(entry)

	image := gtk.NewImageFromFile(imagefile)
	framebox1.Add(image)

	//--------------------------------------------------------
	// GtkScale
	//--------------------------------------------------------
	scale := gtk.NewHScaleWithRange(0, 100, 1)
	scale.Connect("value-changed", func() {
		println("scale:", int(scale.GetValue()))
	})
	framebox2.Add(scale)

	//--------------------------------------------------------
	// GtkHBox
	//--------------------------------------------------------
	buttons := gtk.NewHBox(false, 1)

	//--------------------------------------------------------
	// GtkButton
	//--------------------------------------------------------
	button := gtk.NewButtonWithLabel("Button with label")
	button.Clicked(func() {
		println("button clicked:", button.GetLabel())
		messagedialog := gtk.NewMessageDialog(
			button.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			entry.GetText())
		messagedialog.Response(func() {
			println("Dialog OK!")

			//--------------------------------------------------------
			// GtkFileChooserDialog
			//--------------------------------------------------------
			filechooserdialog := gtk.NewFileChooserDialog(
				"Choose File...",
				button.GetTopLevelAsWindow(),
				gtk.FILE_CHOOSER_ACTION_OPEN,
				gtk.STOCK_OK,
//.........这里部分代码省略.........
开发者ID:JessonChan,项目名称:go-gtk,代码行数:101,代码来源:demo.go

示例3: InitializeGUI

//InitializeGUI es la funcion que inicializa y ejecuta todo el entorno gráfico de la aplicacion
func (p *Gui) InitializeGUI(errorstr string, file *os.File) {
	gtk.Init(nil)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.Maximize()
	window.SetTitle("Go-SIC ASM/SIM!")
	window.SetIconName("gtk-dialog-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		fmt.Println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "foo")

	//--------------------------------------------------------
	//	GTK statusbar
	//--------------------------------------------------------
	statusbar := gtk.NewStatusbar()
	context_id := statusbar.GetContextId("hola")
	//--------------------------------------------------------
	// GtkVBox
	//--------------------------------------------------------
	vbox := gtk.NewVBox(false, 1)

	//--------------------------------------------------------
	// GtkMenuBar
	//--------------------------------------------------------
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	//--------------------------------------------------------
	// GtkVPaned
	//--------------------------------------------------------
	vpaned := gtk.NewVPaned()
	vbox.Add(vpaned)

	//--------------------------------------------------------
	// GtkFrame
	//--------------------------------------------------------
	frame1 := gtk.NewFrame("Código Fuente/Archivo intermedio/TABSIM")
	framebox1 := gtk.NewVBox(false, 1)
	frame1.Add(framebox1)
	frame1.SetSizeRequest(300, 300)

	frame2 := gtk.NewFrame("Debug/Código Objeto")
	framebox2 := gtk.NewVBox(false, 1)
	frame2.Add(framebox2)

	vpaned.Pack1(frame1, false, false)
	vpaned.Pack2(frame2, false, false)

	//--------------------------------------------------------
	// GtkHBox
	//--------------------------------------------------------
	ventanasPrincipales := gtk.NewHBox(false, 1)
	//----------------------------------------------

	label := gtk.NewLabel("Ensamblador SIC SIC/XE")
	label.ModifyFontEasy("DejaVu Serif 15")
	framebox1.PackStart(label, false, true, 0)
	//--------------------------------------------------------
	// GtkTextView
	//--------------------------------------------------------
	swin := gtk.NewScrolledWindow(nil, nil)

	swin.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin.SetShadowType(gtk.SHADOW_IN)
	textview := gtk.NewTextView()

	textview.ModifyFontEasy("Sans 10")
	var start, end gtk.TextIter
	buffer := textview.GetBuffer()
	buffer.GetStartIter(&start)
	swin.Add(textview)
	ventanasPrincipales.Add(swin)
	//framebox1.Add(swin)
	//--------------------------------------------------------
	// GtkTextView
	//--------------------------------------------------------
	swin4 := gtk.NewScrolledWindow(nil, nil)

	swin4.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin4.SetShadowType(gtk.SHADOW_IN)
	textview4 := gtk.NewTextView()

	textview4.ModifyFontEasy("Sans 10")
	var start4, end4 gtk.TextIter
	buffer4 := textview4.GetBuffer()
	buffer4.GetStartIter(&start4)
	swin4.Add(textview4)
	ventanasPrincipales.Add(swin4)
	//framebox1.Add(swin)
	//--------------------------------------------------------
	// GtkTextView
	//--------------------------------------------------------
	swin5 := gtk.NewScrolledWindow(nil, nil)

	swin5.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin5.SetShadowType(gtk.SHADOW_IN)
	textview5 := gtk.NewTextView()
//.........这里部分代码省略.........
开发者ID:jatovar,项目名称:sic-xe,代码行数:101,代码来源:guinterface.go

示例4: main

func main() {
	gtk.Init(nil)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GoMADScan")
	window.SetIconName("GoMADScan-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		// fmt.Println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "")

	//--------------------------------------------------------
	// GtkVBox
	//--------------------------------------------------------
	vbox := gtk.NewVBox(false, 1)

	//--------------------------------------------------------
	// GtkMenuBar
	//--------------------------------------------------------
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	//--------------------------------------------------------
	// GtkVPaned
	//--------------------------------------------------------
	vpaned := gtk.NewVPaned()
	vbox.Add(vpaned)

	//--------------------------------------------------------
	// GtkFrame
	//--------------------------------------------------------
	frame1 := gtk.NewFrame("")
	framebox1 := gtk.NewVBox(false, 1)
	frame1.Add(framebox1)

	frame2 := gtk.NewFrame("Column index for search (0: all columns)")
	framebox2 := gtk.NewVBox(false, 1)
	frame2.Add(framebox2)

	vpaned.Pack1(frame1, false, false)
	vpaned.Pack2(frame2, false, false)

	//--------------------------------------------------------
	// GtkImage
	//--------------------------------------------------------
	dir := os.Getenv("GOPATH")
	if dir == "" {
		dir = filepath.Join(os.Getenv("HOME"), "/go")
	}
	imagefile := filepath.Join(dir, "/src/github.com/carushi/GoMADScan/image/logo.png")
	label := gtk.NewLabel("Go-based Modification associated database scanner")
	label.ModifyFontEasy("DejaVu Serif 15")
	framebox1.PackStart(label, false, true, 0)
	image := gtk.NewImageFromFile(imagefile)
	framebox1.Add(image)

	//--------------------------------------------------------
	// Data input and output filename
	//--------------------------------------------------------
	arg := arguments{
		0,
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/Sample_modification_site"),
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/Ras_gene_synonym.txt"),
		filepath.Join(dir, "/src/github.com/carushi/GoMADScan/data/output.txt"),
		false,
		true,
		"\t"}

	//--------------------------------------------------------
	// GtkScale
	//--------------------------------------------------------
	scale := gtk.NewHScaleWithRange(0, 20, 1)
	scale.Connect("value-changed", func() {
		arg.column = int(scale.GetValue())
		// fmt.Println("scale:", int(scale.GetValue()))
	})
	framebox2.Add(scale)

	//--------------------------------------------------------
	// InputArea
	//--------------------------------------------------------
	ientry := gtk.NewEntry()
	ientry.SetText(arg.inputPath)
	inputs := gtk.NewHBox(false, 1)
	button := gtk.NewButtonWithLabel("Choose input file")
	button.Clicked(func() {
		//--------------------------------------------------------
		// GtkFileChooserDialog
		//--------------------------------------------------------
		filechooserdialog := gtk.NewFileChooserDialog(
			"Choose File...",
			button.GetTopLevelAsWindow(),
			gtk.FILE_CHOOSER_ACTION_OPEN,
			gtk.STOCK_OK,
			gtk.RESPONSE_ACCEPT)
		filter := gtk.NewFileFilter()
		filter.AddPattern("*")
		filechooserdialog.AddFilter(filter)
		filechooserdialog.Response(func() {
//.........这里部分代码省略.........
开发者ID:carushi,项目名称:GoMADScan,代码行数:101,代码来源:GoMADScan.go

示例5: main

func main() {
	var menuitem *gtk.MenuItem
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("GoBox a0.1")
	window.SetIconName("gtk-dialog-info")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		println("got destroy!", ctx.Data().(string))
		gtk.MainQuit()
	}, "foo")

	//--------------------------------------------------------
	// GtkVBox
	//--------------------------------------------------------
	vbox := gtk.NewVBox(false, 1)

	//--------------------------------------------------------
	// GtkMenuBar
	//--------------------------------------------------------
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	//--------------------------------------------------------
	// GtkVPaned
	//--------------------------------------------------------
	vpaned := gtk.NewVPaned()
	vbox.Add(vpaned)

	//--------------------------------------------------------
	// GtkFrame
	//--------------------------------------------------------
	frame1 := gtk.NewFrame("Dossier et Paramètres")
	framebox1 := gtk.NewVBox(false, 1)
	frame1.Add(framebox1)

	frame2 := gtk.NewFrame("Fonctions")
	framebox2 := gtk.NewVBox(false, 1)
	frame2.Add(framebox2)

	vpaned.Pack1(frame1, false, false)
	vpaned.Pack2(frame2, false, false)

	//--------------------------------------------------------
	// GtkImage
	//--------------------------------------------------------
	/*dir, _ := path.Split(os.Args[0])
	  //imagefile := path.Join(dir, "../../mattn/go-gtk/data/go-gtk-logo.png")
	  imagefile := path.Join(dir, "./go-gtk-logo.png")
	  println(dir)*/

	label := gtk.NewLabel("GoBox a0.1")
	label.ModifyFontEasy("DejaVu Serif 15")
	framebox1.PackStart(label, false, true, 0)

	//--------------------------------------------------------
	// GtkEntry
	//--------------------------------------------------------
	champIp := gtk.NewEntry()
	champIp.SetText("10.0.0.1")
	framebox1.Add(champIp)

	champPort := gtk.NewEntry()
	champPort.SetText("80")
	framebox1.Add(champPort)

	folder := "./"

	/*image := gtk.NewImageFromFile(imagefile)
	  framebox1.Add(image)*/
	buttons := gtk.NewHBox(false, 1)
	//--------------------------------------------------------
	// GtkButton
	//--------------------------------------------------------
	button := gtk.NewButtonWithLabel("Choisir le dossier")
	button.Clicked(func() {
		//--------------------------------------------------------
		// GtkFileChooserDialog
		//--------------------------------------------------------
		filechooserdialog := gtk.NewFileChooserDialog(
			"Sélectionnez le dossier ...",
			button.GetTopLevelAsWindow(),
			gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
			gtk.STOCK_OK,
			gtk.RESPONSE_ACCEPT)
		/*filter := gtk.NewFileFilter()
		  filter.AddPattern("*.go")
		  filechooserdialog.AddFilter(filter)*/
		filechooserdialog.Response(func() {
			println(filechooserdialog.GetFilename())
			folder = filechooserdialog.GetFilename() + "/"
			filechooserdialog.Destroy()
		})
		filechooserdialog.Run()
	})
	buttons.Add(button)

	//--------------------------------------------------------
	// GtkToggleButton
	//--------------------------------------------------------
//.........这里部分代码省略.........
开发者ID:adrien3d,项目名称:gobox,代码行数:101,代码来源:gtk2.go


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