Go language use Go-sciter to create desktop Apps (vii) View object common methods, file selection, window popup, request

Source: Internet
Author: User
Tags file url

For a detailed document of the View object, see:

Https://sciter.com/docs/content/sciter/View.htm

The demo9.html code is as follows:

<!     DOCTYPE html>

The

Demo9.go code is as follows:

Package Main;import ("Github.com/sciter-sdk/go-sciter/window" "Github.com/sciter-sdk/go-sciter" "Log" "OS" "Strings" "Path/filepath" "Io/ioutil" "FMT") Func Deffunc (w *window. Window) {//Register dump function for easy printing of data w in tis script. Definefunction ("Dump", func (args ... *sciter). Value) *sciter. Value {for _, V: = Range args {fmt. Print (v.string () + "");} Fmt. Println (); return sciter. Nullvalue ();}); /process file Move W. Definefunction ("MoveFile", func (args ... *sciter). Value) *sciter. Value {file: = Args[0]. String (); folder: = Args[1]. String ();//Remove the File://file = strings to the left of the path. Trimleft (file, "file://");//Get file name filename: = filepath. Base (file);//Read the data of files, err: = Ioutil. ReadFile (file); if err! = Nil {return sciter. NewValue (Err. Error ());} Write file Data err = Ioutil. WriteFile (filepath. Join (folder, fileName), data, OS. Modeperm); If err = = Nil {//delete original file OS. Remove (file); return sciter. NewValue ("mobile Success");} else {return sciter. NewValue ("Move Failed");}}); Func Main () {W, Err: = window. New (Sciter. Defaultwindowcreateflag, Sciter. Defaultrect); if err! = Nil {log. Fatal (err);} W. LoadFile ("demo9.html"); W.settitle ("View Object Learning");d Effunc (w); W.show (); W.run ();}

The results appear as follows:

Go language use Go-sciter to create desktop Apps (vii) View object common methods, file selection, window popup, request

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.