来自功能的GUI元素不以红色语言显示 [英] GUI elements from a function not being displayed in Red language

查看:107
本文介绍了来自功能的GUI元素不以红色语言显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码试图从函数获取GUI元素:

  mypanelfn:func [] [
collect [
repeat i 10 [
print append copyi in loop:i
keep [t:text] keep append copymessage:i
keep [字段entry
按钮Click[t / text:clicked] return]]]]

view [
do [mypanelfn]]

没有错误消息,并且循环继续,并且还显示一个窗口。但这只是一个没有任何文本,字段或按钮的小空窗口。



这段代码有什么问题?

编辑:放置探针之前 collect 显示(为了清晰起见,我添加了换行符):

 t:textmessage:3fieldentrybuttonClick[t / text:clicked] return 
t:textmessage:4字段entry按钮Click[t / text:clicked]返回
t:textmessage:5fieldentrybuttonClick[t / text:clicked] return


解决方案

你需要独特的名字来表达你想要解决的问题。这里有一个解决方案,而不是撰写

  mypanelfn:func [] [
collect [
repeat i 10 [
tname:to-word rejoin ['ti]
print append copyi in loop:i
keep reduced [to-set-word tname'text] keep append copy消息:我
保持减少[
'字段'输入''按钮'点击'减少[
to-set-path reduce [
tname'text]
clicked]
'return]]]]

我建议您使用命令在控制台中看看他们做了什么。例如。
$ b rejoin ['ti] 创建一个字符串t1与t以及i的(reduced / get-)值。

to-word 改变一个红色(单词)单词 t1



to-setword tname 创建一个设置字 t1:



to-set-path reduce [ tname'text] 创建一个设置路径 t1 / text:


I am using following code to try to get GUI elements from a function:

  mypanelfn: func[] [
    collect[
      repeat i 10 [ 
        print append copy "i in loop: " i
        keep [t: text]  keep append copy "message: " i
        keep [field "entry"    
              button "Click" [t/text: "clicked"] return]]]]

  view [ 
    do [mypanelfn]]

There are no error messages and loop go on all right and a windows is also displayed. But this is only a small empty windows without any text, fields or buttons.

What is wrong with this code?

Edit: putting probe before collect shows (I have added line breaks for clarity):

[t: text "message: 1" field "entry" button "Click" [t/text: "clicked"] return 
t: text "message: 2" field "entry" button "Click" [t/text: "clicked"] return 
t: text "message: 3" field "entry" button "Click" [t/text: "clicked"] return 
t: text "message: 4" field "entry" button "Click" [t/text: "clicked"] return 
t: text "message: 5" field "entry" button "Click" [t/text: "clicked"] return

解决方案

once again; you need unique names for elements you want to address. Here a solution with reduce instead of compose

mypanelfn: func[] [
  collect[
    repeat i 10 [ 
      tname: to-word rejoin ['t i]
      print append copy "i in loop: " i
      keep  reduce [to-set-word tname 'text]  keep append copy "message: " i
      keep reduce [
       'field "entry" 'button "Click"  reduce  [ 
          to-set-path  reduce [
             tname 'text ]
            "clicked" ]
      'return ] ] ] ] 

I recommend that you use the commands in the console to see what they do. E.g.

rejoin ['t i] creates a string "t1"with t and the (reduced/get-)value of i.

to-word changes that to a Red(bol) word t1

to-setword tname creates a set-word t1:

to-set-path reduce [tname 'text ]creates a set-path t1/text:

这篇关于来自功能的GUI元素不以红色语言显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆