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

Golang gwu.NewLabel函数代码示例

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

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



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

示例1: buildSwitchButtonDemo

func buildSwitchButtonDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()
	p.SetCellPadding(1)

	row := gwu.NewHorizontalPanel()
	row.Add(gwu.NewLabel("Here's an ON/OFF switch which enables/disables the other one:"))
	sw := gwu.NewSwitchButton()
	sw.SetOnOff("ENB", "DISB")
	sw.SetState(true)
	row.Add(sw)
	p.Add(row)

	p.AddVSpace(10)
	row = gwu.NewHorizontalPanel()
	row.Add(gwu.NewLabel("And the other one:"))
	sw2 := gwu.NewSwitchButton()
	sw2.SetEnabled(true)
	sw2.Style().SetWidthPx(100)
	row.Add(sw2)
	sw.AddEHandlerFunc(func(e gwu.Event) {
		sw2.SetEnabled(sw.State())
		e.MarkDirty(sw2)
	}, gwu.ETYPE_CLICK)
	p.Add(row)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:27,代码来源:test.go


示例2: buildRadioButtonDemo

func buildRadioButtonDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Select your favorite programming language:"))

	group := gwu.NewRadioGroup("lang")
	rbs := []gwu.RadioButton{gwu.NewRadioButton("Go", group), gwu.NewRadioButton("Java", group), gwu.NewRadioButton("C / C++", group),
		gwu.NewRadioButton("Python", group), gwu.NewRadioButton("QBasic (nah this can't be your favorite)", group)}
	rbs[4].SetEnabled(false)

	for _, rb := range rbs {
		p.Add(rb)
	}

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Select your favorite computer game:"))

	group = gwu.NewRadioGroup("game")
	rbs = []gwu.RadioButton{gwu.NewRadioButton("StarCraft II", group), gwu.NewRadioButton("Minecraft", group),
		gwu.NewRadioButton("Other", group)}

	for _, rb := range rbs {
		p.Add(rb)
	}

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:27,代码来源:test.go


示例3: buildImageDemo

func buildImageDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Google's logo:"))
	img := gwu.NewImage("Google's logo", "https://www.google.com/images/srpr/logo3w.png")
	img.Style().SetSizePx(275, 95)
	p.Add(img)

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Go's Gopher:"))
	img = gwu.NewImage("Go's Gopher", "http://golang.org/doc/gopher/frontpage.png")
	img.Style().SetSizePx(250, 340)
	state := false
	img.AddEHandlerFunc(func(e gwu.Event) {

		switch e.Type() {
		case gwu.ETYPE_CLICK:
			switch state {
			case false:
				img.SetUrl("https://www.google.com/images/srpr/logo3w.png")
				img.Style().SetSizePx(275, 95)
				state = true
			case true:
				img.SetUrl("http://golang.org/doc/gopher/frontpage.png")
				img.Style().SetSizePx(250, 340)
				state = false
			}
		}
		e.MarkDirty(img)
	}, gwu.ETYPE_CLICK)
	p.Add(img)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:34,代码来源:test.go


示例4: buildLabelDemo

func buildLabelDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("This is a Label."))
	p.Add(gwu.NewLabel("世界 And another one. ㅈㅈ"))
	p.Add(gwu.NewLabel("Nothing special about them, but they may be the mostly used components."))

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("You can change their text:"))
	b := gwu.NewButton("Change!")
	b.AddEHandlerFunc(func(e gwu.Event) {
		for i := 0; i < p.CompsCount(); i++ {
			if l, ok := p.CompAt(i).(gwu.Label); ok && l != b {
				reversed := []rune(l.Text())
				for i, j := 0, len(reversed)-1; i < j; i, j = i+1, j-1 {
					reversed[i], reversed[j] = reversed[j], reversed[i]
				}
				l.SetText(string(reversed))
			}
		}
		e.MarkDirty(p)
	}, gwu.ETYPE_CLICK)
	p.Add(b)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:26,代码来源:test.go


示例5: main

func main() {
	// Create GUI server
	server := gwu.NewServer("guitest", "")
	//server := gwu.NewServerTLS("guitest", "", "test_tls/cert.pem", "test_tls/key.pem")
	server.SetText("Test GUI Application")

	server.AddSessCreatorName("login", "Login Window")
	server.AddSHandler(SessHandler{})

	win := gwu.NewWindow("home", "Home Window")
	l := gwu.NewLabel("Home, sweet home of " + server.Text())
	l.Style().SetFontWeight(gwu.FONT_WEIGHT_BOLD).SetFontSize("130%")
	win.Add(l)
	win.Add(gwu.NewLabel("Click on the button to login:"))
	b := gwu.NewButton("Login")
	b.AddEHandlerFunc(func(e gwu.Event) {
		e.ReloadWin("login")
	}, gwu.ETYPE_CLICK)
	win.Add(b)

	server.AddWin(win)

	server.SetLogger(log.New(os.Stdout, "", log.LstdFlags))

	// Start GUI server
	if err := server.Start(); err != nil {
		fmt.Println("Error: Cound not start GUI server:", err)
		return
	}
}
开发者ID:jmptrader,项目名称:gowut,代码行数:30,代码来源:login_demo.go


示例6: buildCheckBoxDemo

func buildCheckBoxDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	suml := gwu.NewLabel("")

	p.Add(gwu.NewLabel("Check the days you want to work on:"))

	cbs := []gwu.CheckBox{gwu.NewCheckBox("Monday"), gwu.NewCheckBox("Tuesday"), gwu.NewCheckBox("Wednesday"),
		gwu.NewCheckBox("Thursday"), gwu.NewCheckBox("Friday"), gwu.NewCheckBox("Saturday"), gwu.NewCheckBox("Sunday")}
	cbs[5].SetEnabled(false)
	cbs[6].SetEnabled(false)

	for _, cb := range cbs {
		p.Add(cb)
		cb.AddEHandlerFunc(func(e gwu.Event) {
			sum := 0
			for _, cb2 := range cbs {
				if cb2.State() {
					sum++
				}
			}
			suml.SetText(fmt.Sprintf("%d day%s is a total of %d hours a week.", sum, plural(sum), sum*8))
			e.MarkDirty(suml)
		}, gwu.ETYPE_CLICK)
	}

	p.Add(suml)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:30,代码来源:test.go


示例7: buildPanelDemo

func buildPanelDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Panel with horizontal layout:"))
	h := gwu.NewHorizontalPanel()
	for i := 1; i <= 5; i++ {
		h.Add(gwu.NewButton("Button " + strconv.Itoa(i)))
	}
	p.Add(h)

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Panel with vertical layout:"))
	v := gwu.NewVerticalPanel()
	for i := 1; i <= 5; i++ {
		v.Add(gwu.NewButton("Button " + strconv.Itoa(i)))
	}
	p.Add(v)

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Panel with natural layout:"))
	n := gwu.NewNaturalPanel()
	for i := 1; i <= 20; i++ {
		n.Add(gwu.NewButton("LONG BUTTON " + strconv.Itoa(i)))
	}
	p.Add(n)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:28,代码来源:test.go


示例8: buildHomeDemo

func buildHomeDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("This app is written in and showcases Gowut version " + gwu.GOWUT_VERSION + "."))
	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Select components on the left side to see them in action."))

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:9,代码来源:test.go


示例9: buildWindowDemo

func buildWindowDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("The Window represents the whole window, the page inside the browser."))
	p.AddVSpace(5)
	p.Add(gwu.NewLabel("The Window is the top of the component hierarchy. It is an extension of the Panel."))

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:9,代码来源:test.go


示例10: updateTables

func updateTables(tables gwu.Panel) {
	var sorted SortBySellPrice
	for card, _ := range PriceHistory {
		sorted = append(sorted, StockedItem{
			card,
			currentState.DeterminePrice(card, 1, true),
			currentState.DeterminePrice(card, 1, false),
		})
	}
	sort.Sort(sorted)

	tables.Clear()
	tables.Add(createFAQ())

	tables.AddHSpace(100)
	for rarity, rarityStr := range []string{"Commons", "Uncommons", "Rares"} {
		layout := gwu.NewPanel()
		tables.Add(layout)
		tables.AddHSpace(30)

		layout.SetHAlign(gwu.HA_CENTER)
		layout.Style().SetBackground("rgba(0,0,0,0.5)")
		layout.Style().SetWidthPx(320)

		header := gwu.NewLabel(rarityStr)
		header.Style().SetColor("rgb(255,255,255)")
		header.Style().SetFontWeight("bold")
		header.Style().SetFontSize("x-large")
		layout.Add(header)

		table := gwu.NewTable()
		layout.Add(table)

		table.SetCellPadding(5)

		row := 0
		for _, sortedItem := range sorted {
			if CardRarities[sortedItem.card] != rarity {
				continue
			}

			table.Add(gwu.NewImage("", fmt.Sprintf("images/%s.png", CardResources[sortedItem.card])), row, 0)
			table.Add(gwu.NewLabel(string(sortedItem.card)), row, 1)
			table.Add(gwu.NewLabel(fmt.Sprintf("%d", sortedItem.buy)), row, 2)
			table.Add(gwu.NewLabel(fmt.Sprintf("%d", sortedItem.sell)), row, 3)
			if row%2 == 0 {
				table.RowFmt(row).Style().SetBackground("rgba(255,255,255,0.75)")
			} else {
				table.RowFmt(row).Style().SetBackground("rgba(150,150,150,0.75)")
			}
			row++
		}
	}
}
开发者ID:Coolwhip3,项目名称:ScrollsTradeBot,代码行数:54,代码来源:html.go


示例11: buildButtonDemo

func buildButtonDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	l := gwu.NewLabel("")

	btnp := gwu.NewHorizontalPanel()
	b := gwu.NewButton("Normal Button")
	b.AddEHandlerFunc(func(e gwu.Event) {
		switch e.Type() {
		case gwu.ETYPE_MOUSE_OVER:
			l.SetText("Mouse is over...")
		case gwu.ETYPE_MOUSE_OUT:
			l.SetText("Mouse is out.")
		case gwu.ETYPE_CLICK:
			x, y := e.Mouse()
			l.SetText(fmt.Sprintf("Clicked at x=%d, y=%d", x, y))
		}
		e.MarkDirty(l)
	}, gwu.ETYPE_CLICK, gwu.ETYPE_MOUSE_OVER, gwu.ETYPE_MOUSE_OUT)
	btnp.Add(b)

	b = gwu.NewButton("Disabled Button")
	b.SetEnabled(false)
	btnp.Add(b)

	p.Add(btnp)

	p.Add(l)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:31,代码来源:test.go


示例12: buildImageDemo

func buildImageDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Google's logo:"))
	img := gwu.NewImage("Google's logo", "https://www.google.com/images/srpr/logo3w.png")
	img.Style().SetSizePx(275, 95)
	p.Add(img)

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("Go's Gopher:"))
	img = gwu.NewImage("Go's Gopher", "http://golang.org/doc/gopher/frontpage.png")
	img.Style().SetSizePx(250, 340)
	p.Add(img)

	return p
}
开发者ID:jmptrader,项目名称:gowut,代码行数:16,代码来源:showcase.go


示例13: buildPasswBoxDemo

func buildPasswBoxDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Enter your password:"))
	p.Add(gwu.NewPasswBox(""))

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:8,代码来源:test.go


示例14: createFAQ

func createFAQ() gwu.Panel {
	panel := gwu.NewPanel()
	panel.Style().SetBackground("rgba(255,255,255,0.75)")

	addHeader := func(text string) {
		label := gwu.NewLabel(text)
		label.Style().SetColor("rgb(0,0,0)")
		label.Style().SetFontWeight("bold")
		label.Style().SetFontSize("large")
		panel.Add(label)
	}

	addText := func(text string) {
		label := gwu.NewLabel(text)
		label.Style().SetColor("rgb(0,0,0)")
		panel.Add(label)
	}

	addHeader("What is this?")
	addText("This site displays the prices for which the ClockworkAgent, a trading bot for the game Scrolls, will buy and sell cards for.")

	addHeader("How do I engage in trading with the bot?")
	addText("Just join the ingame channel 'clockwork' and say '!trade'. You will then be queued up for interaction with the bot in a trade.")

	addHeader("Why are these prices so different from Scrollsguide prices?")
	addText("Scrollsguide prices are determined from WTB and WTS messages in the Trading-channel. Thus they reflect what people expect to " +
		"pay/get for a card, not necessarily what the card is actually traded for. Since most people adjust their expectations to what " +
		"the current Scrollsguide price is, this can lead to a self-fulfilling prophecy. Also, it is pretty easy to manipulate the prices " +
		"for cards that are traded less often, enabling a way to scam the bot if it would use these prices.")

	addHeader("How then are these prices calculated?")
	addText("The price starts at 1500 for rares, 750 for uncommons and 187 for commons. Each time a card is sold to the bot, it will assume " +
		"that the card is less valuable, reducing the price by 100 / 50 / 12.5 depending on rarity. Each time a card is bought from the bot, " +
		"the price will	go up again.")

	addHeader("Why does the buy price fluctuate, when the sell price remains constant?")
	addText("If the bot has less than 2000 gold, the buy prices will be lowered down to a minimum of 50%. This way the bot can aquire more cards, " +
		"balancing out the fact that it had to overpay for most cards in order to determine the price, as well as new additions and general price deflation.")

	addHeader("Who created the bot, and where can I find the source code?")
	addText("Ingame: redefiance")
	addText("Reddit: lando-garner")
	panel.Add(gwu.NewLink("Source", "https://github.com/redefiance/ScrollsTradeBot"))

	return panel
}
开发者ID:Coolwhip3,项目名称:ScrollsTradeBot,代码行数:46,代码来源:html.go


示例15: buildLinkContainerDemo

func buildLinkContainerDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	link := gwu.NewLink("An obvious link, to Google Home", "https://google.com/")
	inside := gwu.NewPanel()
	inside.Style().SetBorder2(1, gwu.BRD_STYLE_SOLID, gwu.CLR_GRAY)
	inside.Add(gwu.NewLabel("Everything inside this box also links to Google!"))
	inside.Add(gwu.NewButton("Me too!"))
	link.SetComp(inside)
	p.Add(link)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:13,代码来源:test.go


示例16: buildLinkDemo

func buildLinkDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()
	p.SetCellPadding(3)

	p.Add(gwu.NewLink("Visit Gowut Home page", "https://sites.google.com/site/gowebuitoolkit/"))
	p.Add(gwu.NewLink("Visit Gowut Project page", "http://code.google.com/p/gowut/"))

	row := gwu.NewHorizontalPanel()
	row.SetCellPadding(3)
	row.Add(gwu.NewLabel("Discussion forum:"))
	row.Add(gwu.NewLink("https://groups.google.com/d/forum/gowebuitoolkit", "https://groups.google.com/d/forum/gowebuitoolkit"))
	p.Add(row)

	row = gwu.NewHorizontalPanel()
	row.SetCellPadding(3)
	row.Add(gwu.NewLabel("Send e-mail to the Gowut author:"))
	email := "iczaaa" + "@" + "gmail.com"
	row.Add(gwu.NewLink("András Belicza <"+email+">", "mailto:"+email))
	p.Add(row)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:22,代码来源:test.go


示例17: buildTextBoxDemo

func buildTextBoxDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	p.Add(gwu.NewLabel("Enter your name (max 15 characters):"))
	row := gwu.NewHorizontalPanel()
	tb := gwu.NewTextBox("")
	tb.SetMaxLength(15)
	tb.AddSyncOnETypes(gwu.ETYPE_KEY_UP)
	length := gwu.NewLabel("")
	length.Style().SetFontSize("80%").SetFontStyle(gwu.FONT_STYLE_ITALIC)
	tb.AddEHandlerFunc(func(e gwu.Event) {
		rem := 15 - len(tb.Text())
		length.SetText(fmt.Sprintf("(%d character%s left...)", rem, plural(rem)))
		e.MarkDirty(length)
	}, gwu.ETYPE_CHANGE, gwu.ETYPE_KEY_UP)
	row.Add(tb)
	row.Add(length)
	p.Add(row)

	p.AddVSpace(10)
	p.Add(gwu.NewLabel("Short biography:"))
	bio := gwu.NewTextBox("")
	bio.SetRows(5)
	bio.SetCols(40)
	p.Add(bio)

	p.AddVSpace(10)
	rtb := gwu.NewTextBox("This is just a read-only text box...")
	rtb.SetReadOnly(true)
	p.Add(rtb)

	p.AddVSpace(10)
	dtb := gwu.NewTextBox("...and a disabled one.")
	dtb.SetEnabled(false)
	p.Add(dtb)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:38,代码来源:test.go


示例18: buildListBoxDemo

func buildListBoxDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	row := gwu.NewHorizontalPanel()
	l := gwu.NewLabel("Select a background color:")
	row.Add(l)
	lb := gwu.NewListBox([]string{"", "Black", "Red", "Green", "Blue", "White"})
	lb.AddEHandlerFunc(func(e gwu.Event) {
		l.Style().SetBackground(lb.SelectedValue())
		e.MarkDirty(l)
	}, gwu.ETYPE_CHANGE)
	row.Add(lb)
	p.Add(row)

	p.AddVSpace(10)
	p.Add(gwu.NewLabel("Select numbers that add up to 89:"))
	sumLabel := gwu.NewLabel("")
	lb2 := gwu.NewListBox([]string{"1", "2", "4", "8", "16", "32", "64", "128"})
	lb2.SetMulti(true)
	lb2.SetRows(10)
	lb2.AddEHandlerFunc(func(e gwu.Event) {
		sum := 0
		for _, idx := range lb2.SelectedIndices() {
			sum += 1 << uint(idx)
		}
		if sum == 89 {
			sumLabel.SetText("Hooray! You did it!")
		} else {
			sumLabel.SetText(fmt.Sprintf("Now quite there... (sum = %d)", sum))
		}
		e.MarkDirty(sumLabel)
	}, gwu.ETYPE_CHANGE)
	p.Add(lb2)
	p.Add(sumLabel)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:37,代码来源:test.go


示例19: buildTableDemo

func buildTableDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	l := gwu.NewLabel("Tip: Switch to the 'debug' theme (top right) to see cell borders.")
	l.Style().SetColor(gwu.CLR_RED).SetFontStyle(gwu.FONT_STYLE_ITALIC)
	p.Add(l)

	p.AddVSpace(20)
	p.Add(gwu.NewLabel("A simple form aligned with a table:"))
	p.AddVSpace(10)
	t := gwu.NewTable()
	t.SetCellPadding(2)
	t.EnsureSize(2, 2)
	var c gwu.Comp
	t.Add(gwu.NewLabel("User name:"), 0, 0)
	c = gwu.NewTextBox("")
	c.Style().SetWidthPx(160)
	t.Add(c, 0, 1)
	t.Add(gwu.NewLabel("Password:"), 1, 0)
	c = gwu.NewPasswBox("")
	c.Style().SetWidthPx(160)
	t.Add(c, 1, 1)
	t.Add(gwu.NewLabel("Go to:"), 2, 0)
	c = gwu.NewListBox([]string{"Inbox", "User preferences", "Last visited page"})
	c.Style().SetWidthPx(160)
	t.Add(c, 2, 1)
	p.Add(t)

	p.AddVSpace(30)
	p.Add(gwu.NewLabel("Advanced table structure with modified alignment, row and col spans:"))
	p.AddVSpace(10)
	t = gwu.NewTable()
	t.Style().SetBorder2(1, gwu.BRD_STYLE_SOLID, gwu.CLR_GREY)
	t.SetAlign(gwu.HA_RIGHT, gwu.VA_TOP)
	t.EnsureSize(5, 5)
	for row := 0; row < 5; row++ {
		for col := 0; col < 5; col++ {
			t.Add(gwu.NewButton("Button "+strconv.Itoa(row)+strconv.Itoa(col)), row, col)
		}
	}
	t.SetColSpan(2, 1, 2)
	t.SetRowSpan(3, 1, 2)
	t.CellFmt(2, 2).Style().SetSizePx(150, 80)
	t.CellFmt(2, 2).SetAlign(gwu.HA_RIGHT, gwu.VA_BOTTOM)
	t.RowFmt(2).SetAlign(gwu.HA_DEFAULT, gwu.VA_MIDDLE)
	t.CompAt(2, 1).Style().SetFullSize()
	t.CompAt(4, 2).Style().SetFullWidth()
	t.RowFmt(0).Style().SetBackground(gwu.CLR_RED)
	t.RowFmt(1).Style().SetBackground(gwu.CLR_GREEN)
	t.RowFmt(2).Style().SetBackground(gwu.CLR_BLUE)
	t.RowFmt(3).Style().SetBackground(gwu.CLR_GREY)
	t.RowFmt(4).Style().SetBackground(gwu.CLR_TEAL)
	p.Add(t)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:56,代码来源:test.go


示例20: buildExpanderDemo

func buildExpanderDemo(event gwu.Event) gwu.Comp {
	p := gwu.NewPanel()

	l := gwu.NewLabel("Click on the Expander's header.")
	l.Style().SetColor(gwu.CLR_GREEN)
	p.Add(l)
	p.AddVSpace(5)
	e := gwu.NewExpander()
	e.SetHeader(gwu.NewLabel("I'm an Expander."))
	e.SetContent(gwu.NewLabel("I'm the content of the Expander."))
	p.Add(e)
	e.AddEHandlerFunc(func(ev gwu.Event) {
		if e.Expanded() {
			l.SetText("You expanded it.")
		} else {
			l.SetText("You collapsed it.")
		}
		ev.MarkDirty(l)
	}, gwu.ETYPE_STATE_CHANGE)

	p.AddVSpace(20)
	var ee gwu.Expander
	for i := 4; i >= 0; i-- {
		e2 := gwu.NewExpander()
		e2.SetHeader(gwu.NewLabel("I hide embedded expanders. #" + strconv.Itoa(i)))
		if i == 4 {
			e2.SetContent(gwu.NewLabel("No more."))
		} else {
			e2.SetContent(ee)
		}
		ee = e2
	}
	p.Add(ee)

	return p
}
开发者ID:anhofmann,项目名称:anhofmann.github.com,代码行数:36,代码来源:test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gwu.NewPanel函数代码示例发布时间:2022-05-24
下一篇:
Golang goweb.Context类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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