Skip to content

run main-loop on a thread #2

@lispnik

Description

@lispnik

Would like to be able to interactively build a gui from the REPL like you can with CAPI. main-loop blocks until the last dialog is closed though. Main consideration is that UI operations should run on the UI thread, otherwise bad thing happen (just like in swing, and maybe others).

Idea sketch:

(iup:open) ;; initialize manual

(defvar *idle-queue* '())

(defun idle-callback () 
   ;; lock
   (dolist (func *idle-queue*) (funcall func)
   (setf *idle-queue* '()))

(with-gui-thread ()
   (setf (iup:attribute foo :title) "new title"))
;;; ...
(call-with-gui-thread (func)
   ;; lock idle queue 
   (push func *idle-queue*))

notes:

  • also need to support the original purpose of the idle callback

  • set global var lockloop (so last dialog doesn't exit main-loop)

  • make sure it's not a multithreaded shit show

  • document

  • check that the CPU usage of idle callback isn't too high (iup docs explain it's called more than you think).

  • should enable this kind of interactive coding (like in TCL wish):

CL-USER> (in-package #:iup-user)
IUP-USER> (start-gui-thread)
IUP-USER> (setq dialog (dialog nil))
IUP-USER> (setq button (button :title "hi"))
IUP-USER> (show dialog)
IUP-USER> (iup:append dialog button)
IUP-USER> (setf (attribute button :title )"new title")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions