求工具箱面板修改方法
以下这个工具箱面板是在论坛里找到的,就是按钮的长度太长(按钮上文字前后的空距太大),修改了width=10也不起作用,不知道应该怎么改,特来求助!!!(defun c:ttt ()
(setq ln (list ;;这里是你要加载的程序
"G:\\面板\\程序1.lsp"
"G:\\面板\\程序2.lsp"
"G:\\面板\\程序3.lsp"
))
(mapcar '(lambda(x) (vl-catch-all-apply 'vl-load-all (list x))) ln)
(make_panel
(list
(list "第一列" ;;第一列
(list "程序1" "cx1") ;(list按钮标签运行的命令)
(list "程序2" "cx2")
(list "程序3" "cx3")
);;第一列
(list "第二列";第二列
(list "功能名称" "命令快捷键") ;(list按钮标签运行的命令)
(list "直线" "line")
) ;;第二列 复制时注意起止括号,LISP括号必须成对..
(list "第三列";都可以自己修改
(list "圆" "CIRCLE")
)
)
)
(princ)
)
(defun make_panel ( menulist / n num_nobut num_button nn nnn menuname val_lst add_dclrow tt order_lst in num_image)
(defun add_dclrow ( dstr / ) (if dstr (setq val_lst (cons dstr val_lst))))
(setq menuname (strcat (vl-filename-mktemp) "temp_pannel.dcl"));
(setq rq (menucmd "M=$(edtime,$(getvar,date),YYYY年MO月DD日)"))
(add_dclrow "curbutton:button{width=10;vertical_margin=none;vertical_margin=none;}")
(add_dclrow "curimage:image{width=10;height=0.2;vertical_margin=none;vertical_margin=none;}")
(add_dclrow "curpanel:dialog{label=\"我的面板\";alignment=centered;vertical_margin=none;horizontal_margin=none;")
(add_dclrow "spacer;")
(add_dclrow ":column{")
(add_dclrow ":row{")
(setq len (apply 'max (mapcar 'length menulist))
order_lst (apply 'append (mapcar 'cdr menulist))
num_button 0
num_nobut 0
in 0
num_image 0
)
(foreach nn menulist
(setq in 0)
(add_dclrow (strcat " : boxed_column{label=\"" (car nn) "\";vertical_margin=none; horizontal_margin=none;"))
(foreach nnn (cdr nn)
(setq num_button (1+ num_button)
in (1+ in)
num_image (1+ num_image)
tt (car nnn)
tt (if tt tt "")
)
(add_dclrow (strcat ":curbutton{label=\"" tt "\";key=\"but" (itoa num_button) "\";}"))
(if (= 4 in)
(progn (add_dclrow (strcat ":curimage{key=\"ima" (itoa num_image) "\";}"))
(setq in 0)
)
)
)
(repeat (- len (length nn))
(setq num_nobut (1+ num_nobut)
in (1+ in)
num_image (1+ num_image)
)
(add_dclrow (strcat " : curbutton{key=\"butno" (itoa num_nobut) "\";}"))
(if (= 4 in)
(progn (add_dclrow (strcat ":curimage{key=\"ima" (itoa num_image) "\";}"))
(setq in 0)
)
)
)
(add_dclrow "spacer;}")
)
(add_dclrow "}:button{label=\"关闭\";key=\"cancel\";is_cancel=true;width=10;fixed_width=true;alignment=centered;}}")
(add_dclrow (strcat ":concatenation {:text_part {label=\"作者:QQ690779088 今日日期:\";}:text {width=12;label=\"" rq "\";}:text_part{label=\" \";}}}"))
(vl-file-delete menuname)
(setq nn (open menuname "w"))
(foreach n (reverse val_lst) (write-line n nn))
(close nn)
(setq nnn (load_dialog menuname))
(if (not (new_dialog "curpanel" nnn)) (exit))
(setq n 0)
(repeat num_nobut (mode_tile (strcat "butno" (itoa num_nobut)) 1) (setq num_nobut (1- num_nobut)))
(foreach nn menulist
(foreach nnn (cdr nn)
(setq n (1+ n)
tt (car nnn)
tt (if tt tt "")
)
(if (= tt "")
(mode_tile (strcat "but" (itoa n)) 1)
(action_tile (strcat "but" (itoa n)) (strcat "\(done_dialog " (itoa n) "\)"))
)
)
)
(setq nn (start_dialog))
(unload_dialog nnn)
(vl-file-delete menuname)
(if (> nn 0)
(progn (setq tt (cadr (nth (1- nn) order_lst)))
(princ "\n")
(if (= (eval (read (strcat "(type c:" tt ")"))) 'SUBR)
(eval (read (strcat "(c:" tt ")")))
(vl-cmdf tt)
)
)
)
)
本帖最后由 kongel 于 2020-8-8 12:24 编辑
加上这么一句fixed_width=true;
本帖最后由 huxu823 于 2020-8-8 13:06 编辑
kongel 发表于 2020-8-8 12:22
加上这么一句fixed_width=true;
加了fixed_width=true
按钮上的文字如果长度不一样,会导致按钮长度也不一样,如下图:
http://chuantu.xyz/t6/740/1596863031x1700340427.png
有没有不管文字长度有没有差别,按钮长度是统一长度的办法?
因为我要写进去的按钮有点多,无法保证每一个按钮上的文字长度是完全一样的
短的加空格使文字一样长
页:
[1]