明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2520|回复: 12

[基础] 对话框问题

  [复制链接]
发表于 2011-7-18 23:36:36 | 显示全部楼层 |阅读模式
请高手帮我修正一下,如何才能将下拉列表的值付给编辑框,下面是我写的测试代码


(defun c:test()
  (setvar "cmdecho" 0)
  (setq dcl_id (load_dialog "test"))
  (new_dialog "test" dcl_id)
  (if (null t_01)(setq t_1 "8"))
  (set_tile "t_01" t_1)
  (action_tile "t_01" "(setq t_01 $value)")
  (if (null s_01)(setq s01 "2"))
  (set_tile "s_01" s01)
  (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  (start_list "s_01")
  (mapcar 'add_list s_dia_lis)
  (end_list)
  (action_tile "s_01" "(setq s_a (atoi $value))
  (setq s_bb (nth s_a s_dia_lis))
  (set_tile \"s_01\" s_bb)")
  (action_tile "s_01" "(setq s_01 $value)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq what(start_dialog))
  (cond ((= 1 what) (t01))
((= 2 what) (t02))
  )
(setvar "cmdecho" 1)
(princ)
);end defun

//这是对话框文件
test: dialog{label="对话框测试";
:row{
:edit_box{
   label="编辑框:";
   width=3;
   key="t_01";}
:popup_list{
     label="下拉列表:";
     key="s_01";
     width=3;}
}
spacer;
:button{   
    label = "Cancel";
    is_cancel = true;
    key = "cancel";
    width = 8;}
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-7-18 23:50:59 | 显示全部楼层
是你的动作函数有错:应如下:
(action_tile
    "s_01"
    "(setq s_a (atoi $value))
  (setq s_bb (nth s_a s_dia_lis))
  (set_tile \"t_01\" s_bb)"
  )  
 楼主| 发表于 2011-7-18 23:57:19 | 显示全部楼层
本帖最后由 Jack_PC 于 2011-7-18 23:58 编辑
zhynt 发表于 2011-7-18 23:50
是你的动作函数有错:应如下:
(action_tile
    "s_01"


请帮我测试看看,我改了还是不能将下拉列表的值付给编辑框,不知是什么原因
  1. (defun c:test()
  2.   (setvar "cmdecho" 0)
  3.   (setq dcl_id (load_dialog "test"))
  4.   (new_dialog "test" dcl_id)

  5.   (if (null t_01)(setq t_1 "8"))
  6.   (set_tile "t_01" t_1)
  7.   (action_tile "t_01" "(setq t_01 $value)")

  8.   (if (null s_01)(setq s01 "2"))
  9.   (set_tile "s_01" s01)
  10.   (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  11.   (start_list "s_01")
  12.   (mapcar 'add_list s_dia_lis)
  13.   (end_list)
  14.   (action_tile "s_01" "(setq s_a (atoi $value))
  15.   (setq s_bb (nth s_a s_dia_lis))
  16.   (set_tile "t_01" s_bb)");;;这里已改
  17.   (action_tile "s_01" "(setq s_01 $value)")

  18.   (action_tile "cancel" "(done_dialog 0)")
  19.   (setq what(start_dialog))
  20.   (cond ((= 1 what) (t01))
  21.         ((= 2 what) (t02))
  22.   )
  23. (setvar "cmdecho" 1)
  24. (princ)
  25. );end defun
发表于 2011-7-19 00:00:51 | 显示全部楼层
(set_tile \"t_01\" s_bb)")
为了醒目,我加了颜色代码,程序中请将其去掉:
(set_tile \“t_01\" s_bb)")
 楼主| 发表于 2011-7-19 00:12:06 | 显示全部楼层
本帖最后由 Jack_PC 于 2011-7-19 00:12 编辑
zhynt 发表于 2011-7-19 00:00
(set_tile \"t_01\" s_bb)")
为了醒目,我加了颜色代码,程序中请将其去掉:
(set_tile \“t_01\" s_bb)" ...


我将此句去掉了,测试还是不能将下拉列表的值付给编辑框中,刚接触LISP还不会,你能够帮我将程序完整一下
(defun c:test()
  (setvar "cmdecho" 0)
  (setq dcl_id (load_dialog "test"))
  (new_dialog "test" dcl_id)
  (if (null t_01)(setq t_1 "8"))
  (set_tile "t_01" t_1)
  (action_tile "t_01" "(setq t_01 $value)")
  (if (null s_01)(setq s01 "2"))
  (set_tile "s_01" s01)
  (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  (start_list "s_01")
  (mapcar 'add_list s_dia_lis)
  (end_list)
  (action_tile "s_01" "(setq s_a (atoi $value))
  (setq s_bb (nth s_a s_dia_lis))
  ;;;(set_tile \"t_01\" s_bb)"
)

  (action_tile "s_01" "(setq s_01 $value)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq what(start_dialog))
  (cond ((= 1 what) (t01))
((= 2 what) (t02))
  )
(setvar "cmdecho" 1)
(princ)
);end defun

发表于 2011-7-19 00:15:20 | 显示全部楼层
没有叫你将他去掉啊。代码如下。
(defun c:test()
  (setvar "cmdecho" 0)
  (setq dcl_id (load_dialog "test"))
  (new_dialog "test" dcl_id)
  (if (null t_01)(setq t_1 "8"))
  (set_tile "t_01" t_1)
  (action_tile "t_01" "(setq t_01 $value)")
  (if (null s_01)(setq s01 "2"))
  (set_tile "s_01" s01)
  (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  (start_list "s_01")
  (mapcar 'add_list s_dia_lis)
  (end_list)
  (action_tile "s_01" "(setq s_a (atoi $value))
  (setq s_bb (nth s_a s_dia_lis))
  (set_tile \"t_01\" s_bb)"
)

  (action_tile "s_01" "(setq s_01 $value)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq what(start_dialog))
  (cond ((= 1 what) (t01))
((= 2 what) (t02))
  )
(setvar "cmdecho" 1)
(princ)
);end defun

 楼主| 发表于 2011-7-19 00:20:45 | 显示全部楼层
zhynt 发表于 2011-7-19 00:15
没有叫你将他去掉啊。代码如下。
(defun c:test()
  (setvar "cmdecho" 0)

测试了一下,当我点下拉列表时那编辑框还是没有反映,

我需要的效果是点下拉列表时,那个编辑框的值跟着变成下拉列表选择的值
发表于 2011-7-19 00:23:39 | 显示全部楼层
不会吧,我测试的好的。

  1. (defun c:test ()
  2.   (setvar "cmdecho" 0)
  3.   (setq dcl_id (load_dialog "test"))
  4.   (new_dialog "test" dcl_id)
  5.   (if (null t_01)
  6.     (setq t_1 "8")
  7.   )
  8.   (set_tile "t_01" t_1)
  9.   (action_tile "t_01" "(setq t_01 $value)(set_tile "s_01" t_01)")
  10.   (if (null s_01)
  11.     (setq s01 "2")
  12.   )
  13.   (set_tile "s_01" s01)
  14.   (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  15.   (start_list "s_01")
  16.   (mapcar 'add_list s_dia_lis)
  17.   (end_list)
  18.   (action_tile
  19.     "s_01"
  20.     "(setq s_a (atoi $value))
  21.   (setq s_bb (nth s_a s_dia_lis))
  22.   (set_tile "t_01" s_bb)"
  23.   )  
  24.   (action_tile "cancel" "(done_dialog 0)")
  25.   (setq what (start_dialog))
  26.   (cond        ((= 1 what) (t01))
  27.         ((= 2 what) (t02))
  28.   )
  29.   (setvar "cmdecho" 1)
  30.   (princ)
  31. )                                        ;end defun

 楼主| 发表于 2011-7-19 00:28:00 | 显示全部楼层
zhynt 发表于 2011-7-19 00:23
不会吧,我测试的好的。

现在是可以,但是下拉列表和编辑框的值不能记忆上一次输入,如果做到记忆上一次输入
发表于 2011-7-19 01:36:53 | 显示全部楼层
可能有点乱,你自己整理一下。

  1. (setq ttt "8")
  2. (setq sss "0")
  3. (setq key t)
  4. (defun t_01 ()
  5.   (setq key nil)
  6.   (if (= (member t_1 s_dia_lis) nil)
  7.     (progn
  8.       (setq s_dia_lis (cons t_1 s_dia_lis))
  9.       (start_list "s_01" 1)
  10.       (mapcar 'add_list s_dia_lis)
  11.       (end_list)
  12.       (set_tile "s_01" "0")
  13.     )
  14.   )
  15. )
  16. (defun c:test (/ )
  17.   (if (null t_1)
  18.     (setq t_1 ttt)(setq ttt t_1)
  19.   )
  20.   (if (null s_a)
  21.     (setq s_a sss)(setq sss s_a)
  22.   )
  23.   (if key
  24.     (setq s_dia_lis (list "2" "4" "5" "6" "8" "10"))
  25.   )
  26.   (setvar "cmdecho" 0)
  27.   (setq dcl_id (load_dialog "test"))
  28.   (new_dialog "test" dcl_id)  
  29.   (set_tile "t_01" t_1)  
  30.   (set_tile "s_01" (rtos s_a))
  31.   (start_list "s_01")
  32.   (mapcar 'add_list s_dia_lis)
  33.   (end_list)
  34.   (action_tile "s_01" "(setq s_a (atoi $value))(setq s_1 (nth s_a s_dia_lis))(set_tile "t_01" s_1)(setq t_1 s_1)")
  35.   (action_tile "t_01" "(setq t_1 (get_tile "t_01"))(t_01)")  
  36.   (action_tile "cancel" "(done_dialog 0)")
  37.   (setq what (start_dialog))
  38.   (cond        ((= 1 what) (t01))
  39.         ((= 2 what) (t02))
  40.   )
  41.   (setvar "cmdecho" 1)
  42.   (princ)
  43. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-7-24 05:19 , Processed in 0.199474 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表