Fork me on GitHub
#humbleui
<
2024-01-15
>
Niki20:01:54

Who said UI apps had to be scary? This is all that’s required to get this window on screen (once I merge vdom branch, soon)

💓 18
👀 7
🤯 2
👍 2
Niki20:01:22

honestly feels easier than starting a web app

💯 5
Omer ZAK00:01:32

How to specify the dependency upon io.github.humbleui.ui in lein-new-app created project's project.clj? I naively tried:

:dependencies [[org.clojure/clojure "1.10.0"]
                 [io.github.humbleui/humbleui {:git/sha "c5b4179e44c486b2d9171be845eb14ff8a7936cf"}]]

Omer ZAK00:01:04

Of course, the above bombed out with:

java.lang.IllegalArgumentException: Bad artifact coordinates io.github.humbleui:humbleui:jar:{:git/sha "c5b4179e44c486b2d9171be845eb14ff8a7936cf"}, expected format is :[:[:]]:
(I stole the incantation from the following: ).

Niki00:01:46

I’m not sure if lein can consume git deps or deps.edn project. Sorry it’s not convenient but the framework itself is still far from being usable so no reason to get comfortable yet

Omer ZAK00:01:11

There is a lein-git-deps plugin and I am still figuring it out.

Omer ZAK01:01:26

UPDATE: I seem to have been successful in overcoming the above obstacle. The next obstacle is: java.lang.ClassNotFoundException: http://io.github.humbleui.jwm.App I tried both the above code and the following (taken from end of ):

(ns scaryui.core
  (:require [io.github.humbleui.ui :as ui])
  (:gen-class))

(def ui
  (ui/default-theme {}
    (ui/center
      (ui/label "Hello from Humble UI! 👋"))))

(defn -main  ;; I enclosed your ui/start-app! form inside -main.
  "Trying it"
  [& args]
  (ui/start-app!
   (ui/window
    {:title "Humble 🐝 UI"}
    #'ui)))
At this point I am surrendering to the Gods of Sleep.

Omer ZAK01:01:24

FYI, my project.clj at this moment is attached below. I did not bother to clean it up.

Руслан Сорокин08:01:55

Is it posible to run and debug HumbleUI applications using only Clojure CLI tools?

Руслан Сорокин08:01:13

No python, no shell and so on..

Руслан Сорокин08:01:30

I tried directly, but often Java crashes. And impossible to catch exception :(

Omer ZAK09:01:43

@U06CUH4D2BT, Is this the Java exception that you see? java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "x" is null

Руслан Сорокин09:01:15

# # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007fb842bcf28d, pid=14916, tid=14987 # # JRE version: OpenJDK Runtime Environment (11.0.21+9) (build 11.0.21+9-post-Ubuntu-0ubuntu122.04) # Java VM: OpenJDK 64-Bit Server VM (11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64) # Problematic frame: # C [libskija.so+0x3bf28d] SkFont::refTypefaceOrDefault() const+0x1d # # Core dump will be written. Default location: Core dumps may be processed with "/lib/systemd/systemd-coredump %P %u %g %s %t 9223372036854775808 %h" (or dumping to /home/ru/clojure/pro-humbleui/core.14916) # # An error report file with more information is saved as: # /home/ru/clojure/pro-humbleui/hs_err_pid14916.log # # If you would like to submit a bug report, please visit: # https://bugs.launchpad.net/ubuntu/+source/openjdk-lts # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # rlwrap: warning: clojure crashed, killed by SIGABRT (core dumped). rlwrap itself has not crashed, but for transparency, it will now kill itself with the same signal warnings can be silenced by the --no-warnings (-n) option Aborted (core dumped)

Руслан Сорокин09:01:28

No Java Exceptions at all. Java crash and in terminal something like this.

Omer ZAK10:01:18

Thanks. You seem to be using Java 11. I use Java 17, and there is Java 21. I do not know if this tidbit is relevant.

Руслан Сорокин10:01:01

Thanks for tip. I try on upgraded Java. Just in case full dump is: ru@ru-sitrol:~/clojure/HumbleUI$ clj Clojure 1.11.1 (require '[io.github.humbleui.ui :as ui]) nil (def UI-animation (ui/row (ui/column (ui/animation "dev/images/animated.gif") (ui/gap 0 10) (ui/label "GIF")) (ui/gap 10 0) (ui/column (ui/animation "dev/images/animated.webp") (ui/gap 0 10) (ui/label "WebP")))) #'user/UI-animation (defn run-animation [] (ui/start-app! (ui/window {:title "Humble 🐝 Animation" :exit-on-close? false} #'UI-animation))) #'user/run-animation (run-animation) #object[clojure.core$future_call$reify__8544 0x11170228 {:status :pending, :val nil}] user=> # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007f72e6bcf28d, pid=16077, tid=16189 # # JRE version: OpenJDK Runtime Environment (11.0.21+9) (build 11.0.21+9-post-Ubuntu-0ubuntu122.04) # Java VM: OpenJDK 64-Bit Server VM (11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64) # Problematic frame: # C [libskija.so+0x3bf28d] SkFont::refTypefaceOrDefault() const+0x1d # # Core dump will be written. Default location: Core dumps may be processed with "/lib/systemd/systemd-coredump %P %u %g %s %t 9223372036854775808 %h" (or dumping to /home/ru/clojure/HumbleUI/core.16077) # # An error report file with more information is saved as: # /home/ru/clojure/HumbleUI/hs_err_pid16077.log # # If you would like to submit a bug report, please visit: # https://bugs.launchpad.net/ubuntu/+source/openjdk-lts # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # rlwrap: warning: clojure crashed, killed by SIGABRT (core dumped). rlwrap itself has not crashed, but for transparency, it will now kill itself with the same signal warnings can be silenced by the --no-warnings (-n) option Aborted (core dumped) ru@ru-sitrol:~/clojure/HumbleUI$

Руслан Сорокин10:01:14

Same result for Java 17 :(

Omer ZAK11:01:35

@Руслан Сорокин, I ran your code (without the ui/animation calls, because I do not have your files). I got the same Java exception I got before: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "x" is null Seems to be a HumbleUI bug (expected, as this package is being developed).

Руслан Сорокин13:01:00

Thank you. It will be great to have a clean HumbleUI environment and easy launch and debugging only on Clojure. So far it's not very "humble" :)

Niki21:01:19

But yes, you don’t need anything beyond clojure to run humbleui project

Niki21:01:54

I published this repo to github https://github.com/HumbleUI/humble-starter

👍 2
escherize23:01:34

Works for me too 👏

Omer ZAK00:01:22

HumbleUI/humble-starter works for me, too. (under clj, not lein)

Руслан Сорокин19:01:06

For me, too. This is exactly what I wanted! Thank you Niki. I wasn't entirely clear when I mentioned Shell and Bash. In some humbleui apps I saw such formula to start: "./script/.." This is new for me, especially that furher goes somthing like "blabla.py" or "blabla.sh". This move me to discuss cleanliness of environment. I understand that CLI is bash, but to use CLI I have to know only CLI, no need to know bash language (almost). That's I mean.

Niki14:01:58

I see. We have python scripts for the sole reason that bash (including Clojure CLI) doesn't work well on Windows

Omer ZAK18:01:21

It seems that the problem (the Cannot invoke "Object.getClass()" because "x" is null exception) with when using leiningen to run my scaryui (the HumbleUI toy application) is due to a difference among java/IRect.java and java-clojure/IRect.java in , which is imported by my application as the dependency [io.github.humbleui/types "0.2.0"] (part of :dependencies declaration). The java-clojure/IRect.java variant declares :x and :y as keywords, but the other variant does not. I still have to find how to get my leiningen configuration to pick up the java-clojure variant rather than the java variant. DISCLAIMER: I did not confirm, yet, that patching the io.github.humbleui/types dependency would cause the problem to go away.

Niki19:01:05

Yes. I think it maven world it’s called “classifier”, so you need io.github.humbleui/types version 0.2.0 with classifier clojure . I have an explanation here https://tonsky.me/blog/humble-decomposition/

Omer ZAK20:01:51

@U050UBKAA, Thanks for the explanation. It confirms my guess that it must be something simple and, from your side of things, trivial. After figuring out how to declare a classifier in leiningen world: by golly, it works! Simply, in :dependencies write:

[io.github.humbleui/types "0.2.0" :classifier "clojure"]
The full project.clj, that I used in my scaryui toy project, is attached to this response. You may want to advise how can we go about adding it to your HumbleUI demo projects so that everyone will be able to freely choose between clj and leiningen.

Руслан Сорокин15:01:36

I slightly changed humbleui-starter example to run application several times:

Руслан Сорокин15:01:03

(ns starter (:require [io.github.humbleui.ui :as ui])) (ui/defcomp app [] [ui/center [ui/label "Hello, world"]]) (defn run [] (ui/start-app! (ui/window {:exit-on-close? false} #'app)))

Руслан Сорокин15:01:20

(require 'starter) nil (starter/run) #object[clojure.core$future_call$reify__8544 0x497ed877 {:status :pending, :val nil}] user=> 00:28.729 Loading align 00:28.762 Loading label

Руслан Сорокин15:01:43

After closing first window the program hung..

Руслан Сорокин15:01:46

How can I debug application, if I can't run it several times?

Niki21:01:47

I usually just never close the window. But if you want to do it, call (ui/start-app!) just once (maybe without window even, it should work, I think), and then call (ui/window {:exit-on-close? false} #'app) as many times as you want (maybe wrapped in app/doui if needed)

Руслан Сорокин06:01:40

@U050UBKAA How do you debug app never closing the window? Can you point me a link to example in which I can update code of the application and repaint its window without closing.

Niki10:01:58

The idea is simple: put window somewhere safe, pass app reference as a var (opposed to plain value), then update that var. Window will automatically redraw All my projects are set up this way, reloading is done by tools.namespace Take a look: https://github.com/HumbleUI/HumbleUI/blob/321a27826b6dca2e35bde3b6ec0fc261f2e71121/dev/user.clj#L37-L44 https://github.com/HumbleUI/humble-deck/blob/8743bda64aff11074dc871b8c8e45da96c02594b/dev/user.clj#L36-L42

Руслан Сорокин17:01:05

@U050UBKAA I see. Humbleui-deck is great. Thank you very much!

Руслан Сорокин09:01:15

# # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007fb842bcf28d, pid=14916, tid=14987 # # JRE version: OpenJDK Runtime Environment (11.0.21+9) (build 11.0.21+9-post-Ubuntu-0ubuntu122.04) # Java VM: OpenJDK 64-Bit Server VM (11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64) # Problematic frame: # C [libskija.so+0x3bf28d] SkFont::refTypefaceOrDefault() const+0x1d # # Core dump will be written. Default location: Core dumps may be processed with "/lib/systemd/systemd-coredump %P %u %g %s %t 9223372036854775808 %h" (or dumping to /home/ru/clojure/pro-humbleui/core.14916) # # An error report file with more information is saved as: # /home/ru/clojure/pro-humbleui/hs_err_pid14916.log # # If you would like to submit a bug report, please visit: # https://bugs.launchpad.net/ubuntu/+source/openjdk-lts # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # rlwrap: warning: clojure crashed, killed by SIGABRT (core dumped). rlwrap itself has not crashed, but for transparency, it will now kill itself with the same signal warnings can be silenced by the --no-warnings (-n) option Aborted (core dumped)