質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
LISP

LISPはプログラミング言語の一種であり、関数型言語に分類されています。 特徴として、括弧を多様する独特の構文を持ちます。

Q&A

解決済

1回答

1556閲覧

LTKのcheck-buttonの使い方を教えていただきたい

kamuycikap

総合スコア135

LISP

LISPはプログラミング言語の一種であり、関数型言語に分類されています。 特徴として、括弧を多様する独特の構文を持ちます。

0グッド

0クリップ

投稿2018/05/26 16:42

CommonLisp:ClozureCL
OS:LinuxMint18 MATE

軽量GUIライブラリであるLTKを試しています。
「ボタンをクリックしたら、check-buttonをONにする」
という処理を実現したいのですが、マニュアルの意味がわからないのと、ltk.lispに処理が書かれていないので、どうすればよいか分からず悩んでおります。

Tclであれば、「.cbtn1 select」という具合で、selectでON/OFFできるのですが、LTKではどうすれば良いのでしょうか。

マニュアルには

The following generic functions are defined on widgets: (value widget) Reads/sets the value of the widget. Applicable for: check-button, radio-button, menucheckbutton, menuradiobutton, scale. (text widget) Reads/sets the text of the widget. Depending on the wid- get, this can be text displayed on the widget (button) or contained as data (entry). Applicable for button, check-button, entry, label, labelframe, spinbox, text.

とありますので、(value XXXXX)として、XXXXXをcheck-buttonのインスタンス名にすれば良いのではないかと想像したのですが、書き方がわからず・・・。
※下記ソースのcbtn1の:commandは動作しています。

識者の方、ぜひ教えてください。

lisp

1;;; LTKでボタンを表示する 2 3(ql:quickload :ltk) 4 5 6;; パッケージの作成 7(defpackage :ex4-05 8 (:use :common-lisp 9 :common-lisp-user 10 :ltk) 11 (:export :main)) 12 13(in-package :ex4-05) 14 15(defun main () 16 (with-ltk () 17 (let* ( 18 (cbtn1 (make-instance 19 'check-button 20 :text "check button1" 21 :variable :cbtn1_val 22 :onvalue :on 23 :offvalue :off 24 :command (lambda (value) 25 (format t "check-button1:~A~%" value) 26 ))) 27 28 (cbtn2 (make-instance 29 'check-button 30 :text "check button2")) 31 32 (cbtn3 (make-instance 33 'check-button 34 :text "Close")) 35 36 (btn (make-instance 37 'button 38 :text "check on!" 39 :command (lambda () 40 (setf (value cbtn1) "ON")))) ;; <-- ここでチェックボタンのON/OFFを操作したい 41 ) 42 (pack (list cbtn1 cbtn2 cbtn3) :side :top :fill :both :expand :yes) ; fill,both,expand,yesを指定すると、Wiindowのハシをドラッグして伸ばしても、ボタンが上下左右に大きくなる。 43 (pack btn :side :top :fill :both :expand :yes) 44 ))) 45 46(main) 47 48 49 50

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

メーリングリストの力を借りてなんとか解決しました。
なれない英語は難しいですね。
以下、解決したコードです。

:variable :cbtn1_val
:onvalue :on
:offvalue :off

上記の指定を外すだけでした。

LTKはvariableの変更を想定していない様子ですね。

lisp

1..snip 2> (cbtn1 (make-instance 3> 'check-button 4> :text "check button1" 5> :variable :cbtn1_val 6LTK assumes that you do not change the :variable parameter, so this will 7prevent SETF from working. You can either directly set the global variable you 8have specified, or just use the default value for :variable. 9

lisp

1;;; LTKでチェックボタンを表示する 2 3(ql:quickload :ltk) 4 5 6;; パッケージの作成 7(defpackage :ex4-05 8 (:use :common-lisp 9 :common-lisp-user 10 :ltk) 11 (:export :main)) 12 13(in-package :ex4-05) 14 15(defun main () 16 (with-ltk () 17 (let* ( 18 (cbtn1 (make-instance 19 'check-button 20 :text "check button1" 21 :command (lambda (value) 22 (format t "check-button1:~A~%" value) 23 ))) 24 25 (cbtn2 (make-instance 26 'check-button 27 :text "check button2")) 28 29 (cbtn3 (make-instance 30 'check-button 31 :text "Close")) 32 33 (btn (make-instance 34 'button 35 :text "check on!" 36 :command (lambda () 37 (setf (value cbtn1) t) 38 (print (value cbtn1))))) 39 ) 40 (pack (list cbtn1 cbtn2 cbtn3) :side :top :fill :both :expand :yes) ; fill,both,expand,yesを指定すると、Wiindowのハシをドラッグして伸ばしても、ボタンが上下左右に大きくなる。 41 (pack btn :side :top :fill :both :expand :yes) 42 ))) 43 44(main) 45 46 47 48 49 50 51 52

投稿2018/06/24 05:45

kamuycikap

総合スコア135

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問