當前位置: 首頁>>代碼示例>>Golang>>正文


Golang walk.FileDialog類代碼示例

本文整理匯總了Golang中github.com/lxn/walk.FileDialog的典型用法代碼示例。如果您正苦於以下問題:Golang FileDialog類的具體用法?Golang FileDialog怎麽用?Golang FileDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FileDialog類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: openFileDia

// real open file dialog
func (tmw *TaxMainWindow) openFileDia() error {
	dlg := new(walk.FileDialog)
	dlg.FilePath = tmw.prevFilePath
	dlg.Filter = "Excel Files(*.xls;*.xlsx)|*.xls;*.xlsx"
	dlg.Title = "請選擇Excel文件"

	if ok, err := dlg.ShowOpen(tmw); err != nil {
		return err
	} else if !ok {
		return nil
	}

	// 拿到選擇的文件的路徑放入tmw struct
	tmw.prevFilePath = dlg.FilePath

	fmt.Println(tmw.prevFilePath)
	// pre clear data
	truncateData(vatTable)
	// invoke taxxlsx read and save 2 db
	if iSuc := xls.ReadAndSave(tmw.prevFilePath); iSuc {
		walk.MsgBox(tmw, "成功", "導入成功", walk.MsgBoxIconInformation)
		// 顯示默認列表數據
		model.RestRows(defaDisplayData())
	}
	return nil
}
開發者ID:LaughingVzr,項目名稱:taxrecrd,代碼行數:27,代碼來源:mainfrm.go

示例2: openFile

func (mw *MyDialog) openFile(filetype string) (file string, err error) {
	dlgFile := new(walk.FileDialog)

	switch filetype {
	case "PC助手":
		dlgFile.Filter = "PC助手(*.exe)|*.exe"
		dlgFile.Title = "選擇PC助手"
	case "Android助手":
		dlgFile.Filter = "Android助手(*.apk)|*.apk"
		dlgFile.Title = "選擇Android助手"
	case "Web 數據庫":
		dlgFile.Filter = "Web 數據庫(*.sql)|*.sql"
		dlgFile.Title = "選擇Web 數據庫"
	}

	if ok, err := dlgFile.ShowOpen(mw); err != nil {
		return dlgFile.FilePath, err
	} else if !ok {
		return dlgFile.FilePath, err
	}

	file = dlgFile.FilePath

	return file, nil
}
開發者ID:CodyGuo,項目名稱:Go-Cody,代碼行數:25,代碼來源:upgrideiMan_ui.go

示例3: main

func main() {
	var outTE *walk.TextEdit
	mw := new(MyMainWindow)
	MainWindow{
		Title:    "簡易加密文件",
		AssignTo: &mw.MainWindow,
		MinSize:  Size{300, 140},
		Layout:   VBox{},
		Children: []Widget{
			HSplitter{
				Children: []Widget{
					TextEdit{AssignTo: &outTE, ReadOnly: true},
				},
			},
			PushButton{
				Text: "選擇文件求反",
				OnClicked: func() {
					dlg := new(walk.FileDialog)
					dlg.Title = "選擇文件"
					if ok, err := dlg.ShowOpen(mw); err != nil {
						outTE.SetText(err.Error())
					} else if !ok {
						outTE.SetText("未選擇文件")
					} else {
						fileName := dlg.FilePath
						file, err := os.Open(fileName)
						defer file.Close()
						if err != nil {
							outTE.SetText("未找到待處理文件")
						}
						//讀取文件內容
						plain, _ := ioutil.ReadAll(file)
						//求反
						for i, b := range plain {
							plain[i] = ^b
						}
						//寫入文件
						if fileName[len(fileName)-1:] != "+" {
							fileName += "+"
						} else {
							fileName = fileName[:len(fileName)-1]
						}
						err = ioutil.WriteFile(fileName, plain, 0777)
						if err != nil {
							outTE.SetText(dlg.FilePath + " 保存轉換後文件失敗!")
						} else {
							outTE.SetText(dlg.FilePath + " 文件已轉換!")
						}
					}
				},
			},
		},
	}.Run()
}
開發者ID:duomi520,項目名稱:wswFileTakeBack,代碼行數:54,代碼來源:main.go

示例4: openImage

func (mw *MyMainWindow) openImage() error {
	dlg := new(walk.FileDialog)

	dlg.FilePath = mw.prevFilePath
	dlg.Filter = "Image Files (*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff"
	dlg.Title = "Select an Image"

	if ok, err := dlg.ShowOpen(mw); err != nil {
		return err
	} else if !ok {
		return nil
	}

	mw.prevFilePath = dlg.FilePath

	img, err := walk.NewImageFromFile(dlg.FilePath)
	if err != nil {
		return err
	}

	var succeeded bool
	defer func() {
		if !succeeded {
			img.Dispose()
		}
	}()

	page, err := walk.NewTabPage()
	if err != nil {
		return err
	}

	if page.SetTitle(path.Base(strings.Replace(dlg.FilePath, "\\", "/", -1))); err != nil {
		return err
	}
開發者ID:2105666566,項目名稱:walk,代碼行數:35,代碼來源:imageviewer.go

示例5: browser

// 瀏覽升級包
func (mw *MyWindow) browser() {
	fd := new(walk.FileDialog)
	fd.Title = "選擇iMan升級包"
	fd.Filter = "iMan Files 最大200MB|*"
	fd.FilePath = mw.file

	if _, err := fd.ShowOpen(mw); err != nil {
		log.Fatal(err)
	}

	mw.file = fd.FilePath
}
開發者ID:CodyGuo,項目名稱:Go-Cody,代碼行數:13,代碼來源:main.go

示例6: openImage

func (mw *MyMainWindow) openImage() error {
	dlg := new(walk.FileDialog)

	dlg.FilePath = mw.prevFilePath
	dlg.Filter = "Image Files (*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff"
	dlg.Title = "選擇圖片"

	if ok, err := dlg.ShowOpen(mw); err != nil {
		return err
	} else if !ok {
		return nil
	}

	mw.prevFilePath = dlg.FilePath

	return nil
}
開發者ID:CodyGuo,項目名稱:xcgui,代碼行數:17,代碼來源:imageviewer.go

示例7: openFile

func (mw *MyDialog) openFile() error {
	dlgFile := new(walk.FileDialog)

	dlgFile.FilePath = mw.upgrideFile
	dlgFile.Filter = "iMan Files 最大200MB|*"
	dlgFile.Title = "選擇iMan升級包"

	if ok, err := dlgFile.ShowOpen(mw); err != nil {
		return err
	} else if !ok {
		return nil
	}

	mw.upgrideFile = dlgFile.FilePath

	return nil
}
開發者ID:CodyGuo,項目名稱:Go-Cody,代碼行數:17,代碼來源:upgrideiMan_ui.go

示例8: openFile

func (mw *MyDialog) openFile() error {
	dlgFile := new(walk.FileDialog)

	dlgFile.FilePath = mw.adjFile
	dlgFile.Filter = "附件 (*)|*"
	dlgFile.Title = "選擇附件"

	if ok, err := dlgFile.ShowOpen(mw); err != nil {
		return err
	} else if !ok {
		return nil
	}

	mw.adjFile = dlgFile.FilePath

	return nil
}
開發者ID:CodyGuo,項目名稱:Go-Cody,代碼行數:17,代碼來源:main-ui.go

示例9: CreateVersion_Triggered

/**
 *添加版本的方法
 */
func CreateVersion_Triggered(owner walk.Form, model *xorm.VersionModel) {
	var dlg *walk.Dialog
	var db *walk.DataBinder
	var dph *walk.LineEdit
	var ep walk.ErrorPresenter
	var version = new(xorm.Version)
	var acceptPB, cancelPB *walk.PushButton

	var dialog = Dialog{}
	dialog.AssignTo = &dlg
	dialog.Title = "創建版本"
	dialog.DataBinder = DataBinder{
		AssignTo:       &db,
		DataSource:     version,
		ErrorPresenter: ErrorPresenterRef{&ep},
	}
	dialog.MinSize = Size{300, 200}
	dialog.Layout = VBox{}
	dialog.DefaultButton = &acceptPB
	dialog.CancelButton = &cancelPB
	dirPath := LineEdit{
		AssignTo: &dph,
		Text:     Bind("Path"),
		ReadOnly: true,
	}

	childrens := []Widget{
		Composite{
			Layout: Grid{Columns: 5},
			Children: []Widget{
				Label{
					Text:    "工程:",
					MinSize: Size{42, 0},
				},
				ComboBox{
					MinSize:       Size{108, 0},
					Value:         Bind("ProjectName", SelRequired{}),
					BindingMember: "Key",
					DisplayMember: "Name",
					Model:         xorm.FindAllProjDataCombox(),
				},
				dirPath,
				PushButton{
					Text: "選擇版本",
					OnClicked: func() {
						filDlg := new(walk.FileDialog)
						filDlg.ShowBrowseFolder(owner)
						dph.SetText(filDlg.FilePath)
					},
				},
			},
		},
		Composite{
			Layout: Grid{Columns: 2},
			Children: []Widget{
				Label{
					Text: "名稱:",
				},
				LineEdit{
					Text:      Bind("Name"),
					MaxLength: 10,
				},
				Label{
					Text: "創建者:",
				},
				LineEdit{
					Text:      Bind("CreateUser"),
					MaxLength: 10,
				},
				Label{
					Text: "描述:",
				},
				TextEdit{
					Text:    Bind("Desc"),
					MinSize: Size{300, 50},
				},
				LineErrorPresenter{
					AssignTo:   &ep,
					ColumnSpan: 2,
				},
			},
		},
		Composite{
			Layout: HBox{},
			Children: []Widget{
				HSpacer{},
				PushButton{
					AssignTo: &acceptPB,
					Text:     "保存",
					OnClicked: func() {
						if err := db.Submit(); err != nil {
							log.Print(err)
							return
						}
						xorm.SaveVersionByParam(version.Name, version.CreateUser, version.Desc)
						model.ResetRows()
						dlg.Accept()
//.........這裏部分代碼省略.........
開發者ID:starmoonlove,項目名稱:packutil,代碼行數:101,代碼來源:versionview.go

示例10: showImage

func showImage(owner walk.Form, tabWidget *walk.TabWidget) {
	dlgf := new(walk.FileDialog)
	dlgf.FilePath = ""
	dlgf.Filter = "Image Files (*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff)|*.emf;*.bmp;*.exif;*.gif;*.jpeg;*.jpg;*.png;*.tiff"
	dlgf.Title = "Select an Image"

	if ok, err := dlgf.ShowOpen(owner); err != nil {
		log.Print(err)
	} else if !ok {
		//return nil
	}

	//walk.MsgBox(nil, "文件路徑", dlgf.FilePath, walk.MsgBoxOK)

	img, err := walk.NewImageFromFile(dlgf.FilePath)
	if err != nil {
		log.Print(err)
	}

	var succeeded bool
	defer func() {
		if !succeeded {
			img.Dispose()
		}
	}()

	page, err := walk.NewTabPage()
	if err != nil {
		log.Print(err)
	}

	//if page.SetTitle(path.Base(strings.Replace(dlgf.FilePath, "\\", "/", -1))); err != nil {
	//	log.Print(err)
	//}
	page.SetLayout(walk.NewHBoxLayout())

	defer func() {
		if !succeeded {
			page.Dispose()
		}
	}()

	imageView, err := walk.NewImageView(page)
	if err != nil {
		log.Print(err)
	}

	defer func() {
		if !succeeded {
			imageView.Dispose()
		}
	}()
	imageView.SetImage(img)

	if err := tabWidget.Pages().Add(page); err != nil {
		log.Print(err)
	}

	if err := tabWidget.SetCurrentIndex(tabWidget.Pages().Len() - 1); err != nil {
		log.Print(err)
	}

	succeeded = true
}
開發者ID:xausee,項目名稱:touch,代碼行數:64,代碼來源:win.go


注:本文中的github.com/lxn/walk.FileDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。