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

Golang gtk.NewEntry函数代码示例

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

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



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

示例1: accountWindow

func accountWindow() {
	// window settings
	window_account := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window_account.SetPosition(gtk.WIN_POS_CENTER)
	window_account.SetTitle("Add Account")

	// main container
	container_main := gtk.NewVBox(false, 10)
	container_user := gtk.NewHBox(false, 0)
	container_pass := gtk.NewHBox(false, 0)
	container_buttons := gtk.NewHBox(false, 5)
	container_main.SetBorderWidth(10)

	// username
	user_label := gtk.NewLabel("Username")
	user_entry := gtk.NewEntry()

	// password
	pass_label := gtk.NewLabel("Password")
	pass_entry := gtk.NewEntry()
	pass_entry.SetVisibility(false)

	// login and cancel buttons
	button_login := gtk.NewButtonWithLabel("Add")
	button_cancel := gtk.NewButtonWithLabel("Cancel")

	// login
	button_login.Clicked(func() {
		username := user_entry.GetText()
		password := pass_entry.GetText()
		profile, err := CreateProfile(username, password)
		if err == nil && profile != nil {
			println("[*] Login successful")
			window_account.Destroy()
		}
	})

	// cancel
	button_cancel.Clicked(func() {
		window_account.Destroy()
	})

	// add elements to containers
	container_buttons.Add(button_login)
	container_buttons.Add(button_cancel)
	container_user.PackStart(user_label, false, false, 20)
	container_user.PackEnd(user_entry, true, true, 1)
	container_pass.PackStart(pass_label, false, false, 20)
	container_pass.PackEnd(pass_entry, true, true, 1)
	container_main.PackStart(container_user, false, false, 1)
	container_main.PackStart(container_pass, false, false, 1)
	container_main.PackStart(container_buttons, false, false, 1)

	window_account.Add(container_main)
	window_account.SetSizeRequest(350, 150)
	window_account.SetResizable(false)
	window_account.ShowAll()
}
开发者ID:kisom,项目名称:socialgopher,代码行数:58,代码来源:app.go


示例2: NewBrowser

// NewBrowser returns a new browser component
func NewBrowser(uri string) *Browser {
	vbox := gtk.NewVBox(false, 1)

	urlBarEntry := gtk.NewEntry()
	urlBarEntry.SetText(uri)
	urlBarEntry.GrabFocus()
	vbox.PackStart(urlBarEntry, false, false, 0)

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

	webview := webkit.NewWebView()
	swin.Add(webview)
	vbox.Add(swin)

	// urlBarEntry.Connect("activate", func() {
	// 	webview.LoadUri(urlBarEntry.GetText())
	// })
	//return vbox
	browser := &Browser{
		VBox:     vbox,
		WebView:  webview,
		URLEntry: urlBarEntry,
		Link:     "",
	}
	browser.connectSignals()
	urlBarEntry.Emit("activate")
	return browser
}
开发者ID:nlamirault,项目名称:actarus,代码行数:31,代码来源:tab.go


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


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


示例5: newBiomeEditFrame

func newBiomeEditFrame() *biomeEditFrame {
	frm := &biomeEditFrame{
		Frame:         gtk.NewFrame("Edit Biome"),
		applyBtn:      gtk.NewButtonWithLabel("Apply"),
		idInput:       gtk.NewEntry(),
		snowLineInput: gtk.NewEntry(),
		nameInput:     gtk.NewEntry(),
		colorInput:    gtk.NewColorButton(),
	}

	frm.idInput.SetSizeRequest(40, -1)
	frm.snowLineInput.SetSizeRequest(40, -1)

	frm.idInput.Connect("changed", frm.unlockApply)
	frm.nameInput.Connect("changed", frm.unlockApply)
	frm.snowLineInput.Connect("changed", frm.unlockApply)
	frm.applyBtn.SetSensitive(false)

	vbox := gtk.NewVBox(false, 0)
	hbox := gtk.NewHBox(false, 0)

	frm.idInput.SetTooltipText("The data value of the Biome [0-255]")
	frm.snowLineInput.SetTooltipText(fmt.Sprintf("Height (Y coordinate) at which snowfall starts (-1 or %d for no snowfall, 0 for always snowy)", mcmap.ChunkSizeY))

	hbox.PackStart(gtk.NewLabel("Color:"), false, false, 0)
	hbox.PackStart(frm.colorInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("ID:"), false, false, 0)
	hbox.PackStart(frm.idInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("Snowline:"), false, false, 0)
	hbox.PackStart(frm.snowLineInput, false, false, 3)
	hbox.PackStart(gtk.NewLabel("Name:"), false, false, 0)
	hbox.PackStart(frm.nameInput, true, true, 3)

	vbox.PackStart(hbox, false, false, 0)
	vbox.PackStart(frm.applyBtn, false, false, 3)
	frm.Add(vbox)

	frm.applyBtn.Connect("clicked", frm.doApply)

	return frm
}
开发者ID:kch42,项目名称:biomed,代码行数:41,代码来源:biome_info_editor.go


示例6: guiMain

func guiMain(ch <-chan Accounts) {
	glib.ThreadInit(nil)
	gdk.ThreadsInit()
	gdk.ThreadsEnter()
	gtk.Init(&os.Args)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("password")
	window.Connect("destroy", gtk.MainQuit)

	entry := gtk.NewEntry()

	store := gtk.NewListStore(glib.G_TYPE_STRING)
	treeview := gtk.NewTreeView()
	treeview.SetModel(store)
	// treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("icon", gtk.NewCellRendererPixbuf(), "pixbuf", 0))
	treeview.AppendColumn(gtk.NewTreeViewColumnWithAttributes("name", gtk.NewCellRendererText(), "text", 0))

	go func() {
		for accounts := range ch {
			gthread(func() {
				store.Clear()
				for _, a := range accounts {
					var iter gtk.TreeIter
					store.Append(&iter)
					store.Set(&iter, 0, a.Name)
				}
			})
		}
	}()

	swin := gtk.NewScrolledWindow(nil, nil)
	swin.Add(treeview)

	vbox := gtk.NewVBox(false, 0)
	vbox.PackStart(entry, false, false, 1)
	vbox.PackStart(swin, true, true, 0)

	window.Add(vbox)

	window.SetSizeRequest(460, 640)
	window.SetResizable(false)
	window.ShowAll()
}
开发者ID:pocke,项目名称:password,代码行数:45,代码来源:gui.go


示例7: main

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

	dialog := gtk.NewDialog()
	dialog.SetTitle("number input")

	vbox := dialog.GetVBox()

	label := gtk.NewLabel("Numnber:")
	vbox.Add(label)

	input := gtk.NewEntry()
	input.SetEditable(true)
	vbox.Add(input)

	input.Connect("insert-text", func(ctx *glib.CallbackContext) {
		a := (*[2000]uint8)(unsafe.Pointer(ctx.Args(0)))
		p := (*int)(unsafe.Pointer(ctx.Args(2)))
		i := 0
		for a[i] != 0 {
			i++
		}
		s := string(a[0:i])
		if s == "." {
			if *p == 0 {
				input.StopEmission("insert-text")
			}
		} else {
			_, err := strconv.ParseFloat(s, 64)
			if err != nil {
				input.StopEmission("insert-text")
			}
		}
	})

	button := gtk.NewButtonWithLabel("OK")
	button.Connect("clicked", func() {
		println(input.GetText())
		gtk.MainQuit()
	})
	vbox.Add(button)

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


示例8: main

func main() {
	gtk.Init(&os.Args)
	display = gtk.NewEntry()
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Simple Go Calculator")
	window.Connect("destroy", Quit, nil)

	// Vertical box containing all components
	vbox := gtk.NewVBox(false, 1)

	// Menu bar
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	// Add calculator display to vertical box
	display.SetCanFocus(false) // disable focus on calcuator display
	display.SetText("0")
	display.SetAlignment(1.0) //align text to right
	vbox.Add(display)

	// Menu items
	filemenu := gtk.NewMenuItemWithMnemonic("_File")
	menubar.Append(filemenu)
	filesubmenu := gtk.NewMenu()
	filemenu.SetSubmenu(filesubmenu)

	aboutmenuitem := gtk.NewMenuItemWithMnemonic("_About")
	aboutmenuitem.Connect("activate", func() {
		messagedialog := gtk.NewMessageDialog(
			window.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			"Simple Go Calculator")
		messagedialog.Response(func() {}, nil)
		messagedialog.Run()
		messagedialog.Destroy()
	},
		nil)
	filesubmenu.Append(aboutmenuitem)

	resetmenuitem := gtk.NewMenuItemWithMnemonic("_Reset")
	resetmenuitem.Connect("activate", func() { Reset(); display.SetText("0") }, nil)
	filesubmenu.Append(resetmenuitem)

	exitmenuitem := gtk.NewMenuItemWithMnemonic("E_xit")
	exitmenuitem.Connect("activate", Quit, nil)
	filesubmenu.Append(exitmenuitem)

	// Vertical box containing all buttons
	buttons := gtk.NewVBox(false, 5)

	for i := 0; i < 4; i++ {
		hbox := gtk.NewHBox(false, 5) // a horizontal box for each 4 buttons
		for j := 0; j < 4; j++ {
			b := gtk.NewButtonWithLabel(string(nums[i*4+j]))
			b.Clicked(Input(b), nil) //add click event
			hbox.Add(b)
		}
		buttons.Add(hbox) // add horizonatal box to vertical buttons' box
	}

	vbox.Add(buttons)

	window.Add(vbox)
	window.SetSizeRequest(250, 250)
	window.ShowAll()
	gtk.Main()
}
开发者ID:abiosoft,项目名称:gocalc,代码行数:69,代码来源:gui.go


示例9: main

func main() {
	gtk.Init(&os.Args)
	display = gtk.NewEntry()
	display.SetAlignment(1.0)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Simple Go Calculator")
	window.Connect("destroy", Quit)

	// Vertical box containing all components
	vbox := gtk.NewVBox(false, 1)

	// Menu bar
	menubar := gtk.NewMenuBar()
	vbox.PackStart(menubar, false, false, 0)

	// Add calculator display to vertical box
	display.SetCanFocus(false) // disable focus on calcuator display
	vbox.Add(display)

	// Menu items
	filemenu := gtk.NewMenuItemWithMnemonic("_File")
	menubar.Append(filemenu)
	filesubmenu := gtk.NewMenu()
	filemenu.SetSubmenu(filesubmenu)

	aboutmenuitem := gtk.NewMenuItemWithMnemonic("_About")
	aboutmenuitem.Connect("activate", func() {
		messagedialog := gtk.NewMessageDialog(
			window.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			"Simple Go Calculator")
		messagedialog.Response(func() {})
		messagedialog.Run()
		messagedialog.Destroy()
	},
		nil)
	filesubmenu.Append(aboutmenuitem)

	resetmenuitem := gtk.NewMenuItemWithMnemonic("_Reset")
	resetmenuitem.Connect("activate", func() { Reset(); display.SetText("0") })
	filesubmenu.Append(resetmenuitem)

	exitmenuitem := gtk.NewMenuItemWithMnemonic("E_xit")
	exitmenuitem.Connect("activate", Quit)
	filesubmenu.Append(exitmenuitem)

	// Vertical box containing all buttons
	buttons := gtk.NewVBox(false, 5)

	bmap := map[string]*gtk.Button{}

	for i := 0; i < 4; i++ {
		hbox := gtk.NewHBox(false, 5) // a horizontal box for each 4 buttons
		for j := 0; j < 4; j++ {
			b := gtk.NewButtonWithLabel(string(nums[i*4+j]))
			b.Clicked(Input(b)) //add click event
			hbox.Add(b)
			bmap[string(nums[i*4+j])] = b
		}
		buttons.Add(hbox) // add horizonatal box to vertical buttons' box
	}

	vbox.Add(buttons)

	window.Connect("key-press-event", func(ctx *glib.CallbackContext) bool {
		arg := ctx.Args(0)
		kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))
		c := (string(uint8(kev.Keyval % 0xff)))
		if kev.Keyval == gdk.KEY_Return {
			c = "="
			return true
		}
		if b, ok := bmap[c]; ok {
			Input(b)()
			b.GrabFocus()
		} else if kev.Keyval == gdk.KEY_Delete {
			Reset()
			display.SetText("0")
			return true
		}
		return false
	})

	window.Add(vbox)
	window.SetSizeRequest(250, 250)
	window.ShowAll()
	gtk.Main()
}
开发者ID:mattn,项目名称:gocalc,代码行数:90,代码来源:gui.go


示例10: Login

// Login creates a GTK fullscreen window where users can log inn.
// It returns when a user successfully authenticates.
func Login(hostAPI, client string, extraMinutes, agel, ageh int) (user string, minutes int, userType string) {
	// Inital window configuration
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	defer window.Destroy()
	window.Fullscreen()
	window.SetKeepAbove(true)
	window.SetTitle("Mycel Login")

	// Build GUI
	frame := gtk.NewFrame("Logg deg på " + client)
	frame.SetLabelAlign(0.5, 0.5)
	var imageLoader *gdkpixbuf.Loader
	imageLoader, _ = gdkpixbuf.NewLoaderWithMimeType("image/png")
	imageLoader.Write(logo_png())
	imageLoader.Close()
	logo := gtk.NewImageFromPixbuf(imageLoader.GetPixbuf())
	button := gtk.NewButtonWithLabel("Logg inn")
	userlabel := gtk.NewLabel("Lånenummer/brukernavn")
	pinlabel := gtk.NewLabel("PIN-kode/passord")
	table := gtk.NewTable(3, 2, false)
	userentry := gtk.NewEntry()
	userentry.SetMaxLength(10)
	userentry.SetSizeRequest(150, 23)
	pinentry := gtk.NewEntry()
	pinentry.SetVisibility(false)
	pinentry.SetMaxLength(10)

	table.Attach(userlabel, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 7, 5)
	table.Attach(userentry, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 7, 5)
	table.Attach(pinlabel, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 7, 5)
	table.Attach(pinentry, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 7, 5)
	table.Attach(button, 1, 2, 2, 3, gtk.FILL, gtk.FILL, 7, 5)

	error := gtk.NewLabel("")

	vbox := gtk.NewVBox(false, 20)
	vbox.SetBorderWidth(20)
	vbox.Add(logo)
	vbox.Add(table)
	vbox.Add(error)

	frame.Add(vbox)

	center := gtk.NewAlignment(0.5, 0.5, 0, 0)
	center.Add(frame)
	window.Add(center)

	// Functions to validate and check responses
	checkResponse := func(username, password string) {
		user, err := authenticate(hostAPI, username, password)
		if err != nil {
			log.Println("authentication API call failed: ", err)
			//error.SetMarkup("<span foreground='red'>Fikk ikke kontakt med server, vennligst prøv igjen!</span>")
			error.SetMarkup("<span foreground='red'>Feil lånenummer/brukernavn eller PIN/passord</span>")
			return
		}
		if !user.Authenticated {
			error.SetMarkup("<span foreground='red'>" + user.Message + "</span>")
			return
		}
		if user.Minutes+extraMinutes <= 0 && user.Type != "G" {
			error.SetMarkup("<span foreground='red'>Beklager, du har brukt opp kvoten din for i dag!</span>")
			return
		}
		if user.Type == "G" && user.Minutes <= 0 {
			error.SetMarkup("<span foreground='red'>Beklager, du har brukt opp kvoten din for i dag!</span>")
			return
		}
		if user.Age < agel || user.Age > ageh {
			error.SetMarkup("<span foreground='red'>Denne maskinen er kun for de mellom " +
				strconv.Itoa(agel) + " og " + strconv.Itoa(ageh) + "</span>")
			return
		}

		// sucess!
		userType = user.Type
		minutes = user.Minutes

		// set printer billing
		//LNUMMER
		cmd := exec.Command("/bin/sh", "-c", "/usr/bin/lpoptions -p publikumsskriver -o job-billing="+username)
		output, err := cmd.CombinedOutput()
		if err != nil {
			log.Println("failed to set printer billing options: ", string(output))
		}

		gtk.MainQuit()
		return
	}
	validate := func(ctx *glib.CallbackContext) {
		arg := ctx.Args(0)
		kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))
		username := userentry.GetText()
		password := pinentry.GetText()
		if kev.Keyval == gdk.KEY_Return {
			if username == "" && password == "" {
				return
			}
//.........这里部分代码省略.........
开发者ID:digibib,项目名称:mycel-client,代码行数:101,代码来源:login.go


示例11: main


//.........这里部分代码省略.........
	buttons.Add(resetbutton)

	// TICK MENU ITEM
	tickbutton := gtk.NewButtonWithLabel("Tick")
	tickbutton.Clicked(func() {
		updateentities(entities)
	})
	buttons.Add(tickbutton)

	// AUTOUPDATE MENU ITEM
	autotickbutton := gtk.NewToggleButtonWithLabel("AutoUpdate")
	autotickbutton.Clicked(func() {
		// Stop the previous ticker if it exists
		if autoticker != nil {
			autoticker.Stop()
		}

		if autoupdating {
			// Toggle autoupdating state
			autoupdating = false
		} else {
			// Start the ticker
			autoticker = time.NewTicker(time.Duration(tickslider.GetValue()) * time.Millisecond)

			// Spawn a goroutine that will run update entities every tick
			go func() {
				for _ = range autoticker.C {
					updateentities(entities)
				}
			}()

			// Toggle autoupdating state
			autoupdating = true
		}
	})
	buttons.Add(autotickbutton)
	davbox.Add(buttons)

	notebook.AppendPage(davbox, gtk.NewLabel("Simulation"))

	// INITIALIZE PANEL
	entitiesvbox := gtk.NewVBox(false, 1)

	// INITIALIZE LABELS FOR TABLE
	titles := gtk.NewHBox(false, 1)
	titles.Add(gtk.NewLabel("Mass"))
	titles.Add(gtk.NewLabel("X-Pos"))
	titles.Add(gtk.NewLabel("Y-Pos"))
	titles.Add(gtk.NewLabel("X-Vel"))
	titles.Add(gtk.NewLabel("Y-Vel"))
	titles.Add(gtk.NewLabel("X-Acc"))
	titles.Add(gtk.NewLabel("Y-Acc"))
	entitiesvbox.Add(titles)

	// INITIALIZE ENTRIES IN ROWS FOR TABLE
	for row := 0; row < entitylimit; row++ {
		rowbox := gtk.NewHBox(false, 1)
		for col := 0; col < entityfields; col++ {
			textfield := gtk.NewEntry()
			// Hold reference to text field in entries 2d array
			entries[row][col] = textfield
			rowbox.Add(textfield)
		}
		entitiesvbox.Add(rowbox)
	}

	// CLEAR ENTITIES BUTTON
	clearentitiesbutton := gtk.NewButtonWithLabel("Clear Entries")
	clearentitiesbutton.Clicked(func() {
		for row := 0; row < entitylimit; row++ {
			for col := 0; col < entityfields; col++ {
				entries[row][col].SetText("")
			}
		}
	})
	entitiesvbox.Add(clearentitiesbutton)

	// Limit the size of the entitiesvbox and add to notebook
	entitiesvbox.SetSizeRequest(width, height)
	notebook.AppendPage(entitiesvbox, gtk.NewLabel("Entities"))

	// FINISH PACKING COMPONENTS
	topvbox.PackStart(notebook, false, false, 0)

	// FINISH PACKING WINDOW
	window.Add(topvbox)

	// Show the GUI
	window.ShowAll()

	// Grab the drawable and initialize graphics context now that they are initialized
	drawable = drawingarea.GetWindow().GetDrawable()
	blackgc = gdk.NewGC(drawable)
	redgc = gdk.NewGC(drawable)
	redgc.SetRgbFgColor(gdk.NewColorRGB(255, 0, 0))
	bluegc = gdk.NewGC(drawable)
	bluegc.SetRgbFgColor(gdk.NewColorRGB(0, 0, 255))

	gtk.Main()
}
开发者ID:tkajder,项目名称:gtk-gravitysimulation,代码行数:101,代码来源:app.go


示例12: main

func main() {
	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) {
		fmt.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)
	//frame2 := gtk.NewFrame("Demo")
	//framebox2 := gtk.NewVBox(false, 1)
	//frame2.Add(framebox2)
	frame1.Add(framebox1)
	vpaned.Pack1(frame1, false, false)
	//vpaned.Pack1(frame2, false, false)

	entry := gtk.NewEntry()
	entry.SetText("Hej")
	framebox1.Add(entry)
	//vbox.PackStart(menubar, false, false, 0)

	imagefile := "texy1.png"
	image := gtk.NewImageFromFile(imagefile)
	framebox1.Add(image)
	button := gtk.NewButtonWithLabel("Calculate!")
	button.Clicked(func() {
		handlestring(entry.GetText())
		image.SetFromFile("temp.png")
	})
	framebox1.Add(button)

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

}
开发者ID:Englebabz,项目名称:CasGO,代码行数:61,代码来源:main.go


示例13: main

func main() {
	gtk.Init(nil)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("Lab 1")
	window.Connect("destroy",
		func(ctx *glib.CallbackContext) {
			gtk.MainQuit()
		},
		"Window destroyed")

	all_boxes := gtk.NewVBox(false, 0)
	base_conversion_box := gtk.NewHBox(false, 0)

	left_label_vbox := gtk.NewVBox(false, 5)
	number_entry_label := gtk.NewLabel("Input:")
	output_number_label := gtk.NewLabel("Output:")
	left_label_vbox.PackStart(number_entry_label, true, true, 0)
	left_label_vbox.PackStart(output_number_label, true, true, 0)

	left_input_vbox := gtk.NewVBox(false, 5)
	number_entry := gtk.NewEntry()
	output_number := gtk.NewEntry()
	left_input_vbox.PackStart(number_entry, true, true, 0)
	left_input_vbox.PackStart(output_number, true, true, 0)

	middle_label_vbox := gtk.NewVBox(false, 5)
	base_entry_label := gtk.NewLabel("Input base:")
	output_number_base10_label := gtk.NewLabel("Output (base 10):")
	middle_label_vbox.PackStart(base_entry_label, true, true, 0)
	middle_label_vbox.PackStart(output_number_base10_label, true, true, 0)

	middle_input_vbox := gtk.NewVBox(false, 5)
	base_entry := gtk.NewEntry()
	output_number_base10 := gtk.NewEntry()
	middle_input_vbox.PackStart(base_entry, true, true, 0)
	middle_input_vbox.PackStart(output_number_base10, true, true, 0)

	right_box := gtk.NewVBox(false, 5)
	output_base_box := gtk.NewHBox(false, 5)
	base_output_entry_label := gtk.NewLabel("Output base:")
	base_output_entry := gtk.NewEntry()
	base_output_entry.SetWidthChars(4)
	output_base_box.PackStart(base_output_entry_label, true, true, 0)
	output_base_box.PackStart(base_output_entry, true, true, 0)
	calculate_button := gtk.NewButtonWithLabel("Calculate")
	right_box.PackStart(output_base_box, true, true, 0)
	right_box.PackStart(calculate_button, true, true, 0)

	base_conversion_box.PackStart(left_label_vbox, true, true, 5)
	base_conversion_box.PackStart(left_input_vbox, true, true, 5)
	base_conversion_box.PackStart(middle_label_vbox, true, true, 5)
	base_conversion_box.PackStart(middle_input_vbox, true, true, 5)
	base_conversion_box.PackStart(right_box, true, true, 5)

	calculate_button.Clicked(func() {
		starting_number := number_entry.GetText()
		starting_base := base_entry.GetText()
		integer := string_to_int(starting_number, starting_base)
		output_number_base10.SetText(strconv.Itoa(integer))
		converted_number := int_to_string(integer, char_to_int(base_output_entry.GetText()))
		output_number.SetText(converted_number)
	})

	string_conversion_box := gtk.NewHBox(false, 5)
	input_label := gtk.NewLabel("Input string:")
	input_string := gtk.NewEntry()
	caps_label := gtk.NewLabel("Captial:")
	all_caps := gtk.NewEntry()
	lower_label := gtk.NewLabel("Lower case:")
	all_lower := gtk.NewEntry()
	convert_button := gtk.NewButtonWithLabel("Convert")
	string_conversion_box.PackStart(input_label, true, true, 0)
	string_conversion_box.PackStart(input_string, true, true, 0)
	string_conversion_box.PackStart(caps_label, true, true, 0)
	string_conversion_box.PackStart(all_caps, true, true, 0)
	string_conversion_box.PackStart(lower_label, true, true, 0)
	string_conversion_box.PackStart(all_lower, true, true, 0)
	string_conversion_box.PackStart(convert_button, true, true, 0)

	convert_button.Clicked(func() {
		string_to_convert := input_string.GetText()
		all_caps.SetText(caps(string_to_convert))
		all_lower.SetText(lowers(string_to_convert))
	})

	all_boxes.PackStart(base_conversion_box, true, true, 0)
	all_boxes.PackStart(gtk.NewHSeparator(), true, true, 10)
	all_boxes.PackStart(string_conversion_box, true, true, 0)
	window.Add(all_boxes)
	window.ShowAll()
	gtk.Main()
}
开发者ID:hkparker,项目名称:WillametteUniversity,代码行数:93,代码来源:lab1.go


示例14: runGUI

func runGUI() {

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

	keyboardEventsChan := make(chan *keyhandler.KeyPressEvent)
	window.Connect("key-press-event", func(ctx *glib.CallbackContext) {
		arg := ctx.Args(0)
		kev := *(**gdk.EventKey)(unsafe.Pointer(&arg))
		kpe := keyhandler.KeyPressEvent{int(kev.Keyval), 0}
		if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 {
			kpe.Modifier = gdk.CONTROL_MASK
		}
		keyboardEventsChan <- &kpe
	})

	// motionEvent := make(chan interface{})
	// window.Connect("motion-notify-event", func(ctx *glib.CallbackContext) {
	// 	arg := ctx.Args(0)
	// 	motionEvent <- *(**gdk.EventMotion)(unsafe.Pointer(&arg))
	// })
	// go events.MotionHandler(motionEvent)

	buttonEventChan := make(chan interface{})
	window.Connect("button-press-event", func(ctx *glib.CallbackContext) {
		arg := ctx.Args(0)
		buttonEventChan <- *(**gdk.EventButton)(unsafe.Pointer(&arg))
	})
	go events.ButtonHandler(buttonEventChan)

	setupProxy()

	vbox := gtk.NewVBox(false, 1)

	notebook := gtk.NewNotebook()

	tab := ui.NewBrowser(homePage)
	page := gtk.NewFrame("")
	notebook.AppendPage(page, gtk.NewLabel("Home"))
	page.Add(tab.VBox)
	vbox.PackStart(notebook, true, true, 0)

	statusbar := gtk.NewStatusbar()
	contextID := statusbar.GetContextId("actarus")
	statusbar.Push(contextID, "Welcome to Actarus.")
	vbox.PackStart(statusbar, false, false, 0)

	replEntry := gtk.NewEntry()
	replEntry.Hide()
	vbox.PackEnd(replEntry, false, false, 0)

	window.Add(vbox)

	window.SetSizeRequest(defaultWinWidth, defaultWinHeight)
	window.ShowAll()

	replEntry.GrabFocus()
	replEntry.SetVisible(false)

	// Handlers
	go events.KeyboardHandler(
		keyboardEventsChan,
		window,
		replEntry,
		tab.URLEntry,
		notebook)

	gtk.Main()
}
开发者ID:nlamirault,项目名称:actarus,代码行数:70,代码来源:actarus.go


示例15: main

func main() {
	flag.Parse()

	runtime.GOMAXPROCS(runtime.NumCPU())
	common.SetDefaultGtkTheme()

	machinePassword = uuid.New()[:4]
	clremoton = newClient(&remoton.Client{Prefix: "/remoton", TLSConfig: &tls.Config{}})
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGABRT, syscall.SIGKILL, syscall.SIGTERM)
	go func() {
		<-sigs
		clremoton.Terminate()
	}()
	gtk.Init(nil)

	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetPosition(gtk.WIN_POS_CENTER)
	window.SetTitle("REMOTON CLIENT")
	window.Connect("destroy", func(ctx *glib.CallbackContext) {
		gtk.MainQuit()
		clremoton.Terminate()
	}, "quit")
	window.SetIcon(common.GetIconGdkPixbuf())

	appLayout := gtk.NewVBox(false, 1)
	menu := gtk.NewMenuBar()
	appLayout.Add(menu)

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

	menuitem := gtk.NewMenuItemWithMnemonic("_About")
	menuitem.Connect("activate", func() {
		dialog := common.GtkAboutDialog()
		dialog.SetProgramName("Client Desktop")
		dialog.SetComments("Share your desktop secure")
		dialog.Run()
		dialog.Destroy()
	})
	submenu.Append(menuitem)

	hpaned := gtk.NewHPaned()
	appLayout.Add(hpaned)
	statusbar := gtk.NewStatusbar()
	contextID := statusbar.GetContextId("remoton-desktop-client")

	//---
	//CONTROL
	//---
	frameControl := gtk.NewFrame("Controls")
	controlBox := gtk.NewVBox(false, 1)
	frameControl.Add(controlBox)

	controlBox.Add(gtk.NewLabel("MACHINE ID"))
	machineIDEntry := gtk.NewEntry()
	machineIDEntry.SetEditable(false)
	controlBox.Add(machineIDEntry)

	machineAuthEntry := gtk.NewEntry()
	machineAuthEntry.SetEditable(false)
	controlBox.Add(machineAuthEntry)

	controlBox.Add(gtk.NewLabel("Server"))
	serverEntry := gtk.NewEntry()
	serverEntry.SetText("127.0.0.1:9934")
	if os.Getenv("REMOTON_SERVER") != "" {
		serverEntry.SetText(os.Getenv("REMOTON_SERVER"))
		serverEntry.SetEditable(false)
	}
	controlBox.Add(serverEntry)

	controlBox.Add(gtk.NewLabel("Auth Server"))
	authServerEntry := gtk.NewEntry()
	authServerEntry.SetText("public")
	controlBox.Add(authServerEntry)

	var getCertFilename func() string

	localCert := filepath.Join(filepath.Dir(os.Args[0]), "cert.pem")
	if _, err := os.Stat(localCert); err == nil || os.IsExist(err) {
		controlBox.Add(gtk.NewLabel("Cert local"))
		getCertFilename = func() string {
			return localCert
		}
	} else if os.Getenv("REMOTON_CERT_FILE") != "" {
		controlBox.Add(gtk.NewLabel("Cert enviroment"))
		getCertFilename = func() string {
			return os.Getenv("REMOTON_CERT_FILE")
		}
	} else {
		btnCert := gtk.NewFileChooserButton("Cert", gtk.FILE_CHOOSER_ACTION_OPEN)
		getCertFilename = btnCert.GetFilename
		controlBox.Add(btnCert)
	}

	btnSrv := gtk.NewButtonWithLabel("Start")
	clremoton.VNC.OnConnection(func(addr net.Addr) {
//.........这里部分代码省略.........
开发者ID:bit4bit,项目名称:remoton,代码行数:101,代码来源:main.go


示例16: main

func main() {
	b, err := ioutil.ReadFile("settings.json")
	if err != nil {
		fmt.Println(`"settings.json" not found: `, err)
		return
	}
	var config map[string]string
	err = json.Unmarshal(b, &config)
	if err != nil {
		fmt.Println(`can't read "settings.json": `, err)
		return
	}
	client := &oauth.Client{Credentials: oauth.Credentials{config["ClientToken"], config["ClientSecret"]}}
	cred := &oauth.Credentials{config["AccessToken"], config["AccessSecret"]}

	runtime.LockOSThread()
	gtk.Init(&os.Args)
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Twitter!")
	window.Connect("destroy", gtk.MainQuit)

	vbox := gtk.NewVBox(false, 1)

	scrolledwin := gtk.NewScrolledWindow(nil, nil)
	textview := gtk.NewTextView()
	textview.SetEditable(false)
	textview.SetCursorVisible(false)
	scrolledwin.Add(textview)
	vbox.Add(scrolledwin)

	buffer := textview.GetBuffer()
	tag := buffer.CreateTag("blue", map[string]string{"foreground": "#0000FF", "weight": "700"})

	hbox := gtk.NewHBox(false, 1)
	vbox.PackEnd(hbox, false, true, 5)

	label := gtk.NewLabel("Tweet")
	hbox.PackStart(label, false, false, 5)
	text := gtk.NewEntry()
	hbox.PackEnd(text, true, true, 5)

	text.Connect("activate", func() {
		t := text.GetText()
		text.SetText("")
		post(client, cred, t)
	})

	window.Add(vbox)
	window.SetSizeRequest(800, 500)
	window.ShowAll()

	var mutex sync.Mutex

	go func() {
		show(client, cred, func(t *tweet) {
			mutex.Lock()
			display(t, buffer, tag)
			mutex.Unlock()
		})

		stream(client, cred, func(t *tweet) {
			mutex.Lock()
			display(t, buffer, tag)
			var start, end gtk.TextIter
			buffer.GetIterAtLine(&start, buffer.GetLineCount()-2)
			buffer.GetEndIter(&end)
			buffer.Delete(&start, &end)
			mutex.Unlock()
		})
	}()

	for alive {
		mutex.Lock()
		alive = gtk.MainIterationDo(false)
		mutex.Unlock()
	}
}
开发者ID:mattn,项目名称:go-gtk,代码行数:77,代码来源:twitterstream.go


示例17: InitializeGUI


//.........这里部分代码省略.........
	//--------------------------------------------------------
	swin2 := gtk.NewScrolledWindow(nil, nil)

	swin2.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin2.SetShadowType(gtk.SHADOW_IN)
	textview2 := gtk.NewTextView()
	textview2.SetEditable(false)
	var start2, end2 gtk.TextIter
	buffer2 := textview2.GetBuffer()
	buffer2.GetStartIter(&start2)
	swin2.Add(textview2)
	//framebox2.Add(swin2)
	ventanas.Add(swin2)
	//--------------------------------------------------------
	// GtkTextView
	//--------------------------------------------------------
	swin3 := gtk.NewScrolledWindow(nil, nil)

	swin3.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
	swin3.SetShadowType(gtk.SHADOW_IN)
	textview3 := gtk.NewTextView()
	textview3.SetEditable(false)
	var start3, end3 gtk.TextIter
	buffer3 := textview3.GetBuffer()
	buffer3.GetStartIter(&start3)
	swin3.Add(textview3)
	//framebox2.Add(swin2)
	ventanas.Add(swin3)
	framebox2.PackStart(ventanas, true, true, 1)

	//--------------------------------------------------------
	// GtkEntry
	//--------------------------------------------------------
	entry := gtk.NewEntry()
	entry.SetText("Para comenzar, favor de escoger un archivo del directorio....")
	//entry.SetSensitive(false)
	entry.SetEditable(false)
	framebox2.Add(entry)

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

	//--------------------------------------------------------
	// GtkButton //**OPEN FILE****//
	//--------------------------------------------------------
	button := gtk.NewButtonWithLabel("Elegir archivo...")
	var filename string
	var isXE bool
	button.Clicked(func() {
		fmt.Println("button clicked:", button.GetLabel())
		messagedialog := gtk.NewMessageDialog(
			button.GetTopLevelAsWindow(),
			gtk.DIALOG_MODAL,
			gtk.MESSAGE_INFO,
			gtk.BUTTONS_OK,
			"Escoja un archivo .*s o *.x de su directorio")
		messagedialog.Response(func() {
			fmt.Println("Dialog OK!")

			//--------------------------------------------------------
			// GtkFileChooserDialog
			//--------------------------------------------------------
			filechooserdialog := gtk.NewFileChooserDialog(
				"Choose File...",
开发者ID:jatovar,项目名称:sic-xe,代码行数:67,代码来源:guinterface.go


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


示例19: main


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gtk.NewHBox函数代码示例发布时间:2022-05-23
下一篇:
Golang gtk.NewButtonWithLabel函数代码示例发布时间: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