AndyObtiva / glimmer-dsl-libui

Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library - The Quickest Way From Zero To GUI - If You Liked Shoes, You'll Love Glimmer! - No need to pre-install any prerequisites. Just install the gem and have platform-independent GUI that just works on Mac, Windows, and Linux.
MIT License
497 stars 15 forks source link

Multiple executions in IRB causes error #45

Open rvs314 opened 1 year ago

rvs314 commented 1 year ago

When running a simple example in IRB, I get a weird result where running a program multiple times causes the second invocation to make an empty window.

Here's an example interaction:

irb(main):001:0> require 'glimmer-dsl-libui'
=> true
irb(main):006:0> include Glimmer
=> Object
irb(main):008:0> window('test') {
irb(main):010:1*     button('Click Me')
irb(main):011:1>   }.show # window displays correctly, call is blocking
=> nil
irb(main):014:0> window('test') {
irb(main):015:1*     button('Click Me')
irb(main):016:1>   }.show # window opens, but does not update; call is non-blocking
=> nil
irb(main):017:0> # repl is still live, but the window does not redisplay

This looks like an analogue of this issue in the underlying LibUI bindings.

I'm using Debian GNU/Linux 6.1.0-6-amd64, ruby 3.1.2p20, XOrg Version: 1:7.7+23 and dwm-6.2.

AndyObtiva commented 1 year ago

Please use girb instead (Glimmer IRB): https://github.com/AndyObtiva/glimmer-dsl-libui#girb-glimmer-irb

It automatically requires the glimmer-dsl-libui library and includes Glimmer for you.

Also, it allows opening a window multiple times with no practical problem.

The only known issue it suffers from is when you close the window (via x button or by quitting), it keeps the window open, but if you re-open the window with different title/content, the new title/content shows up, so it's not a problem practically speaking.

Otherwise, you have another option for playing around with Glimmer DSL for LibUI applications. Start the Glimmer Meta-Example (via ruby -r glimmer-dsl-libui -e "require 'examples/meta_example'" command), which lets you start multiple applications from the same code editor with no problem.: https://github.com/AndyObtiva/glimmer-dsl-libui#examples

I believe both options above should address your concerns/goals, so I am closing this issue. But, if you still have issues or you have other comments to share, please reply or even re-open the issue if needed.

rvs314 commented 1 year ago

@AndyObtiva

Sorry for resurrecting this, but I don't think this fixes my issue. At least, repeating the issue in girb causes the same error. When it starts, I get the following messages:

Gtk-Message: 14:03:38.638: Failed to load module "xapp-gtk3-module"
irb: warn: can't alias exit from irb_exit.
irb: warn: can't alias quit from irb_exit.

Typing in the example I gave above, the second invocation (even with new contents) doesn't render.

I am able to start multiple applications from the meta-example viewer, but it doesn't really solve the issue of not being able to use them in IRB.

AndyObtiva commented 1 year ago

You do not have to be sorry for resurrecting this. However, this might just be a Linux-only issue as it works fine on my Mac. I didn't think of testing on Linux. I'm sorry about this. I will take a look when I get a chance.

By the way, by "should address your concerns/goals", I meant addressing the ultimate goal behind using both IRB and Meta-Example, which is to be able to prototype Ruby Glimmer apps quickly. To me personally, the Meta-Example is good enough in addressing that goal/concern to the point that I rarely use IRB. Sometimes, it is a good idea to step back and realize that a certain tool is not needed if there are better alternatives that address the same goals behind it, and I sometimes have to discipline myself against using a certain popular tool (letting go of attachment to it) if I have other more effective tools at my disposal. Otherwise, I would be hurting productivity in finishing apps for customers unnecessarily. But, perhaps there is a goal for why to use IRB that the Meta-Example does not address, like being able to go up in the command history to re-run previous commands. So, I will still look into the issue on Linux to figure out if there is a fix for it. And, I hope that the Meta-Example could address part of your goal/concern in the meantime until the IRB issue is resolved if possible.

rvs314 commented 1 year ago

I didn't think of testing on Linux. I'm sorry about this. I will take a look when I get a chance.

Thanks - let me know if there's anything you want me to help/test on my end.

By the way, by "should address your concerns/goals", I meant addressing the ultimate goal behind using both IRB and Meta-Example, which is to be able to prototype Ruby Glimmer apps quickly. To me personally, the Meta-Example is good enough in addressing that goal/concern to the point that I rarely use IRB. Sometimes, it is a good idea to step back and realize that a certain tool is not needed if there are better alternatives that address the same goals behind it, and I sometimes have to discipline myself against using a certain popular tool (letting go of attachment to it) if I have other more effective tools at my disposal. Otherwise, I would be hurting productivity in finishing apps for customers unnecessarily.

That makes sense, each person works differently. The project I'm working on relies on communicating with several live connections which are best handled interactively, hence IRB.

AndyObtiva commented 1 year ago

That makes sense. Sounds good. I’ll let you know if I need any help. I haven’t had a chance to take a look on Linux yet, but I’ll let you know as soon as I have.

AndyObtiva commented 1 year ago

I was able to reproduce and confirm this issue on Linux.

I could not come up with a fix for it yet, but if I do in the future, you will hear of it here.