本文整理匯總了Golang中github.com/lxn/walk.Action.SetImage方法的典型用法代碼示例。如果您正苦於以下問題:Golang Action.SetImage方法的具體用法?Golang Action.SetImage怎麽用?Golang Action.SetImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.Action
的用法示例。
在下文中一共展示了Action.SetImage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setActionImage
func setActionImage(action *walk.Action, image interface{}) (err error) {
var img *walk.Bitmap
switch image := image.(type) {
case nil:
return nil
case *walk.Bitmap:
img = image
case string:
if img, err = walk.NewBitmapFromFile(image); err != nil {
return
}
default:
return errors.New("invalid type for Image")
}
return action.SetImage(img)
}
示例2: setActionImage
func setActionImage(action *walk.Action, image interface{}) (err error) {
var img walk.Image
switch image := image.(type) {
case nil:
return nil
case *walk.Bitmap:
img = image
case string:
if img, err = imageFromFile(image); err != nil {
return
}
}
if bmp, ok := img.(*walk.Bitmap); ok {
return action.SetImage(bmp)
}
return errors.New("invalid type for Image")
}
示例3: initAction
func (a Action) initAction(wa *walk.Action) (*walk.Action, error) {
text := a.Text
if text == "" {
text = "-"
}
if err := wa.SetText(text); err != nil {
return nil, err
}
if err := wa.SetImage(a.Image); err != nil {
return nil, err
}
if a.OnTriggered != nil {
wa.Triggered().Attach(a.OnTriggered)
}
if a.AssignTo != nil {
*a.AssignTo = wa
}
return wa, nil
}