About package lxn/walk

164 views
Skip to first unread message

洪嘉鴻

unread,
Oct 9, 2019, 10:25:06 AM10/9/19
to golang-nuts
Hello everyone:
       I'm a beginner for golang with Win10. Now I'm trying to write an user interface. The version of the golang which I am using is 1.12.9. Here are some problems that I'm encountering:

1. How to append text with a new line?
2. How to output variables as the "fmt.Println" function? (Ex:   fmt.Println("The initial number is:", input)) 
3. How to implement text edit as the "fmt.Scanf" function?
4. How to implement with bottoms? (Ex: There are 3 bottoms, if the third bottom is clicked, the three bottoms will disappear and then appear 4 new bottoms to let the user choose.)

Here is the code for the problems above, where the code is with lots of errors
Any help is appreciated.
Thank you very much!
Max
UI-test.go

HaWe

unread,
Oct 10, 2019, 4:42:35 AM10/10/19
to golang-nuts
Don't know about the lnx package. And I didn't check your code.
But I can answer beginner's questions:

1.  The plus sign means concatenation for strings.
    var s = "text"
    s += "\n"
2. fmt.Println prints to standard output, but fmt.Sprintln prints to a string.
3. Similar answer: Use fmt.Sscanf.

Ahh ... and you might like the word 'button' better than 'bottom' :-)

Jake Montgomery

unread,
Oct 10, 2019, 11:44:09 AM10/10/19
to golang-nuts
Welcome Max,
 
First a tip. It is easier for people to view your code samples if you post them in the playground. Even though this code will not run in the playground, due to the imports, its a nice way for people to quickly see what you are talking about.

The code you have provided does not compile. It would be much easier to help you if I could try running what you have. So I suggest always making sure your samples compile before posting.

I'm note sure what you experience level is, but UI code can be complicated and hard to debug and diagnose. So if you are new to go, I suggesting doing some command line projects first to get comfortable with the language.

2. How to output variables as the "fmt.Println" function? (Ex:   fmt.Println("The initial number is:", input))

I think you want to use fmt.Sprintf to get a string to then pass to AppendText:
outTE.AppendText(fmt.Sprintf("The initial number is: %d", initial))

3. How to implement text edit as the "fmt.Scanf" function?
 
You want to get the text from the edit box using it's Text() function then call Sscanf().

4. How to implement with bottoms?

(Its buttons, not bottoms.) There are a bunch of examples that come with walk. See https://github.com/lxn/walk/tree/master/examples. The documentation on the library ios not great. I suggest you build all the examples, and look at the ones that do something like what you are trying to do.

 - God Luck
Message has been deleted

洪嘉鴻

unread,
Oct 13, 2019, 9:11:00 PM10/13/19
to golang-nuts
OK, I'll try them.
Yes, the word should be "button", not "bottom".
I don't think the documentation on the library is clear, either.
Thanks for your suggestions!

Jake Montgomery於 2019年10月10日星期四 UTC+8下午11時44分09秒寫道:
Message has been deleted
Message has been deleted

洪嘉鴻

unread,
Oct 14, 2019, 2:44:02 AM10/14/19
to golang-nuts
OK, I'll try them.
However, the "\n" I used didn't work.
outTE.AppendText("Hello World !\n")
outTE
.AppendText("Nice to meet you !")
The output on the text edit shows "Hello World ! Nice to meet you !"
But when I use "\r\n", it works!
Yes, the word should be "button", not "bottom".
Thanks for your help!

HaWe於 2019年10月10日星期四 UTC+8下午4時42分35秒寫道:
Message has been deleted

洪嘉鴻

unread,
Oct 14, 2019, 5:15:33 AM10/14/19
to golang-nuts
Hello everyone:

However, there is still a problem that I'm encountering:
Is there any examples about tree diagram with buttons for references? 
Ex: When we install software, there are multiple choices for users to choose, and then click "Next" buttons, until the installation is finished.
Reply all
Reply to author
Forward
0 new messages