humbleui

Niki 2024-01-15T20:45:54.365879Z

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)

👍 2
🤯 2
👀 6
💓 18
Niki 2024-01-29T10:47:58.958979Z

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

ru 2024-01-29T17:41:05.344799Z

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

Niki 2024-01-19T14:34:58.037349Z

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

ru 2024-01-18T19:55:06.727579Z

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.

Omer ZAK 2024-01-24T18:20:21.586959Z

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.

Niki 2024-01-24T19:30:05.904109Z

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 ZAK 2024-01-24T20:32:51.710039Z

@tonsky, 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.

Niki 2024-01-15T20:49:22.055009Z

honestly feels easier than starting a web app

💯 7
Omer ZAK 2024-01-16T00:16:32.312719Z

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 ZAK 2024-01-16T00:21:04.628589Z

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: ).

Niki 2024-01-16T00:34:46.588499Z

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 ZAK 2024-01-16T00:44:11.350509Z

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

Omer ZAK 2024-01-16T01:18:26.918349Z

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 ZAK 2024-01-16T01:20:24.017569Z

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

ru 2024-01-17T08:29:38.270179Z

👍

Niki 2024-01-17T21:33:43.924419Z

@zspovenetsky all I was saying is that your clj command is all bash https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/clojure

Niki 2024-01-17T21:34:19.813299Z

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

Niki 2024-01-17T21:45:54.183589Z

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

👍 2
Adrian Smith 2024-01-17T21:52:53.674759Z

Cool

escherize 2024-01-17T23:43:34.709219Z

Works for me too 👏

Omer ZAK 2024-01-18T00:24:22.967359Z

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

ru 2024-01-28T15:43:36.907729Z

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

ru 2024-01-28T15:44:03.843249Z

(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)))

ru 2024-01-28T15:46:20.627419Z

(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

ru 2024-01-28T15:47:43.206989Z

After closing first window the program hung..

ru 2024-01-28T15:51:46.220809Z

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

Niki 2024-01-28T21:20:47.496429Z

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)

ru 2024-01-29T06:45:40.486079Z

@tonsky 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.

ru 2024-01-16T08:17:06.248409Z

Hello! I am a newbie.

ru 2024-01-16T08:18:55.335809Z

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

ru 2024-01-16T08:20:13.349169Z

No python, no shell and so on..

ru 2024-01-16T08:35:30.324909Z

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

Omer ZAK 2024-01-16T09:24:43.795129Z

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

ru 2024-01-16T09:48:15.249059Z

# # 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)

ru 2024-01-16T09:48:28.280929Z

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

Omer ZAK 2024-01-16T10:03:18.660529Z

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.

ru 2024-01-16T10:31:01.560139Z

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$

ru 2024-01-16T10:32:14.430519Z

Same result for Java 17 :(

Omer ZAK 2024-01-16T11:04:35.945189Z

@Руслан Сорокин, 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).

ru 2024-01-16T13:39:00.067399Z

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" :)

Niki 2024-01-16T16:32:06.541769Z

@zspovenetsky what OS are you on?

Niki 2024-01-16T16:32:48.977999Z

> Clojure CLI tools > No python, no shell and so on.. But Clojure CLI is shell

Niki 2024-01-16T16:33:12.199759Z

But technically yes, deps.edn with humble dependency is all you need

Niki 2024-01-16T16:34:51.279689Z

If found it was Ubuntu. Maybe it was broken recently, there are people working on X11 from time to time, I don’t check it regularly

Niki 2024-01-16T16:36:06.938099Z

> java.lang.ClassNotFoundException: http://io.github.humbleui.jwm.App Looks like lein-deps-git doesn’t handle transitive dependencies? Is JWM on classpath?

Omer ZAK 2024-01-16T17:20:10.497419Z

@tonsky, I fixed the java.lang.ClassNotFoundException: problem by adding more dependencies to project.clj, while consulting with your deps.edn. Now my stumbling block is java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "x" is null. Currently, my dependencies are:

:dependencies [[org.clojure/clojure "1.11.1"]
                 ;;[io.github.humbleui/types$clojure "0.2.0"]
                 [io.github.humbleui/types "0.2.0"]
                 [io.github.humbleui/jwm "0.4.15" :exclusions [io.github.humbleui/types]]
                 [io.github.humbleui/skija-linux-x64 "0.116.1" :exclusions [io.github.humbleui/types]]
                 ]

ru 2024-01-16T17:21:08.702619Z

Shell I mean bash. I use Mint 21.3. If we can do without leiningen?

ru 2024-01-16T17:22:18.085089Z

Only CLI that is native to Clojure.

Omer ZAK 2024-01-16T17:23:25.723829Z

By the way, I am working on Debian 11 (Bullseye). I got Clojure to work on it in spite of the naysayers who advised me to upgrade to Debian 12 (Bookworm). I also use java-17-openjdk-amd64.

ru 2024-01-16T17:30:29.650079Z

I understand that can be aproach to use any tool that suit better. But other approach to stay in clean environment is also has its rights. May just this approach helps avoid this issue of different OSes.

ru 2024-01-16T17:38:14.274559Z

My only dependency difference that I use [io.github.humbleui/types$clojure "0.2.0"]

ru 2024-01-16T17:54:19.451119Z

When I replace with [io.github.humbleui/types "0.2.0"] I'v got: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "x" is null, , same of Omer ZAK's.

teodorlu 2024-01-16T17:57:40.400189Z

I’m looking forward to using this. No ports, no websockets, just a REPL and an UI. Thanks for making this!

❤️ 3
Omer ZAK 2024-01-16T18:07:34.737729Z

I am hereby reporting partial success. Partial because it is outside of lein. The following is after editing files.

$ pwd
<miscellaneous subdirectories>/scaryui
$ diff .lein-git-deps/HumbleUI/depeps.edn 
1c1
< {:paths ["src" "resources"]
---
> {:paths ["src" "resources" ".lein-git-deps/HumbleUI/src"]
$ clj
Clojure 1.11.1
user=> (require '[scaryui.core])
nil
user=> (scaryui.core/-main)
#object[clojure.core$future_call$reify__8544 0x1f4dd016 {:status :pending, :val nil}]
and I get the window. The contents of my scaryui/core.clj in this experiment were:
(ns scaryui.core
  (:require [io.github.humbleui.ui :as ui])
  (:gen-class))

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

(defn -main
  "Trying it"
  [& args]
  (ui/start-app!
   (ui/window
    {:title "Humble 🐝 UI"}
    #'ui2)))
However, I would still like to get lein run to work on this.

ru 2024-01-16T19:31:49.794879Z

Great! By the way, clj and lein are de facto standard in many github apps.

Omer ZAK 2024-01-16T23:38:28.113779Z

Actually, I used both. lein was used to retrieve dependencies (lein deps; lein git-deps) and clj - to actually run the scary 😁 stuff.