本文整理匯總了Golang中github.com/lxn/walk.MainWindow.Run方法的典型用法代碼示例。如果您正苦於以下問題:Golang MainWindow.Run方法的具體用法?Golang MainWindow.Run怎麽用?Golang MainWindow.Run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxn/walk.MainWindow
的用法示例。
在下文中一共展示了MainWindow.Run方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
var tool *walk.Action
var menutool *walk.Menu
var mw *walk.MainWindow
mw.SetMaximizeBox(false)
mw.SetFixedSize(true)
mw, _ = walk.NewMainWindowCody()
mw.SetTitle("測試")
mw.SetSize(walk.Size{300, 200})
menutool, _ = walk.NewMenu()
tool = walk.NewMenuAction(menutool)
tool.SetText("文件")
open := walk.NewAction()
open.SetText("打開")
exit := walk.NewAction()
exit.SetText("退出")
menutool.Actions().Add(open)
menutool.Actions().Add(exit)
men2, _ := walk.NewMenu()
too2 := walk.NewMenuAction(men2)
too2.SetText("工具")
mw.Menu().Actions().Add(tool)
mw.Menu().Actions().Add(too2)
mw.Show()
mw.Run()
}
示例2: WebviewWindow
// Spawns a window containing a webview pointed at the given URL, and waits for
// it to be closed. If the webview cannot be opened, returns an error
// immediately.
func WebviewWindow(serverURL string) (e error) {
var mainWindow *walk.MainWindow
var webView *walk.WebView
log.Print("Starting to create webview window")
if err := (declarative.MainWindow{
AssignTo: &mainWindow,
Title: "WebCmd Webview",
MinSize: declarative.Size{600, 400},
Size: declarative.Size{800, 600},
Visible: true,
Layout: declarative.HBox{},
Children: []declarative.Widget{
declarative.WebView{
AssignTo: &webView,
},
},
}.Create()); err != nil {
log.Println("Error while creating window. Usually happens when " +
"compiled without -ldflags=\"-Hwindowsgui\" or a manifest. " +
"see make.bat to compile with window support on windows.")
return errors.New("Unable to create webview window")
}
log.Print("Create complete, initializing webView with URL ", serverURL)
webView.SetURL(serverURL)
mainWindow.Run()
log.Print("Webview closed.")
return nil
}
示例3: main
func main() {
var mw *walk.MainWindow
if err := (MainWindow{
AssignTo: &mw,
Title: "Walk LogView Example",
MinSize: Size{320, 240},
Size: Size{400, 600},
Layout: VBox{MarginsZero: true},
}.Create()); err != nil {
log.Fatal(err)
}
lv, err := NewLogView(mw)
if err != nil {
log.Fatal(err)
}
lv.PostAppendText("XXX")
log.SetOutput(lv)
go func() {
for i := 0; i < 10000; i++ {
time.Sleep(100 * time.Millisecond)
log.Println("Text" + "\r\n")
}
}()
mw.Run()
}
示例4: main
func main() {
var mw *walk.MainWindow
if err := (MainWindow{
AssignTo: &mw,
Title: "Walk External Widgets Example",
Size: Size{400, 300},
Layout: HBox{},
}).Create(); err != nil {
log.Fatal(err)
}
for _, name := range []string{"a", "b", "c"} {
if w, err := NewMyWidget(mw); err != nil {
log.Fatal(err)
} else {
w.SetName(name)
}
}
mpb, err := NewMyPushButton(mw)
if err != nil {
log.Fatal(err)
}
mpb.SetText("MyPushButton")
mw.Run()
}
示例5: main
func main() {
var mw *walk.MainWindow
var c1 *walk.Composite
var c2 *walk.Composite
bmp, err := walk.NewBitmapFromFile("../../img/plus.png")
if err != nil {
panic(err)
}
defer bmp.Dispose()
MainWindow{
AssignTo: &mw,
Title: "Background Example",
Layout: VBox{MarginsZero: true},
MinSize: Size{300, 400},
Children: []Widget{
Composite{
AssignTo: &c1,
Layout: VBox{},
Children: []Widget{
TextEdit{},
},
},
Composite{
AssignTo: &c2,
Layout: VBox{},
Children: []Widget{
TextEdit{},
},
},
ImageView{
Image: bmp,
},
},
}.Create()
scb, err := walk.NewSolidColorBrush(walk.RGB(255, 0, 0))
if err != nil {
panic(err)
}
defer scb.Dispose()
c1.SetBackground(scb)
bmb, err := walk.NewBitmapBrush(bmp)
if err != nil {
panic(err)
}
defer bmb.Dispose()
c2.SetBackground(bmb)
mw.Show()
mw.Run()
}
示例6: 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()
}
示例7: Run
func Run() {
var mw *walk.MainWindow
var db *walk.DataBinder
var ep walk.ErrorPresenter
var spiderMenu = NewSpiderMenu(spider.Menu)
if err := (MainWindow{
AssignTo: &mw,
DataBinder: DataBinder{
AssignTo: &db,
DataSource: Input,
ErrorPresenter: ErrorPresenterRef{&ep},
},
Title: config.APP_NAME,
MinSize: Size{1100, 700},
Layout: VBox{},
Children: []Widget{
// 任務列表
HSplitter{
Children: []Widget{
TableView{
MinSize: Size{550, 400},
AlternatingRowBGColor: walk.RGB(255, 255, 224),
CheckBoxes: true,
ColumnsOrderable: true,
Columns: []TableViewColumn{
{Title: "#", Width: 45},
{Title: "任務", Width: 110 /*, Format: "%.2f", Alignment: AlignFar*/},
{Title: "描述", Width: 370},
},
Model: spiderMenu,
},
// 關鍵詞
VSplitter{
MinSize: Size{550, 400},
Children: []Widget{
VSplitter{
Children: []Widget{
Label{
Text: "關鍵詞:(多任務之間以 | 隔開,選填)",
},
LineEdit{
Text: Bind("Keywords"),
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "采集頁數:(選填)",
},
NumberEdit{
Value: Bind("MaxPage"),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*並發協程:(1~99999)",
},
NumberEdit{
Value: Bind("ThreadNum", Range{1, 99999}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*分批輸出大小:(1~5,000,000 條數據)",
},
NumberEdit{
Value: Bind("DockerCap", Range{1, 5000000}),
Suffix: "",
Decimals: 0,
},
},
},
VSplitter{
Children: []Widget{
Label{
Text: "*間隔基準:",
},
ComboBox{
Value: Bind("BaseSleeptime", SelRequired{}),
BindingMember: "Uint",
DisplayMember: "Key",
Model: GUIOpt.SleepTime,
},
},
},
//.........這裏部分代碼省略.........
示例8: main
func main() {
var mainWindow *walk.MainWindow
var treeView *walk.TreeView
var tableView *walk.TableView
var webView *walk.WebView
treeModel, err := NewDirectoryTreeModel()
if err != nil {
log.Fatal(err)
}
tableModel := NewFileInfoModel()
if err := (MainWindow{
AssignTo: &mainWindow,
Title: "Walk File Browser Example",
MinSize: Size{600, 400},
Size: Size{800, 600},
Layout: HBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TreeView{
AssignTo: &treeView,
Model: treeModel,
OnCurrentItemChanged: func() {
dir := treeView.CurrentItem().(*Directory)
if err := tableModel.SetDirPath(dir.Path()); err != nil {
walk.MsgBox(
mainWindow,
"Error",
err.Error(),
walk.MsgBoxOK|walk.MsgBoxIconError)
}
},
},
TableView{
AssignTo: &tableView,
Columns: []TableViewColumn{
TableViewColumn{
Title: "Name",
DataMember: "Name",
Width: 200,
},
TableViewColumn{
Title: "Size",
DataMember: "Size",
Format: "%d",
Alignment: AlignFar,
Width: 80,
},
TableViewColumn{
Title: "Modified",
DataMember: "Modified",
Format: "2006-01-02 15:04:05",
Width: 120,
},
},
Model: tableModel,
OnCurrentIndexChanged: func() {
var url string
if index := tableView.CurrentIndex(); index > -1 {
name := tableModel.items[index].Name
dir := treeView.CurrentItem().(*Directory)
url = filepath.Join(dir.Path(), name)
}
webView.SetURL(url)
},
},
WebView{
AssignTo: &webView,
},
},
},
},
}.Create()); err != nil {
log.Fatal(err)
}
mainWindow.Run()
}