2
20
Fork
You've already forked nodgui
4

(with-nodgui (:stream *saved-tk*) ...) gives Unknown &KEY argument: :STREAM #19

Open
opened 2024年12月15日 02:56:54 +01:00 by defaultxr · 12 comments
Contributor
Copy link

Hi,

Based on the docstring of with-nodgui, it seems like I should be able to do something like this:

(with-nodgui ()
 (setf *saved-tk* *tk*)
 ;; ...more stuff...
 )
(with-nodgui (:stream *saved-tk*)
 (fire-event *saved-widget* "<<MyVirtualEvent>>"))

But when I try to do something like that, I get the following error:

Unknown &KEY argument: :STREAM
 [Condition of type SB-EXT:UNKNOWN-KEYWORD-ARGUMENT]
Restarts:
 0: [CONTINUE] Ignore all unknown keywords
 1: [RETRY] Retry SLY mREPL evaluation request.
 2: [*ABORT] Return to SLY's top level.
 3: [ABORT] abort thread (#<THREAD tid=2628163 "sly-channel-1-mrepl-remote-1" RUNNING {1000F90653}>)
Backtrace:
 0: (START-WISH :STREAM #<WIDGET {100C6D69A3}>) [more]
 1: ((LAMBDA NIL :IN CALL-WITH-NODGUI))
 2: (CALL-WITH-NODGUI #<FUNCTION (LAMBDA NIL :IN STEPSEQ-ACTIVE-STEP) {100A604E1B}> :STREAM #<WIDGET {100C6D69A3}>)
 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SETF (STEPSEQ-ACTIVE-STEP *TMP-CANVAS*) 1) #<NULL-LEXENV>)
 4: (EVAL (SETF (STEPSEQ-ACTIVE-STEP *TMP-CANVAS*) 1))
 5: ((LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1))
 [...]

Basically, I need to be able to fire a virtual event from a separate thread so that I can ensure the GUI updates based on data that is being changed outside of the GUI. Is something like this the best way to go about doing that?

P.S. I may have a few more bug reports for you in the future as I'm currently working on a project using Nodgui for its GUI.

Hi, Based on the docstring of `with-nodgui`, it seems like I should be able to do something like this: ```lisp (with-nodgui () (setf *saved-tk* *tk*) ;; ...more stuff... ) (with-nodgui (:stream *saved-tk*) (fire-event *saved-widget* "<<MyVirtualEvent>>")) ``` But when I try to do something like that, I get the following error: ``` Unknown &KEY argument: :STREAM [Condition of type SB-EXT:UNKNOWN-KEYWORD-ARGUMENT] Restarts: 0: [CONTINUE] Ignore all unknown keywords 1: [RETRY] Retry SLY mREPL evaluation request. 2: [*ABORT] Return to SLY's top level. 3: [ABORT] abort thread (#<THREAD tid=2628163 "sly-channel-1-mrepl-remote-1" RUNNING {1000F90653}>) Backtrace: 0: (START-WISH :STREAM #<WIDGET {100C6D69A3}>) [more] 1: ((LAMBDA NIL :IN CALL-WITH-NODGUI)) 2: (CALL-WITH-NODGUI #<FUNCTION (LAMBDA NIL :IN STEPSEQ-ACTIVE-STEP) {100A604E1B}> :STREAM #<WIDGET {100C6D69A3}>) 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SETF (STEPSEQ-ACTIVE-STEP *TMP-CANVAS*) 1) #<NULL-LEXENV>) 4: (EVAL (SETF (STEPSEQ-ACTIVE-STEP *TMP-CANVAS*) 1)) 5: ((LAMBDA NIL :IN SLYNK-MREPL::MREPL-EVAL-1)) [...] ``` Basically, I need to be able to fire a virtual event from a separate thread so that I can ensure the GUI updates based on data that is being changed outside of the GUI. Is something like this the best way to go about doing that? P.S. I may have a few more bug reports for you in the future as I'm currently working on a project using Nodgui for its GUI.
Owner
Copy link

Hi @defaultxr !

The bug you reported about the stream keyword argument should be fixed in the development branch. Thanks for reporting!

About firing events from a different thread please take a look at the code below where two different threads compete to append text in a text area; if I have understood correctly your goal, you need, as you correctly guessed, to pass the stream between threads (but please be aware that the stream to the TK interpreter pipe is bound to nodgui:*wish*, not nodgui:*tk*, the latter is the root widget - so called toplevel - of the GUI), but there is no need to use nodgui:with-nodgui. In nodgui writing and reading concurrently to/from the pipe is supported, so is (minus bugs) for the vast majority of the functions of the library that write or read from the pipe.

P.S. I may have a few more bug reports for you in the future as I'm currently working on a project using Nodgui for its GUI.

That's great! Thanks for helping improving this library and for using too!

Bye
C.

(asdf:make "nodgui")
(asdf:make "bordeaux-threads")
(in-package :nodgui)
(named-readtables:in-readtable nodgui.syntax:nodgui-syntax)
(defparameter *event* #$<<insert>>$)
(defun appending-thread (text-area wish-stream)
 (lambda ()
 (let ((*wish* wish-stream))
 (sleep (random 4))
 (loop repeat 10 do
 (sleep (random 5))
 (fire-event text-area *event*)))))
(defun main ()
 (setf *debug-tk* t)
 (with-nodgui ()
 (let* ((text-area (make-instance 'scrolled-text)))
 (append-text text-area
 (format nil "Waiting for events from the other thread.~%"))
 (grid text-area 0 0)
 (bind text-area
 *event*
 (lambda (e)
 (declare (ignore e))
 (append-text text-area
 (format nil
 "virtual event fired~%"))))
 (let ((thread-1 (nodgui.utils:make-thread
 (appending-thread text-area *wish*)))
 (thread-2 (nodgui.utils:make-thread
 (appending-thread text-area *wish*))))
 (nodgui.utils:join-thread thread-1)
 (nodgui.utils:join-thread thread-2)))))
Hi @defaultxr ! The bug you reported about the `stream` keyword argument should be fixed in the development branch. Thanks for reporting! About firing events from a different thread please take a look at the code below where two different threads compete to append text in a text area; if I have understood correctly your goal, you need, as you correctly guessed, to pass the stream between threads (but please be aware that the stream to the TK interpreter pipe is bound to `nodgui:*wish*`, not `nodgui:*tk*`, the latter is the root widget - so called `toplevel` - of the GUI), but there is no need to use `nodgui:with-nodgui`. In nodgui writing and reading concurrently to/from the pipe is supported, so is (minus bugs) for the vast majority of the functions of the library that write or read from the pipe. > P.S. I may have a few more bug reports for you in the future as I'm currently working on a project using Nodgui for its GUI. That's great! Thanks for helping improving this library and for using too! Bye C. ``` lisp (asdf:make "nodgui") (asdf:make "bordeaux-threads") (in-package :nodgui) (named-readtables:in-readtable nodgui.syntax:nodgui-syntax) (defparameter *event* #$<<insert>>$) (defun appending-thread (text-area wish-stream) (lambda () (let ((*wish* wish-stream)) (sleep (random 4)) (loop repeat 10 do (sleep (random 5)) (fire-event text-area *event*))))) (defun main () (setf *debug-tk* t) (with-nodgui () (let* ((text-area (make-instance 'scrolled-text))) (append-text text-area (format nil "Waiting for events from the other thread.~%")) (grid text-area 0 0) (bind text-area *event* (lambda (e) (declare (ignore e)) (append-text text-area (format nil "virtual event fired~%")))) (let ((thread-1 (nodgui.utils:make-thread (appending-thread text-area *wish*))) (thread-2 (nodgui.utils:make-thread (appending-thread text-area *wish*)))) (nodgui.utils:join-thread thread-1) (nodgui.utils:join-thread thread-2))))) ```
Author
Contributor
Copy link

Thank you, that's very helpful! It's been a bit since I used Nodgui so I forgot that *wish* is what I want here, not *tk*. The example also is helpful, thanks for writing that.

One thing I have a question about though: how do the nodgui.utils thread functions differ from the bordeaux-threads ones? And when should nodgui's thread functions be used rather than bordeaux-threads' functions?

Unrelated to the previous questions--and let me know if you'd rather I make a separate issue for this--another question I have is that I'm not sure how to apply multiple tags to an item in a canvas. For example:

(with-nodgui ()
 (let* ((canvas (make-canvas *tk*))
 (rect1 (create-rectangle canvas 0 0 100 100))
 (rect2 (create-rectangle canvas 100 0 200 100))
 (rect3 (create-rectangle canvas 200 0 300 100)))
 (pack canvas :expand t :fill :both)
 (item-configure canvas rect1 "fill" "#FF0000")
 (item-configure canvas rect1 "tag" (list "foo" "bar")) ; neither tag seems to be applied
 (item-configure canvas rect2 "fill" "#00FF00")
 (item-configure canvas rect2 "tag" "foo") ; works
 (item-configure canvas rect3 "fill" "#0000FF")
 (item-configure canvas rect3 "tag" "bar") ; works
 (tag-bind canvas "foo" "<ButtonPress-1>" (lambda (ev) (do-msg "foo clicked")))
 (tag-bind canvas "bar" "<ButtonPress-1>" (lambda (ev) (do-msg "bar clicked")))))

Maybe i'm misunderstanding Tk, but from what I saw online, it should be possible to apply multiple tags to one item. Tk seems to have an addtag command, as well as dtags to delete tags, gettags to get a list of tags of an item, and find to find items that have the specified tag. I did an (apropos "tag" 'nodgui) but it looks like at least a few of those are missing (or maybe they just have a different name?).

Thank you, that's very helpful! It's been a bit since I used Nodgui so I forgot that `*wish*` is what I want here, not `*tk*`. The example also is helpful, thanks for writing that. One thing I have a question about though: how do the `nodgui.utils` thread functions differ from the bordeaux-threads ones? And when should nodgui's thread functions be used rather than bordeaux-threads' functions? Unrelated to the previous questions--and let me know if you'd rather I make a separate issue for this--another question I have is that I'm not sure how to apply multiple tags to an item in a canvas. For example: ```lisp (with-nodgui () (let* ((canvas (make-canvas *tk*)) (rect1 (create-rectangle canvas 0 0 100 100)) (rect2 (create-rectangle canvas 100 0 200 100)) (rect3 (create-rectangle canvas 200 0 300 100))) (pack canvas :expand t :fill :both) (item-configure canvas rect1 "fill" "#FF0000") (item-configure canvas rect1 "tag" (list "foo" "bar")) ; neither tag seems to be applied (item-configure canvas rect2 "fill" "#00FF00") (item-configure canvas rect2 "tag" "foo") ; works (item-configure canvas rect3 "fill" "#0000FF") (item-configure canvas rect3 "tag" "bar") ; works (tag-bind canvas "foo" "<ButtonPress-1>" (lambda (ev) (do-msg "foo clicked"))) (tag-bind canvas "bar" "<ButtonPress-1>" (lambda (ev) (do-msg "bar clicked"))))) ``` Maybe i'm misunderstanding Tk, but from what I saw online, it should be possible to apply multiple tags to one item. Tk seems to have an `addtag` command, as well as `dtags` to delete tags, `gettags` to get a list of tags of an item, and `find` to find items that have the specified tag. I did an `(apropos "tag" 'nodgui)` but it looks like at least a few of those are missing (or maybe they just have a different name?).
Owner
Copy link

Hi @defaultxr !

Thank you, that's very helpful!

You are very welcome! 😄

It's been a bit since I used Nodgui so I forgot that *wish* is what I want here, not *tk*. The example also is helpful, thanks for writing that.

My pleasure!

One thing I have a question about though: how do the nodgui.utils thread functions differ from the bordeaux-threads ones? And when should nodgui's thread functions be used rather than bordeaux-threads' functions?

To answer to both questions, just take a look at the source where the functions are defined:

https://codeberg.org/cage/nodgui/src/branch/master/src/utils.lisp#L561

As you can easily see, these functions are no more that a one line wrapper to bordeaux-threads: make-thread just enforce single precision float; the only other caveat is that only version 2 of the API is supported, take this into account if you are using version 1 in your code.

[...]

Maybe i'm misunderstanding Tk, but from what I saw online, it should be possible to apply multiple tags to one item.

I believe you got it right! I added two missing functions to the development branch: item-add-tag and item-remove-tag (we can change the name if they do not seem right), please see if the code below fits your needs:


(defun main ()
 (setf *debug-tk* t)
 (with-nodgui ()
 (let* ((canvas (make-canvas *tk*))
 (rect1 (create-rectangle canvas 0 0 100 100)))
 (pack canvas :expand t :fill :both)
 (item-configure canvas rect1 "fill" (make-tk-color "#FF0000"))
 (item-add-tag canvas (list "foo" "bar") :withtag rect1)
 (tag-bind canvas "foo" "<1>" (lambda (e)
 (declare (ignore e))
 (do-msg "foo clicked, this tag removed")
 (item-remove-tag canvas rect1 "foo")))
 (tag-bind canvas "bar" "<3>" (lambda (e)
 (declare (ignore e))
 (do-msg "bar clicked"))))))

Please let me know if you think there are other important functions not wrapped by nodgui, I will try to patch the code.

Bye!
C.

Hi @defaultxr ! > Thank you, that's very helpful! You are very welcome! 😄 > It's been a bit since I used Nodgui so I forgot that `*wish*` is what I want here, not `*tk*`. The example also is helpful, thanks for writing that. My pleasure! > > > One thing I have a question about though: how do the `nodgui.utils` thread functions differ from the bordeaux-threads ones? And when should nodgui's thread functions be used rather than bordeaux-threads' functions? To answer to both questions, just take a look at the source where the functions are defined: https://codeberg.org/cage/nodgui/src/branch/master/src/utils.lisp#L561 As you can easily see, these functions are no more that a one line wrapper to bordeaux-threads: `make-thread` just enforce single precision float; the only other caveat is that only version 2 of the API is supported, take this into account if you are using version 1 in your code. [...] > Maybe i'm misunderstanding Tk, but from what I saw online, it should be possible to apply multiple tags to one item. > I believe you got it right! I added two missing functions to the development branch: `item-add-tag` and `item-remove-tag` (we can change the name if they do not seem right), please see if the code below fits your needs: ``` lisp (defun main () (setf *debug-tk* t) (with-nodgui () (let* ((canvas (make-canvas *tk*)) (rect1 (create-rectangle canvas 0 0 100 100))) (pack canvas :expand t :fill :both) (item-configure canvas rect1 "fill" (make-tk-color "#FF0000")) (item-add-tag canvas (list "foo" "bar") :withtag rect1) (tag-bind canvas "foo" "<1>" (lambda (e) (declare (ignore e)) (do-msg "foo clicked, this tag removed") (item-remove-tag canvas rect1 "foo"))) (tag-bind canvas "bar" "<3>" (lambda (e) (declare (ignore e)) (do-msg "bar clicked")))))) ``` Please let me know if you think there are other important functions not wrapped by nodgui, I will try to patch the code. Bye! C.
Author
Contributor
Copy link

That's all very helpful! After switching to the development branch, I tried out the tag functions and the example and they seem to be working for me so far. Thanks very much, and I appreciate the quick responses :)

If you're curious, I'm currently working on a live music performance interface using Nodgui. I don't have it making sound yet, but I'm going to be working on it intently since the performance I want to use it for is in early January. Here's a screenshot of the interface as it currently is, showing the step sequencer with some steps active (the black ones) and a search through my music library on the right side:

2024年12月22日-171738_2880x1620.png

I might record a video of the interface being used after I've made more progress on it.

That's all very helpful! After switching to the development branch, I tried out the tag functions and the example and they seem to be working for me so far. Thanks very much, and I appreciate the quick responses :) If you're curious, I'm currently working on a live music performance interface using Nodgui. I don't have it making sound yet, but I'm going to be working on it intently since the performance I want to use it for is in early January. Here's a screenshot of the interface as it currently is, showing the step sequencer with some steps active (the black ones) and a search through my music library on the right side: ![2024年12月22日-171738_2880x1620.png](/attachments/93706389-83c7-4b63-980d-6ea14210fae6) I might record a video of the interface being used after I've made more progress on it.
Owner
Copy link

Hi @defaultxr !

That's all very helpful! After switching to the development branch, I tried out the tag functions and the example and they seem to be working for me so far. Thanks very much, and I appreciate the quick responses :)

You are very welcome! I think i am going to add function to list and find items by tags and get the tags associated with an item before merging the development branch into master.

If you're curious,

I am, but i was afraid to ask! 😅

I'm currently working on a live music performance interface using Nodgui.

Nice! If you need more rendering speed you may use the SDL frame, if needed you can exploit the hardware acceleration with OpenGL too.

Forgive my ignorance, are you going to use cl-collider or something?

I don't have it making sound yet, but I'm going to be working on it intently since the performance I want to use it for is in early January.

I hope this performance could be recorded!

Here's a screenshot of the interface as it currently is, showing the step sequencer with some steps active (the black ones) and a search through my music library on the right side:

2024年12月22日-171738_2880x1620.png

I might record a video of the interface being used after I've made more progress on it.

That also would be great! I am happy to know that the library can be useful for your project, i wrote it hoping that would be good enough for general use, not only for my personal project. Seems it was! 😄

As eventually this thread is going to be closed I am leaving here a page with my personal contacts, if needed feel free to contact me for any question related to this library.

https://www.autistici.org/interzona/contact.html

Happy season!
C.

Hi @defaultxr ! > That's all very helpful! After switching to the development branch, I tried out the tag functions and the example and they seem to be working for me so far. Thanks very much, and I appreciate the quick responses :) You are very welcome! I think i am going to add function to list and find items by tags and get the tags associated with an item before merging the development branch into master. > > If you're curious, I am, but i was afraid to ask! 😅 > I'm currently working on a live music performance interface using Nodgui. Nice! If you need more rendering speed you may use the SDL frame, if needed you can exploit the hardware acceleration with OpenGL too. Forgive my ignorance, are you going to use cl-collider or something? > > I don't have it making sound yet, but I'm going to be working on it intently since the performance I want to use it for is in early January. I hope this performance could be recorded! Here's a screenshot of the interface as it currently is, showing the step sequencer with some steps active (the black ones) and a search through my music library on the right side: > > ![2024年12月22日-171738_2880x1620.png](/attachments/93706389-83c7-4b63-980d-6ea14210fae6) > > I might record a video of the interface being used after I've made more progress on it. That also would be great! I am happy to know that the library can be useful for your project, i wrote it hoping that would be good enough for general use, not only for my personal project. Seems it was! 😄 As eventually this thread is going to be closed I am leaving here a page with my personal contacts, if needed feel free to contact me for any question related to this library. https://www.autistici.org/interzona/contact.html Happy season! C.
Author
Contributor
Copy link

Nice! If you need more rendering speed you may use the SDL frame, if needed you can exploit the hardware acceleration with OpenGL too.

Thanks, I did see that mentioned, but didn't look into it until now, and it looks like there is a pretty nice API, so it would probably work well for doing an oscilloscope-type display. I'm not sure I'll have time before the performance to code something like that (since I want to focus on the core functionality of my setup first) but I'll of course let you know if I run into any issues when I do try it out :)

Forgive my ignorance, are you going to use cl-collider or something?

Yes! cl-collider, mostly controlled via my algorithmic sequencing library cl-patterns. The idea is that the graphical interface I'm creating with Nodgui should allow for faster control over some of the pattern parameters compared to doing so with text/code (not to mention allowing for much more visual representations of the state of the system). A lot can be done with code, but in a real time performance, there are definitely some things where a GUI besides Emacs makes more sense.

I hope this performance could be recorded!

I usually try to record the audio of my performances, and I think there will probably be some videos people will take as well. I'll be sure to share anything I get!

That also would be great! I am happy to know that the library can be useful for your project, i wrote it hoping that would be good enough for general use, not only for my personal project. Seems it was! 😄

Definitely! I had actually attempted to create graphical interfaces for music composition/performance in the past using the McCLIM library, but CLIM has a lot more layers to it, and I ran into a few issues with it that I wasn't able to solve, which felt pretty discouraging. I still think CLIM is cool and McCLIM is an amazing project, but it's definitely a bit more complex and difficult sometimes.

I had previously played around with Tk through Tkinter in Python, so I knew it worked pretty well for the types of things I was wanting to do. And it's definitely a lot nicer to be able to make a Tk app in Lisp than in Python, so Nodgui has been great :)

As eventually this thread is going to be closed I am leaving here a page with my personal contacts, if needed feel free to contact me for any question related to this library.

https://www.autistici.org/interzona/contact.html

Happy season!
C.

Thanks very much! I think those were the main issues I had for now, but I'll let you know if I have any other questions or feature requests. I also gave you a follow on fedi 👍

But yeah, thanks again, and happy holidays to you as well :)

> Nice! If you need more rendering speed you may use the SDL frame, if needed you can exploit the hardware acceleration with OpenGL too. Thanks, I did see that mentioned, but didn't look into it until now, and it looks like there is a pretty nice API, so it would probably work well for doing an oscilloscope-type display. I'm not sure I'll have time before the performance to code something like that (since I want to focus on the core functionality of my setup first) but I'll of course let you know if I run into any issues when I do try it out :) > Forgive my ignorance, are you going to use cl-collider or something? Yes! cl-collider, mostly controlled via my algorithmic sequencing library [cl-patterns](https://github.com/defaultxr/cl-patterns). The idea is that the graphical interface I'm creating with Nodgui should allow for faster control over some of the pattern parameters compared to doing so with text/code (not to mention allowing for much more visual representations of the state of the system). A lot can be done with code, but in a real time performance, there are definitely some things where a GUI besides Emacs makes more sense. > I hope this performance could be recorded! I usually try to record the audio of my performances, and I think there will probably be some videos people will take as well. I'll be sure to share anything I get! > That also would be great! I am happy to know that the library can be useful for your project, i wrote it hoping that would be good enough for general use, not only for my personal project. Seems it was! 😄 Definitely! I had actually attempted to create [graphical interfaces for music composition/performance](https://github.com/defaultxr/thundersnow) in the past using the McCLIM library, but CLIM has a lot more layers to it, and I ran into a few issues with it that I wasn't able to solve, which felt pretty discouraging. I still think CLIM is cool and McCLIM is an amazing project, but it's definitely a bit more complex and difficult sometimes. I had previously played around with Tk through Tkinter in Python, so I knew it worked pretty well for the types of things I was wanting to do. And it's definitely a lot nicer to be able to make a Tk app in Lisp than in Python, so Nodgui has been great :) > As eventually this thread is going to be closed I am leaving here a page with my personal contacts, if needed feel free to contact me for any question related to this library. > > https://www.autistici.org/interzona/contact.html > > Happy season! > C. Thanks very much! I think those were the main issues I had for now, but I'll let you know if I have any other questions or feature requests. I also gave you a follow on fedi 👍 But yeah, thanks again, and happy holidays to you as well :)
Author
Contributor
Copy link

Another request for you - is there some way to set the background color of a combobox after it has already been created? I'm trying various combinations of (configure ...) and the like but they don't seem to be working. I found this page which suggests that "fieldbackground" may be the name of the configure option you have to set, but when trying (configure entry "fieldbackground" "#FF0000"), my app crashes and this Lisp error occurs:

Tcl/Tk error: unknown option "-fieldbackground"
 while executing
".nd.nf.ng.nw.nMb.nOb configure {-fieldbackground} {#FF0000}"
 invoked from within
"catch 
cmd"
 [Condition of type NODGUI.CONDITIONS:TK-ERROR]
Restarts:
 0: [ABORT] abort thread (#<THREAD tid=3036326 "read loop" RUNNING {100F888003}>)
Backtrace:
 0: ((LAMBDA NIL :IN NODGUI::START-READING-LOOP))
 1: ((FLET BT2::RUN-FUNCTION :IN BT2::ESTABLISH-DYNAMIC-ENV))
 2: ((LABELS BT2::%ESTABLISH-DYNAMIC-ENV-WRAPPER :IN BT2::ESTABLISH-DYNAMIC-ENV))
 3: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 4: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 5: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 6: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 7: (SB-THREAD::RUN)
 8: ("foreign function: call_into_lisp_")
 --more--
Another request for you - is there some way to set the background color of a `combobox` after it has already been created? I'm trying various combinations of `(configure ...)` and the like but they don't seem to be working. I found [this page](https://stackoverflow.com/questions/27912250/how-to-set-the-background-color-of-a-ttk-combobox) which suggests that `"fieldbackground"` may be the name of the configure option you have to set, but when trying `(configure entry "fieldbackground" "#FF0000")`, my app crashes and this Lisp error occurs: ``` Tcl/Tk error: unknown option "-fieldbackground" while executing ".nd.nf.ng.nw.nMb.nOb configure {-fieldbackground} {#FF0000}" invoked from within "catch cmd" [Condition of type NODGUI.CONDITIONS:TK-ERROR] Restarts: 0: [ABORT] abort thread (#<THREAD tid=3036326 "read loop" RUNNING {100F888003}>) Backtrace: 0: ((LAMBDA NIL :IN NODGUI::START-READING-LOOP)) 1: ((FLET BT2::RUN-FUNCTION :IN BT2::ESTABLISH-DYNAMIC-ENV)) 2: ((LABELS BT2::%ESTABLISH-DYNAMIC-ENV-WRAPPER :IN BT2::ESTABLISH-DYNAMIC-ENV)) 3: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN)) 4: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN)) 5: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN)) 6: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN)) 7: (SB-THREAD::RUN) 8: ("foreign function: call_into_lisp_") --more-- ```
Owner
Copy link

Hi @defaultxr !

[SDL frame]

Thanks, I did see that mentioned, but didn't look into it until now, and it looks like there is a pretty nice API, so it would probably work well for doing an oscilloscope-type display. I'm not sure I'll have time before the performance to code something like that (since I want to focus on the core functionality of my setup first)

I was thinking could be useful to display waves or similar, the price for better performance is more complex code though, but only mentioned just in case! 😄

but I'll of course let you know if I run into any issues when I do try it out :)

Thanks!

Forgive my ignorance, are you going to use cl-collider or something?

Yes! cl-collider, mostly controlled via my algorithmic sequencing library cl-patterns.

Seems a pretty complex work! 👍

The idea is that the graphical interface I'm creating with Nodgui should allow for faster control over some of the pattern parameters compared to doing so with text/code (not to mention allowing for much more visual representations of the state of the system). A lot can be done with code, but in a real time performance, there are definitely some things where a GUI besides Emacs makes more sense.

I am not good at music and I admire a lot people that can compose music on live performance (even using code!). The skills to accomplish such task are amazing!

I hope this performance could be recorded!

I usually try to record the audio of my performances, and I think there will probably be some videos people will take as well. I'll be sure to share anything I get!

Looking forward to listen it, then!

[...]

Definitely! I had actually attempted to create graphical interfaces for music composition/performance in the past using the McCLIM library, but CLIM has a lot more layers to it, and I ran into a few issues with it that I wasn't able to solve, which felt pretty discouraging. I still think CLIM is cool and McCLIM is an amazing project, but it's definitely a bit more complex and difficult sometimes.

I had previously played around with Tk through Tkinter in Python, so I knew it worked pretty well for the types of things I was wanting to do. And it's definitely a lot nicer to be able to make a Tk app in Lisp than in Python, so Nodgui has been great :)

I think McCLIM is wonderful and eventually it will make this library someway obsolete, and I think it will be a good thing, too! Nodgui is both much more simple and much less ambitious (it is just a wrapper for TK) but allowed me to assemble some non trivial GUI in little time (and version 9 support some nice looking theme too), it is the "No Drama GUI", after all! 😁

[...]

Thanks very much! I think those were the main issues I had for now, but I'll let you know if I have any other questions or feature requests. I also gave you a follow on fedi 👍

Found the notification and followed back! 😄

Bye!
C.

Hi @defaultxr ! > > [SDL frame] > > Thanks, I did see that mentioned, but didn't look into it until now, and it looks like there is a pretty nice API, so it would probably work well for doing an oscilloscope-type display. I'm not sure I'll have time before the performance to code something like that (since I want to focus on the core functionality of my setup first) I was thinking could be useful to display waves or similar, the price for better performance is more complex code though, but only mentioned just in case! 😄 > but I'll of course let you know if I run into any issues when I do try it out :) Thanks! > > > Forgive my ignorance, are you going to use cl-collider or something? > > Yes! cl-collider, mostly controlled via my algorithmic sequencing library [cl-patterns](https://github.com/defaultxr/cl-patterns). Seems a pretty complex work! 👍 > The idea is that the graphical interface I'm creating with Nodgui should allow for faster control over some of the pattern parameters compared to doing so with text/code (not to mention allowing for much more visual representations of the state of the system). A lot can be done with code, but in a real time performance, there are definitely some things where a GUI besides Emacs makes more sense. I am not good at music and I admire a lot people that can compose music on live performance (even using code!). The skills to accomplish such task are amazing! > > > I hope this performance could be recorded! > > I usually try to record the audio of my performances, and I think there will probably be some videos people will take as well. I'll be sure to share anything I get! Looking forward to listen it, then! [...] > Definitely! I had actually attempted to create [graphical interfaces for music composition/performance](https://github.com/defaultxr/thundersnow) in the past using the McCLIM library, but CLIM has a lot more layers to it, and I ran into a few issues with it that I wasn't able to solve, which felt pretty discouraging. I still think CLIM is cool and McCLIM is an amazing project, but it's definitely a bit more complex and difficult sometimes. > > I had previously played around with Tk through Tkinter in Python, so I knew it worked pretty well for the types of things I was wanting to do. And it's definitely a lot nicer to be able to make a Tk app in Lisp than in Python, so Nodgui has been great :) I think McCLIM is wonderful and eventually it will make this library someway obsolete, and I think it will be a good thing, too! Nodgui is both much more simple and much less ambitious (it is just a wrapper for TK) but allowed me to assemble some non trivial GUI in little time (and version 9 support some nice looking theme too), it is the "No Drama GUI", after all! 😁 [...] > Thanks very much! I think those were the main issues I had for now, but I'll let you know if I have any other questions or feature requests. I also gave you a follow on fedi 👍 Found the notification and followed back! 😄 Bye! C.
Owner
Copy link

Hi @defaultxr !

Another request for you - is there some way to set the background color of a combobox after it has already been created? I'm trying various combinations of (configure ...) and the like but they don't seem to be working.

After TK 8.6 setting the widget colors using commands in no more supported with the so called ttk widget (nodgui uses almost exclusively ttk); the only way to change these parameters is using style; graphics theme are TCL code that modify widgets style, here is an introduction to ttk styles.

https://tkdocs.com/tutorial/styles.html

Nodgui has a lispy interface for styles:

https://codeberg.org/cage/nodgui/src/branch/master/src/styles.lisp

And the included demo contains an example about changing style of a button:

https://codeberg.org/cage/nodgui/src/branch/master/src/demo-tests.lisp#L1452

But I have to be honest, i spent more time writing the interface than using it, so never used this feature for anything serious, you could be easily be the first one! 😄 But be aware that you may entering in a rabbit hole! 😅

So said, here is a code that changes the fieldbackground style property after 3 second after the GUI initialization:

Note the call to make-style (a macro actually), apply-style and style-configure. TCombobox is the style class for the combobox and, with this code, we are inheriting style from it and apply changes just to one parameter.

(defun main ()
 (setf *debug-tk* t)
 (with-nodgui ()
 (let ((combo-style (make-style combo-style
 (:extend "TCombobox")
 :fieldbackground (make-tk-color :red)))
 (combo (make-instance 'combobox)))
 (bt2:make-thread (let ((wish *wish*))
 (lambda ()
 (let ((*wish* wish))
 (sleep 3)
 (apply-style combo-style)
 (style-configure combo combo-style)))))
 (pack combo))))

I would love to see if the interface I wrote for styling works or even makes sense! But, again, i think for complex work some issues could arise, so be careful and - of course- let me know how I can help.

Happy hacking!
C.

PS: i also added item-get-tag and item-find-items in the development branch, i do not know why i skipped wrapping this commands before. 😓

Hi @defaultxr ! > Another request for you - is there some way to set the background color of a `combobox` after it has already been created? I'm trying various combinations of `(configure ...)` and the like but they don't seem to be working. After TK 8.6 setting the widget colors using commands in no more supported with the so called `ttk` widget (nodgui uses almost exclusively `ttk`); the only way to change these parameters is using style; graphics theme are TCL code that modify widgets style, here is an introduction to `ttk` styles. https://tkdocs.com/tutorial/styles.html Nodgui has a lispy interface for styles: https://codeberg.org/cage/nodgui/src/branch/master/src/styles.lisp And the included demo contains an example about changing style of a button: https://codeberg.org/cage/nodgui/src/branch/master/src/demo-tests.lisp#L1452 But I have to be honest, i spent more time writing the interface than using it, so never used this feature for anything serious, you could be easily be the first one! 😄 But be aware that you may entering in a rabbit hole! 😅 So said, here is a code that changes the `fieldbackground` style property after 3 second after the GUI initialization: Note the call to `make-style` (a macro actually), `apply-style` and `style-configure`. `TCombobox` is the style class for the combobox and, with this code, we are inheriting style from it and apply changes just to one parameter. ``` lisp (defun main () (setf *debug-tk* t) (with-nodgui () (let ((combo-style (make-style combo-style (:extend "TCombobox") :fieldbackground (make-tk-color :red))) (combo (make-instance 'combobox))) (bt2:make-thread (let ((wish *wish*)) (lambda () (let ((*wish* wish)) (sleep 3) (apply-style combo-style) (style-configure combo combo-style))))) (pack combo)))) ``` I would love to see if the interface I wrote for styling works or even makes sense! But, again, i think for complex work some issues could arise, so be careful and - of course- let me know how I can help. Happy hacking! C. PS: i also added `item-get-tag` and `item-find-items` in the development branch, i do not know why i skipped wrapping this commands before. 😓
Owner
Copy link

@defaultxr wrote in #19 (comment):

Hi @defaultxr !

If you're curious, I'm currently working on a live music performance interface using Nodgui. I

How was the performance?

Bye!
C.

@defaultxr wrote in https://codeberg.org/cage/nodgui/issues/19#issuecomment-2536490: Hi @defaultxr ! > If you're curious, I'm currently working on a live music performance interface using Nodgui. I How was the performance? Bye! C.
Author
Contributor
Copy link

Hi @cage ! The performance went well, though unfortunately I wasn't able to implement the functionality I was aiming for in time for it, so I ended up falling back to some Pure Data patches I'd made in the past and used those instead. It's easy to underestimate how much time and work a project will require...

I'm not giving up on this project though and once it's developed enough I'm going to use it for a future performance. I'll definitely keep you posted on that :)

Hi @cage ! The performance went well, though unfortunately I wasn't able to implement the functionality I was aiming for in time for it, so I ended up falling back to some Pure Data patches I'd made in the past and used those instead. It's easy to underestimate how much time and work a project will require... I'm not giving up on this project though and once it's developed enough I'm going to use it for a future performance. I'll definitely keep you posted on that :)
Owner
Copy link

Hi! @defaultxr

I am sincerely happy that the performance was good! I wish you having more even better!

It's easy to underestimate how much time and work a project will require...

So true! 😄

I'm not giving up on this project though and once it's developed enough I'm going to use it for a future performance. I'll definitely keep you posted on that :)

Thanks @defaultxr, looking forward for your update! 😄
C.

Hi! @defaultxr I am sincerely happy that the performance was good! I wish you having more even better! > It's easy to underestimate how much time and work a project will require... So true! 😄 > > I'm not giving up on this project though and once it's developed enough I'm going to use it for a future performance. I'll definitely keep you posted on that :) Thanks @defaultxr, looking forward for your update! 😄 C.
Sign in to join this conversation.
No Branch/Tag specified
master
development
v0.7.6.5
v0.7.6.4
v0.7.6.3
v0.7.6.2
v0.7.6.1
v0.7.6.0
v0.7.5.1
v0.7.5.0
v0.7.4.0
v0.7.3.5
v0.7.3.4
v0.7.3.3
v0.7.3.2
v0.7.3.1
v0.7.3.0
v0.7.2.1
v0.7.2.0
v0.7.1.3
v0.7.1.2
v0.7.1.1
v0.7.1.0
v0.7.0.4
v0.7.0.3
v0.7.0.2
v0.7.0.1
v0.7.0.0
v0.6.2.1
v0.6.2.0
v0.6.1.2
v0.6.1.1
v0.6.1.0
v0.4.9.6
v0.4.9.3
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cage/nodgui#19
Reference in a new issue
cage/nodgui
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?