一个McCLIM实例

原创
2018/05/13 08:04
阅读数 320

McCLIM是Common Lisp的UI组件,详细信息见:https://www.oschina.net/p/mcclim 或 

该博客源码来自视频:https://www.youtube.com/watch?v=-NA2Payslys

环境信息:

OS: ubuntu 18.04

REPL: emacs + slime + sbcl

package system: quicklisp

project system: clproject

1. 建立mchello工程框架

安装quicklisp,参考 https://www.quicklisp.org/beta/

安装quickproject

CL-USER> (ql:quickload "quickproject")
To load "quickproject":
  Load 1 ASDF system:
    quickproject
; Loading "quickproject"

("quickproject")

创建工程:

CL-USER> (quickproject:make-project #p"~/quicklisp/local-projects/mchello" :depends-on '(clim clim-lisp))

工程文件截图

mchello.asd文件内容不需要修改

;;;; mchello.asd

(asdf:defsystem #:mchello
  :description "Describe mchello here"
  :author "Your Name <your.name@example.com>"
  :license "Specify license here"
  :depends-on (#:clim
               #:clim-lisp)
  :serial t
  :components ((:file "package")
               (:file "mchello")))

package.lisp内容

;;;; package.lisp

(defpackage #:mchello
  (:use #:cl #:clim #:clim-lisp)
  (:export "app-main"))

mchello.lisp内容

;;;; mchello.lisp

(in-package #:mchello)

;;; "mchello" goes here. Hacks and glory await!
(define-application-frame mchelloapp ()
  ()
  (:pointer-documentation t)
  (:panes
   (app :application :display-time nil :height 400 :width 500)
   (int :interactor :height 200 :width 500))
  (:layouts
					;(default (vertically () app int))))
   (default (horizontally () app int))))

(defun app-main ()
  (run-frame-top-level (make-application-frame 'mchelloapp)))

(define-mchelloapp-command (com-quit :name t) ()
  (frame-exit *application-frame*))

(define-mchelloapp-command (com-parity :name t) ((number 'integer))
  (format t "~a is ~a~%" number
	  (if (oddp number) "odd" "even")))

(define-mchelloapp-command (com-say :name t) ((what-to-say 'string))
  (format t "~a~%" what-to-say))

UI实例截图如下(左侧为显示区,右侧为交互区):

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部