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


Golang walk.NewPushButton函数代码示例

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


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

示例1: init

func (mw *MyWindow) init() (err error) {
	mw.SetMinimizeBox(true)
	mw.SetMaximizeBox(false)
	mw.SetFixedSize(true)

	mw.MainWindow, _ = walk.NewMainWindow()
	succeeded := false
	defer func() {
		if !succeeded {
			mw.Dispose()
		}
	}()

	mw.SetClientSize(walk.Size{260, 160})

	mw.SetTitle("主窗体")

	mw.ui.SecTitileLb, _ = walk.NewLabel(mw)
	mw.ui.SecTitileLb.SetText("子窗体:")
	mw.ui.SecTitileLb.SetBounds(walk.Rectangle{10, 50, 50, 20})

	mw.ui.SecTitileLe, _ = walk.NewLineEdit(mw)
	mw.ui.SecTitileLe.SetBounds(walk.Rectangle{60, 50, 160, 20})
	mw.ui.SecTitileLe.SetWidth(150)

	mw.ui.CreateBtn, _ = walk.NewPushButton(mw)
	mw.ui.CreateBtn.SetText("生成子窗体")
	mw.ui.CreateBtn.SetBounds(walk.Rectangle{90, 100, 75, 25})

	succeeded = true

	return nil
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:33,代码来源:master_ui.go

示例2: Create

func (pb PushButton) Create(builder *Builder) error {
	w, err := walk.NewPushButton(builder.Parent())
	if err != nil {
		return err
	}

	return builder.InitWidget(pb, w, func() error {
		if err := w.SetImage(pb.Image); err != nil {
			return err
		}

		if err := w.SetImageAboveText(pb.ImageAboveText); err != nil {
			return err
		}

		if pb.OnClicked != nil {
			w.Clicked().Attach(pb.OnClicked)
		}

		if pb.AssignTo != nil {
			*pb.AssignTo = w
		}

		return nil
	})
}
开发者ID:2105666566,项目名称:walk,代码行数:26,代码来源:pushbutton.go

示例3: Create

func (pb PushButton) Create(builder *Builder) error {
	w, err := walk.NewPushButton(builder.Parent())
	if err != nil {
		return err
	}

	return builder.InitWidget(pb, w, func() error {
		img := pb.Image
		if s, ok := img.(string); ok {
			var err error
			if img, err = walk.NewImageFromFile(s); err != nil {
				return err
			}
		}
		if img != nil {
			if err := w.SetImage(img.(walk.Image)); err != nil {
				return err
			}
		}

		if err := w.SetImageAboveText(pb.ImageAboveText); err != nil {
			return err
		}

		if pb.OnClicked != nil {
			w.Clicked().Attach(pb.OnClicked)
		}

		if pb.AssignTo != nil {
			*pb.AssignTo = w
		}

		return nil
	})
}
开发者ID:Archs,项目名称:walk,代码行数:35,代码来源:pushbutton.go

示例4: main

func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	mainWnd, err := walk.NewMainWindow()
	if err != nil {
		return
	}

	mw := &MainWindow{MainWindow: mainWnd}

	mw.SetTitle("SocketIm Example")

	button1, _ := walk.NewPushButton(mw)
	button1.SetText("start port 8000")
	button1.SetX(10)
	button1.SetY(10)
	button1.SetWidth(100)
	button1.SetHeight(30)

	button1.Clicked().Attach(func() {
		go NewTalkWindow(mw, 8000, 8001)
		button1.SetEnabled(false)
	})

	button2, _ := walk.NewPushButton(mw)
	button2.SetText("start port 8001")
	button2.SetX(10)
	button2.SetY(60)
	button2.SetWidth(100)
	button2.SetHeight(30)

	button2.Clicked().Attach(func() {
		go NewTalkWindow(mw, 8001, 8000)
		button2.SetEnabled(false)
	})

	mw.SetSize(walk.Size{120, 150})
	mw.Show()

	mw.Run()
}
开发者ID:atree1987,项目名称:MyWorks,代码行数:42,代码来源:main.go

示例5: NewButton

func NewButton(parent walk.Container, text string, width, height, x, y int) *Button {
	b := new(Button)
	b.PushButton, _ = walk.NewPushButton(parent)
	size := walk.Size{width, height}
	b.SetSize(size)
	b.SetMinMaxSize(size, size)
	b.SetY(y)
	b.SetX(x)
	b.SetText(text)

	return b
}
开发者ID:joy999,项目名称:walkwrap,代码行数:12,代码来源:Button.go

示例6: NewLoginWindow

func NewLoginWindow() {
	walk.SetPanicOnError(true)
	myWindow, _ := walk.NewMainWindow()
	mw := &LoginWindow{MainWindow: myWindow}
	//mw.SetLayout(walk.NewVBoxLayout())
	mw.SetTitle("nsq client")

	userLabel, _ := walk.NewLabel(mw)
	userLabel.SetText("用户名:")
	userLabel.SetX(20)
	userLabel.SetY(10)
	userLabel.SetSize(walk.Size{40, 20})

	userEdit, _ := walk.NewLineEdit(mw)
	userEdit.SetReadOnly(false)
	userEdit.SetX(70)
	userEdit.SetY(10)
	userEdit.SetSize(walk.Size{200, 20})
	userEdit.KeyDown().Attach(mw.onKeyDown)
	mw.userEdit = userEdit

	pwdLabel, _ := walk.NewLabel(mw)
	pwdLabel.SetText("密码:")
	pwdLabel.SetX(20)
	pwdLabel.SetY(40)
	pwdLabel.SetSize(walk.Size{40, 20})

	pwdEdit, _ := walk.NewLineEdit(mw)
	pwdEdit.SetReadOnly(false)
	pwdEdit.SetX(70)
	pwdEdit.SetY(40)
	pwdEdit.SetSize(walk.Size{200, 20})
	pwdEdit.KeyDown().Attach(mw.onKeyDown)
	mw.pwdEdit = pwdEdit

	loginBtn, _ := walk.NewPushButton(mw)
	loginBtn.SetText("登陆")
	loginBtn.SetX(120)
	loginBtn.SetY(70)
	loginBtn.SetSize(walk.Size{60, 30})
	loginBtn.Clicked().Attach(mw.loginBtn_OnClick)
	mw.loginBtn = loginBtn

	mw.Show()
	mw.userEdit.SetFocus()
	mw.SetMinMaxSize(walk.Size{300, 150}, walk.Size{})
	mw.SetSize(walk.Size{300, 150})
	mw.Run()
	os.Exit(0)
}
开发者ID:ibmendoza,项目名称:nsq-client,代码行数:50,代码来源:login_window.go

示例7: NewMyPushButton

func NewMyPushButton(parent walk.Container) (*MyPushButton, error) {
	pb, err := walk.NewPushButton(parent)
	if err != nil {
		return nil, err
	}

	mpb := &MyPushButton{pb}

	if err := walk.InitWrapperWidget(mpb); err != nil {
		return nil, err
	}

	return mpb, nil
}
开发者ID:richardjoo,项目名称:walk,代码行数:14,代码来源:externalwidgets.go

示例8: NewPairChatWindow

func NewPairChatWindow(_usr, _partner User) {
	walk.SetPanicOnError(true)
	myWindow, _ := walk.NewMainWindow()

	mw := &PairChatWindow{
		MainWindow: myWindow,
		usr:        _usr,
		partner:    _partner,
		msgChan:    make(chan *NsqMsg, 1),
	}

	mw.SetTitle(fmt.Sprintf("与%s私聊", _partner.Nick))

	msgEdit, _ := walk.NewTextEdit(mw)
	mw.msgEdit = msgEdit
	mw.msgEdit.SetSize(walk.Size{530, 100})
	mw.msgEdit.SetX(10)
	mw.msgEdit.SetY(360)
	mw.msgEdit.SetReadOnly(false)

	chatView, _ := NewChatMsgView(mw)
	mw.chatView = chatView
	mw.chatView.SetSize(walk.Size{530, 350})
	mw.chatView.SetX(10)
	mw.chatView.SetY(5)

	sendBtn, _ := walk.NewPushButton(mw)
	mw.sendBtn = sendBtn
	mw.sendBtn.SetText("发送")
	mw.sendBtn.SetX(480)
	mw.sendBtn.SetY(470)
	mw.sendBtn.SetSize(walk.Size{60, 30})
	mw.sendBtn.Clicked().Attach(mw.sendBtn_OnClick)

	mw.MainWindow.Show()

	mw.msgEdit.SetFocus()
	mw.SetMinMaxSize(walk.Size{565, 550}, walk.Size{565, 550})
	mw.SetSize(walk.Size{565, 550})

	pairChatMgr.register(mw.partner.Id, mw.msgChan)
	go mw.msgRouter()

	mw.MainWindow.Run()
	pairChatMgr.unregister(mw.partner.Id)
}
开发者ID:ibmendoza,项目名称:nsq-client,代码行数:46,代码来源:pairchat_window.go

示例9: main

func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	myWindow, _ := walk.NewMainWindow()

	myWindow.SetLayout(walk.NewVBoxLayout())
	myWindow.SetTitle("Go GUI example")

	myButton1, _ := walk.NewPushButton(myWindow)
	myButton1.SetText("XXXX")

	lb, _ := walk.NewListBox(myWindow)

	em := NewEnvModel()

	for _, env := range os.Environ() {
		i := strings.Index(env, "=")
		if i == 0 {
			continue
		}
		varName := env[0:i]
		value := env[i+1:]
		envItem := EnvItem{varName, value}

		em.envItems = append(em.envItems, envItem)
	}

	fmt.Println("The len of Model", em.ItemCount())
	lb.SetModel(em)
	lb.CurrentIndexChanged().Attach(func() {
		if curVar, ok := em.Value(lb.CurrentIndex()).(string); ok {
			myButton1.SetText(curVar)
			fmt.Println("CurrentIndex:", lb.CurrentIndex())
			fmt.Println("CurrentEnvVarName:", curVar)
		}
	})
	lb.DblClicked().Attach(func() {
		value := em.envItems[lb.CurrentIndex()].value
		walk.MsgBox(myWindow, "About", value, walk.MsgBoxOK|walk.MsgBoxIconInformation)
	})
	myWindow.Show()
	myWindow.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
	myWindow.SetSize(walk.Size{400, 500})
	myWindow.Run()
}
开发者ID:hoperuin,项目名称:walk,代码行数:46,代码来源:listbox.go

示例10: NewTalkWindow

func NewTalkWindow(mv *MainWindow, listenPort int, sendPort int) {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	talkWnd, err := walk.NewMainWindow()
	if err != nil {
		return
	}

	tw := &TalkWindow{MainWindow: talkWnd, ListenPort: listenPort, SendPort: sendPort}

	tw.SetTitle("I'm listing in" + strconv.Itoa(tw.ListenPort))

	tw.ShowText, _ = walk.NewTextEdit(tw)
	tw.ShowText.SetX(10)
	tw.ShowText.SetY(10)
	tw.ShowText.SetWidth(280)
	tw.ShowText.SetHeight(300)
	tw.ShowText.SetReadOnly(true)

	tw.SendText, _ = walk.NewTextEdit(tw)
	tw.SendText.SetX(10)
	tw.SendText.SetY(320)
	tw.SendText.SetWidth(200)
	tw.SendText.SetHeight(30)

	button1, _ := walk.NewPushButton(tw)
	button1.SetText("发送")
	button1.SetX(220)
	button1.SetY(320)
	button1.SetWidth(70)
	button1.SetHeight(30)
	button1.Clicked().Attach(func() {
		tw.Send()
	})

	tw.SetSize(walk.Size{320, 400})
	tw.Show()

	go tw.Listen()
	tw.Run()
}
开发者ID:atree1987,项目名称:MyWorks,代码行数:42,代码来源:im.go

示例11: main

func main() {
	walk.Initialize(walk.InitParams{PanicOnError: true})
	defer walk.Shutdown()

	rand.Seed(time.Now().UnixNano())

	mainWnd, _ := walk.NewMainWindow()

	mw := &MainWindow{
		MainWindow: mainWnd,
		model:      NewFooModel(),
	}

	mw.SetLayout(walk.NewVBoxLayout())
	mw.SetTitle("Walk TableView Example")

	resetRowsButton, _ := walk.NewPushButton(mw)
	resetRowsButton.SetText("Reset Rows")

	resetRowsButton.Clicked().Attach(func() {
		// Get some fresh data.
		mw.model.ResetRows()
	})

	tableView, _ := walk.NewTableView(mw)

	tableView.SetAlternatingRowBGColor(walk.RGB(255, 255, 224))
	tableView.SetReorderColumnsEnabled(true)

	// Everybody loves check boxes.
	tableView.SetCheckBoxes(true)

	// Don't forget to set the model.
	tableView.SetModel(mw.model)

	mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
	mw.SetSize(walk.Size{800, 600})
	mw.Show()

	mw.Run()
}
开发者ID:etel,项目名称:walk,代码行数:41,代码来源:tableview.go

示例12: Create

func (pb PushButton) Create(parent walk.Container) error {
	w, err := walk.NewPushButton(parent)
	if err != nil {
		return err
	}

	return InitWidget(pb, w, func() error {
		if err := w.SetText(pb.Text); err != nil {
			return err
		}

		if pb.OnClicked != nil {
			w.Clicked().Attach(pb.OnClicked)
		}

		if pb.AssignTo != nil {
			*pb.AssignTo = w
		}

		return nil
	})
}
开发者ID:etel,项目名称:walk,代码行数:22,代码来源:pushbutton.go

示例13: initPoseInfo


//.........这里部分代码省略.........
	exitAction := walk.NewAction()
	exitAction.SetText("E&xit")
	exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
	fileMenu.Actions().Add(exitAction)
}

func (mw *MainWindow) initCanvas() {
	for i := 0; i < POSE_CNT_MAX; i++ {
		iv, _ := selfWidget.NewMyImageView(mw)
		mw.imageView[i] = iv
	}
}
func (mw *MainWindow) initOtherBars() {
	sp, _ := walk.NewSplitter(mw)
	sp.SetSize(walk.Size{400, 20})

	lab, _ := walk.NewLabel(sp)
	lab.SetSize(walk.Size{16, 30})
	// lab.SetText("Pose")

	// others
	mw.uiFrameCnt, _ = walk.NewNumberEdit(sp)
	//mw.uiFrameCnt.SetSize(walk.Size{42, TB_H})
	mw.uiFrameCnt.SetRange(1, 100)
	mw.uiFrameCnt.SetDecimals(0)
	mw.uiFrameCnt.SetValue(8)
	mw.uiFrameCnt.SetEnabled(false)
	mw.uiFrameCnt.SetToolTipText(ttPlayPose)

	mw.uiPoseCnt, _ = walk.NewNumberEdit(sp)
	//mw.uiPoseCnt.SetSize(walk.Size{42, TB_H})
	mw.uiPoseCnt.SetRange(1, 100)
	mw.uiPoseCnt.SetValue(1)
	mw.uiPoseCnt.SetDecimals(0)
	mw.uiPoseCnt.SetToolTipText(ttPosCnt)

	mw.uiAddBoundY, _ = walk.NewNumberEdit(sp)
	mw.uiAddBoundY.SetRange(1, 1000)
	mw.uiAddBoundY.SetValue(0)
	mw.uiAddBoundY.SetDecimals(0)
	mw.uiAddBoundY.ValueChanged().Attach(func() {
		yBoundAdd = int(mw.uiAddBoundY.Value())
		if yBoundAdd < -imageH {
			yBoundAdd = -imageH
		}
		if yBoundAdd > (imageH - boundary.Max.Y) {
			yBoundAdd = imageH - boundary.Max.Y
		}
		mw.uiAddBoundY.SetValue(float64(yBoundAdd))
		mw.setImageSize()
	})

	mw.uiConvirm, _ = walk.NewPushButton(sp)
	mw.uiConvirm.SetText("OK")
	mw.uiConvirm.Clicked().Attach(func() {
		// Get some fresh data.
		// mw.onUiSetFrameCnt()
	})

	walk.InitWidget(sp, mw, FREEZEIZE_CLASS,
		winapi.CCS_NORESIZE,
		winapi.WS_EX_TOOLWINDOW|winapi.WS_EX_WINDOWEDGE)
}

func newMainWindow() {
	walk.SetPanicOnError(true)
	mainWnd, _ := walk.NewMainWindow()

	mw := &MainWindow{MainWindow: mainWnd}
	mw.viewGrid = walk.NewGridLayout()
	mw.SetLayout(mw.viewGrid)
	mw.viewGrid.SetRowStretchFactor(GRID_CNT, 2)
	mw.viewGrid.SetColumnStretchFactor(GRID_CNT, 2)
	mw.viewGrid.SetMargins(walk.Margins{6, 28, 2, 6})

	mw.SetTitle("Image composer")

	mw.initMenu()
	mw.initOtherBars()
	mw.initCanvas()

	mw.SetMinMaxSize(walk.Size{800, 600}, walk.Size{})
	mw.SetSize(walk.Size{800, 600})

	mw.refreshToolBar(MODE_INVALID)
	mw.Show()
	mw.Run()
}

func init() {
	walk.MustRegisterWindowClass(FREEZEIZE_CLASS)
	runtime.GOMAXPROCS(2)

	screenW = int(winapi.GetSystemMetrics(winapi.SM_CXSCREEN))
	screenH = int(winapi.GetSystemMetrics(winapi.SM_CYSCREEN))
}

func main() {
	newMainWindow()
}
开发者ID:hemaolong,项目名称:Rabbit,代码行数:101,代码来源:main.go

示例14: init

func (w *MyDialog) init(owner walk.RootWidget) (err error) {
	if w.Dialog, err = walk.NewDialog(owner); err != nil {
		return err
	}

	succeeded := false
	defer func() {
		if !succeeded {
			w.Dispose()
		}
	}()

	var font *walk.Font
	if font == nil {
		font = nil
	}

	w.SetName("Dialog")
	if err := w.SetClientSize(walk.Size{598, 300}); err != nil {
		return err
	}
	if err := w.SetTitle(`Dialog`); err != nil {
		return err
	}

	// noProgressBtn
	if w.ui.noProgressBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.noProgressBtn.SetName("noProgressBtn")
	if err := w.ui.noProgressBtn.SetBounds(walk.Rectangle{40, 60, 161, 23}); err != nil {
		return err
	}
	if err := w.ui.noProgressBtn.SetText(`NoProgress`); err != nil {
		return err
	}
	if err := w.ui.noProgressBtn.SetMinMaxSize(walk.Size{0, 0}, walk.Size{161, 16777215}); err != nil {
		return err
	}

	// indeterminateBtn
	if w.ui.indeterminateBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.indeterminateBtn.SetName("indeterminateBtn")
	if err := w.ui.indeterminateBtn.SetBounds(walk.Rectangle{40, 90, 161, 23}); err != nil {
		return err
	}
	if err := w.ui.indeterminateBtn.SetText(`Indeterminate`); err != nil {
		return err
	}
	if err := w.ui.indeterminateBtn.SetMinMaxSize(walk.Size{0, 0}, walk.Size{161, 16777215}); err != nil {
		return err
	}

	// normalBtn
	if w.ui.normalBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.normalBtn.SetName("normalBtn")
	if err := w.ui.normalBtn.SetBounds(walk.Rectangle{40, 120, 161, 23}); err != nil {
		return err
	}
	if err := w.ui.normalBtn.SetText(`Normal`); err != nil {
		return err
	}
	if err := w.ui.normalBtn.SetMinMaxSize(walk.Size{0, 0}, walk.Size{161, 16777215}); err != nil {
		return err
	}

	// errBtn
	if w.ui.errBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.errBtn.SetName("errBtn")
	if err := w.ui.errBtn.SetBounds(walk.Rectangle{40, 150, 161, 23}); err != nil {
		return err
	}
	if err := w.ui.errBtn.SetText(`Error`); err != nil {
		return err
	}

	// pausedBtn
	if w.ui.pausedBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.pausedBtn.SetName("pausedBtn")
	if err := w.ui.pausedBtn.SetBounds(walk.Rectangle{40, 180, 161, 23}); err != nil {
		return err
	}
	if err := w.ui.pausedBtn.SetText(`Paused`); err != nil {
		return err
	}

	// startBtn
	if w.ui.startBtn, err = walk.NewPushButton(w); err != nil {
		return err
	}
	w.ui.startBtn.SetName("startBtn")
	if err := w.ui.startBtn.SetBounds(walk.Rectangle{290, 180, 75, 23}); err != nil {
//.........这里部分代码省略.........
开发者ID:karlma,项目名称:walk,代码行数:101,代码来源:dialog_ui.go

示例15: NewGroupChatWindow

func NewGroupChatWindow(_usr User) {
	walk.SetPanicOnError(true)
	myWindow, _ := walk.NewMainWindow()

	mw := &GroupChatWindow{
		MainWindow: myWindow,
		usr:        _usr,
		usrModel:   NewUsrModel(),
	}

	mw.SetTitle("简易群聊:" + _usr.Nick)

	usrList, _ := walk.NewListBox(mw)
	mw.usrList = usrList
	mw.usrList.SetModel(mw.usrModel)
	mw.usrList.SetSize(walk.Size{100, 450})
	mw.usrList.SetX(10)
	mw.usrList.SetY(5)
	mw.usrList.ItemActivated().Attach(mw.userlist_ItemActivated)
	mw.usrList.CurrentIndexChanged().Attach(mw.userlist_CurrentIndexChanged)

	msgEdit, _ := walk.NewTextEdit(mw)
	mw.msgEdit = msgEdit
	mw.msgEdit.SetSize(walk.Size{500, 100})
	mw.msgEdit.SetX(120)
	mw.msgEdit.SetY(310)
	mw.msgEdit.SetReadOnly(false)

	chatView, _ := NewChatMsgView(mw)
	mw.chatView = chatView
	mw.chatView.SetSize(walk.Size{500, 300})
	mw.chatView.SetX(120)
	mw.chatView.SetY(5)

	sendBtn, _ := walk.NewPushButton(mw)
	mw.sendBtn = sendBtn
	mw.sendBtn.SetText("发送")
	mw.sendBtn.SetX(560)
	mw.sendBtn.SetY(420)
	mw.sendBtn.SetSize(walk.Size{60, 30})
	mw.sendBtn.Clicked().Attach(mw.sendBtn_OnClick)

	mw.MainWindow.Show()

	mw.msgEdit.SetFocus()
	mw.SetMinMaxSize(walk.Size{645, 500}, walk.Size{645, 500})
	mw.SetSize(walk.Size{645, 500})

	mw.chatMgr = &ChatMgr{
		topic:   "imtech",
		channel: mw.usr.Id,
		msgChan: make(chan *NsqMsg, 1),
	}
	go Receiver.registerMsgHandler(mw.chatMgr)
	go mw.msgRouter()

	mw.MainWindow.Run()
	mw.chatMgr.reader.Stop()
	Publisher.Stop()
	pairChatMgr.release()
	os.Exit(0)

}
开发者ID:ibmendoza,项目名称:nsq-client,代码行数:63,代码来源:groupchat_window.go


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