本文整理匯總了Golang中github.com/lxn/walk.MainWindow.SetIcon方法的典型用法代碼示例。如果您正苦於以下問題:Golang MainWindow.SetIcon方法的具體用法?Golang MainWindow.SetIcon怎麽用?Golang MainWindow.SetIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.MainWindow
的用法示例。
在下文中一共展示了MainWindow.SetIcon方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
var mw *walk.MainWindow
var windowIcon *walk.Icon
counter := 0
if _, err := (MainWindow{
AssignTo: &mw,
Title: "Walk Image Icon Example",
Layout: HBox{},
Children: []Widget{
HSpacer{},
PushButton{
Text: "Push me",
OnClicked: func() {
ic, err := walk.NewIconFromImage(makeDigitImage(counter))
if err != nil {
return
}
counter++
mw.SetIcon(ic)
if windowIcon != nil {
windowIcon.Dispose()
}
windowIcon = ic
},
},
HSpacer{},
},
}.Run()); err != nil {
log.Fatal(err)
}
}
示例2: main
// Main entry and GUI construction
func main() {
LANG = queryRegLayoutId(LANG_ID)
var (
mw *walk.MainWindow
currentLayout = getKeyboardLayout() // Get current system layout.
layoutPresent = checkLanguage() // Check if installed language is present and can be loaded.
triggered = true
infoText string
ldtMain *walk.LineEdit
btnMain *walk.PushButton
)
if layoutPresent {
infoText = INFO_TEXT
} else {
infoText = "The layout does not seem to be present on your system. Please install it first."
}
MainWindow{
AssignTo: &mw,
Title: "kasahorow " + LANG_STRING + " Writer",
MaxSize: Size{600, 200},
MinSize: Size{600, 200},
Layout: VBox{},
Children: []Widget{
MultilineLabel{Text: infoText},
LineEdit{AssignTo: &ldtMain},
PushButton{
AssignTo: &btnMain,
Enabled: layoutPresent,
Text: "Switch back to default layout.",
OnClicked: func() {
if triggered {
triggered = false
activateKeyboardLayout(currentLayout, KFL_SETFORPROCESS)
btnMain.SetText("Switch to " + LANG_STRING + ".")
} else {
triggered = true
loadLanguage()
btnMain.SetText("Switch back to default layout.")
}
},
},
},
}.Create()
if layoutPresent {
mw.Synchronize(loadLanguage) // Load new layout in main GUI thread.
}
ic, _ := walk.NewIconFromResource("kasahorow")
mw.SetIcon(ic)
mw.Run()
}
示例3: Run
//.........這裏部分代碼省略.........
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*間隔基準:",
},
ComboBox{
Value: Bind("BaseSleeptime", SelRequired{}),
BindingMember: "Uint",
DisplayMember: "Key",
Model: GUIOpt.SleepTime,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*隨機延遲:",
},
ComboBox{
Value: Bind("RandomSleepPeriod", SelRequired{}),
BindingMember: "Uint",
DisplayMember: "Key",
Model: GUIOpt.SleepTime,
},
},
},
RadioButtonGroupBox{
ColumnSpan: 2,
Title: "*輸出方式",
Layout: HBox{},
DataMember: "OutType",
Buttons: []RadioButton{
{Text: GUIOpt.OutType[0].Key, Value: GUIOpt.OutType[0].String},
{Text: GUIOpt.OutType[1].Key, Value: GUIOpt.OutType[1].String},
{Text: GUIOpt.OutType[2].Key, Value: GUIOpt.OutType[2].String},
},
},
},
},
},
},
Composite{
Layout: HBox{},
Children: []Widget{
// 必填項錯誤檢查
LineErrorPresenter{
AssignTo: &ep,
ColumnSpan: 2,
},
PushButton{
Text: "開始抓取",
AssignTo: &toggleSpecialModePB,
OnClicked: func() {
if toggleSpecialModePB.Text() == "取消" {
toggleSpecialModePB.SetEnabled(false)
toggleSpecialModePB.SetText("取消中…")
Stop()
} else {
if err := db.Submit(); err != nil {
log.Print(err)
return
}
Input.Spiders = spiderMenu.GetChecked()
if len(Input.Spiders) == 0 {
return
}
toggleSpecialModePB.SetText("取消")
Start()
}
},
},
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
// 綁定log輸出界麵
lv, err := NewLogView(mw)
if err != nil {
log.Fatal(err)
}
log.SetOutput(lv)
if icon, err := walk.NewIconFromResource("ICON"); err == nil {
mw.SetIcon(icon)
}
// 運行窗體程序
mw.Run()
}
示例4: main
func main() {
fout, _ := os.Create("dialer.log")
defer fout.Close()
bo := bufio.NewWriter(fout)
defer bo.Flush()
util.INFO.SetOutput(bo)
util.ERROR.SetOutput(bo)
bin, err := ioutil.ReadFile("config.json")
if err == nil {
json.Unmarshal(bin, config)
} else {
util.ERROR.Log(err)
err = nil
}
var usr, pwd *walk.LineEdit
var raddr, rusr, rpwd *walk.LineEdit
var lb, rb *walk.PushButton
var mode *walk.ComboBox
var mw *walk.MainWindow
var db *walk.DataBinder
var laddr, lusr, lpwd *walk.Splitter
go func() {
for mw == nil {
runtime.Gosched()
}
ic, err := walk.NewIconFromResourceId(6)
if err == nil {
// func onLoad() {
db.SetAutoSubmit(true)
mw.SetIcon(ic)
switch config.RouterType {
case "hiwifi":
laddr.SetVisible(true)
lusr.SetVisible(false)
lpwd.SetVisible(true)
case "openwrt":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
case "asus":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
default:
laddr.SetVisible(false)
lusr.SetVisible(false)
lpwd.SetVisible(false)
}
mw.SetSize(walk.Size{0, 0})
// }
}
}()
MainWindow{
AssignTo: &mw,
Title: TITLE,
MinSize: Size{340, 0},
Layout: VBox{},
DataBinder: DataBinder{
AssignTo: &db,
DataSource: config,
},
Children: []Widget{
HSplitter{
Children: []Widget{
Label{Text: "用戶名", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("Username"), AssignTo: &usr, MaxSize: Size{0, 20}},
}, MaxSize: Size{0, 20},
},
HSplitter{
Children: []Widget{
Label{Text: "密碼", MaxSize: Size{60, 20}},
LineEdit{Text: Bind("Password"), AssignTo: &pwd, MaxSize: Size{0, 20}, PasswordMode: true,
OnMouseDown: func(x, y int, button walk.MouseButton) {
pwd.SetPasswordMode(false)
},
OnMouseUp: func(x, y int, button walk.MouseButton) {
pwd.SetPasswordMode(true)
},
},
}, MaxSize: Size{0, 20},
},
HSplitter{
Children: []Widget{
Label{Text: "模式", MaxSize: Size{60, 20}},
ComboBox{AssignTo: &mode,
Editable: true, Value: Bind("RouterType"),
Model: []string{"local", "10.0.x.x(手動填寫)", "openwrt", "hiwifi", "asus"},
MaxSize: Size{0, 20},
OnCurrentIndexChanged: func() {
switch mode.CurrentIndex() {
case 2: //"openwrt":
laddr.SetVisible(true)
lusr.SetVisible(true)
lpwd.SetVisible(true)
case 3: //"hiwifi":
config.RouterAddr = "192.168.199.1"
laddr.SetVisible(true)
lusr.SetVisible(false)
//.........這裏部分代碼省略.........
示例5: main
func main() {
var le, le2 *walk.LineEdit
var lb1, lb2 *walk.Label
var ck1 *walk.CheckBox
var mw *walk.MainWindow
copytext, _ := walk.Clipboard().Text()
updateIcon := func() {
mainIcon, err := walk.NewIconFromResource("101")
if err != nil {
// do some work
}
mw.SetIcon(mainIcon)
}
if err := (MainWindow{
AssignTo: &mw,
Title: "模板下載器",
MinSize: Size{400, 100},
Layout: VBox{},
Children: []Widget{
CheckBox{
AssignTo: &ck1,
Name: "cksnap",
Text: "帶截圖抓取",
Checked: false,
},
Label{
AssignTo: &lb1,
Text: "網址",
},
LineEdit{
AssignTo: &le,
Text: copytext,
},
Label{
AssignTo: &lb2,
Text: "保存目錄",
},
LineEdit{
AssignTo: &le2,
Text: `D:\APMServ5.2.6\www\htdocs\down\tpls\`,
},
PushButton{
Text: "開始抓取",
OnClicked: func() {
fmt.Println(ck1.Checked())
if ck1.Checked() {
command := flag.String("cmd", "phantomjs", "Set the command.")
patharr := strings.Split(le2.Text(), "\\")
args := flag.String("args", "rasterize.js "+le.Text()+" "+le2.Text()+"\\"+patharr[len(patharr)-1]+".png", "Set the args. (separated by spaces)")
var argArray []string
if *args != "" {
argArray = strings.Split(*args, " ")
} else {
argArray = make([]string, 0)
}
flag.Parse()
cmd := exec.Command(*command, argArray...)
buf, err := cmd.Output()
if err != nil {
fmt.Fprintf(os.Stderr, "The command failed to perform: %s (Command: %s, Arguments: %s)", err, *command, *args)
return
}
fmt.Fprintf(os.Stdout, "Result: %s", buf)
}
getTemplate(le.Text(), le2.Text())
},
},