Forum: Ruby Question about GUI API for Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jacek O. (Guest)
on 2006-01-12 13:37
Hi... currently I'm developing a small gui application. I don't know
which API for gui creating should I use. I've tried Tk only. For me it
is quite good (but not so many examples, tutorials is available on the
net). I'm looking for an API, in which I'll be able to create text
viever widgets which supports different colors, fonts and styles in one
widget.

Please help...
Jacek
David V. (Guest)
on 2006-01-12 13:46
(Received via mailing list)
On Thu, 12 Jan 2006 12:37:35 +0100, Jacek O. 
<removed_email_address@domain.invalid>
wrote:

> Hi... currently I'm developing a small gui application. I don't know
> which API for gui creating should I use. I've tried Tk only. For me it
> is quite good (but not so many examples, tutorials is available on the
> net). I'm looking for an API, in which I'll be able to create text
> viever widgets which supports different colors, fonts and styles in one
> widget.
>
> Please help...
> Jacek
>


A very frequently used toolkit is FOX. I have certain issues with the
toolkit, religious and from personal observation of certain persistent
quirks, but at any rate, it's indeed fast, mature, and easy to use /
deploy. It seems to feature a styled text widget too.

Other ones you might want to consider is wxruby if you can handle with
slightly lacking documentation, or a Gtk binding, which might be tricky
getting to work on Windows machines.

David V.
Jacek O. (Guest)
on 2006-01-12 13:56
David V. wrote:
> On Thu, 12 Jan 2006 12:37:35 +0100, Jacek O. <removed_email_address@domain.invalid>
> wrote:
>
>> Hi... currently I'm developing a small gui application. I don't know
>> which API for gui creating should I use. I've tried Tk only. For me it
>> is quite good (but not so many examples, tutorials is available on the
>> net). I'm looking for an API, in which I'll be able to create text
>> viever widgets which supports different colors, fonts and styles in one
>> widget.
>>
>> Please help...
>> Jacek
>>
>
>
> A very frequently used toolkit is FOX. I have certain issues with the
> toolkit, religious and from personal observation of certain persistent
> quirks, but at any rate, it's indeed fast, mature, and easy to use /
> deploy. It seems to feature a styled text widget too.
>
> Other ones you might want to consider is wxruby if you can handle with
> slightly lacking documentation, or a Gtk binding, which might be tricky
> getting to work on Windows machines.
>
> David V.

Thanks for reply David!

Fox can be very good.. I've read some docs on FXRuby site and shown that
FreeRide is using it :)

Wxruby can be good but for me documentation is the most important :)
(and as you said there isn't a lot of docs for wxruby). Gtk for me is
not good too, because my primary os is Windows.

Regards
Jacek
David V. (Guest)
on 2006-01-12 14:13
(Received via mailing list)
On Thu, 12 Jan 2006 12:57:03 +0100, Jacek O. 
<removed_email_address@domain.invalid>
wrote:

>
> Thanks for reply David!
>
> Fox can be very good.. I've read some docs on FXRuby site and shown that
> FreeRide is using it :)

I -have- been getting strange behaviour from it sometimes that occured
to
other people - dialogs opening with the top left corner being
significantly off the screen. Might be dependent on how the computer is
set up so do check for that when deploying the application.

>
> Wxruby can be good but for me documentation is the most important :)
> (and as you said there isn't a lot of docs for wxruby).

Usually, it's possible to make do with the primary wxWidgets
documentation, but I haven't really used it that extensively to rule out
subtle bugs / incompatibility issues. Also, the project entered the
"long
boring rewrite" phase a while ago, and there isn't much apparent
activity
the like of public releases. I favor it mostly because of the use of
native widgets (somewhat of a religious issue), and usually swallow the
bitter pill and do my GUI work in wxPython. I wouldn't quite recommend
wxruby for production code yet.

David V.
Jacek O. (Guest)
on 2006-01-12 15:23
Ok... I've created simple application in FOX, which uses FXText widget.
I'm able to define some styles (called FXHiliteStyle here) to this text
and use them in the future. But I cannot create links, join multiple
defined styles (for example join 'red' with 'bold') etc. (or can I?)
So.... propably I'll back to Tk :(

Regards
Jacek
unknown (Guest)
on 2006-01-12 18:46
(Received via mailing list)
On Thursday 12 January 2006 08:37 pm, Jacek O. wrote:
> Hi... currently I'm developing a small gui application. I don't know
> which API for gui creating should I use. I've tried Tk only. For me it
> is quite good (but not so many examples, tutorials is available on the
> net). I'm looking for an API, in which I'll be able to create text
> viever widgets which supports different colors, fonts and styles in one
> widget.
>
> Please help...
> Jacek

Hey, you want to use GTK if you are targetting windows or linux. The GTK
bindings support unicode, and the GTK API is frozen. There are several
downsides to FOX, but it is included with one click. GTK really should
be too
as its been around longer and trusted. Reasons have been explained
before on
ruby-talk. Should grep the google groups for the reasons. theres also
qtruby,
which bound to a rock solid library, but I'm not sure how many more
changes
rdale wants.. so until its frozen.. :) GTK is most likely the most
stable if
you're wanting pretty. Also, you said you used Tk, check out the
Tk::Tile
library, which you'll have to download apart from ruby or tk.

Tsume
Lyle J. (Guest)
on 2006-01-12 19:22
(Received via mailing list)
On 1/12/06, David V. <removed_email_address@domain.invalid> wrote:

> I -have- been getting strange behaviour from it sometimes that occured to
> other people - dialogs opening with the top left corner being
> significantly off the screen. Might be dependent on how the computer is
> set up so do check for that when deploying the application.

It's not clear from your description whether this is a bug in the
application or a bug in FXRuby. At any rate, there are no open bug
reports that sound like what you're describing (see
http://rubyforge.org/tracker/?atid=1223&group_id=3...). If
you do believe that it's an FXRuby bug and can file a bug report that
describes the problem and how to reproduce it, I'd appreciate it.
David V. (Guest)
on 2006-01-12 22:03
(Received via mailing list)
On Thu, 12 Jan 2006 18:20:15 +0100, Lyle J.
<removed_email_address@domain.invalid>
wrote:

> reports that sound like what you're describing (see
> http://rubyforge.org/tracker/?atid=1223&group_id=3...). If
> you do believe that it's an FXRuby bug and can file a bug report that
> describes the problem and how to reproduce it, I'd appreciate it.
>


[OT]: your client seems to be acting up, or your fingers slipped and you
used "Reply to all" by mistake. In any case, I received this message
both
via ruby-talk, and via my normal e-mail address.

The bug I described I -think- occurs in both FreeRide for the
configuration dialog and the dialog.rb example that comes with the gem.
I
believe it's tied to me having set Windows to 120 dpi fonts, which as
far
as I know very few other people even know of, much less use, which would
explain the lack of a bug report so far.

That said, I should probably get some screenshots done and file a rep
once
I get around to it.

David V.
Marcin MielżyÅ?ski (Guest)
on 2006-01-12 22:30
(Received via mailing list)
Jacek O. wrote:

> Fox can be very good.. I've read some docs on FXRuby site and shown that
> FreeRide is using it :)
>

Fox is very good :D. It has very consistent API (every constructor takes
pointer/reference to parent widget/container so it is easy to create
automation code that read's configuration file and builds the whole gui
at runtime (and actually this solution works very fast). The
interpreting code takes approximately 500 loc. An example is attached
(it can be xml or indentation based format)

lopex
David V. (Guest)
on 2006-01-12 23:25
(Received via mailing list)
On Thu, 12 Jan 2006 17:44:33 +0100, <removed_email_address@domain.invalid> 
wrote:

> changes
> rdale wants.. so until its frozen.. :) GTK is most likely the most
> stable if
> you're wanting pretty. Also, you said you used Tk, check out the Tk::Tile
> library, which you'll have to download apart from ruby or tk.
>
> Tsume
>


I blame Gtk being mentally associated with a lack of an official binary
distribution for Windows - although I'm going out on a limb here, I
don't
really follow happenings around Gtk. Also, anything with a version
number
lower than 1.0 tends to be difficult to get past Managers That Think
They
Know Tech But Really Don't. And on ocassion, I've had some Windows
programs that bundle a binary Gtk build along not work (notably
MudMagic,
haven't really investigated the problem much).

A frozen API isn't everything, ease of deployment is _very_ valuable in
making end-user applications, and fxruby does deliver perfectly in that
respect.

David V.
unknown (Guest)
on 2006-01-13 09:14
(Received via mailing list)
On Friday 13 January 2006 06:23 am, David V. wrote:
> I blame Gtk being mentally associated with a lack of an official binary
> distribution for Windows - although I'm going out on a limb here, I don't

There are windows binaries for ruby-gtk2 and a gtk installer, what are
you
talking about?
> A frozen API isn't everything, ease of deployment is _very_ valuable in
> making end-user applications, and fxruby does deliver perfectly in that
> respect.

A frozen API is very important not only for the programmer, but for
distribution. When you have an app with 20,000 lines of code, you don't
want
the app to break just because you now have to handle another add-in.

and ease of deployment is very easy with Gtk/ruby-gtk2 as well.. if you
read
the fine site :)

Tsume
tony summerfelt (Guest)
on 2006-01-13 15:02
(Received via mailing list)
David V. wrote on 1/12/2006 4:23 PM:

> A frozen API isn't everything, ease of deployment is _very_ valuable in
> making end-user applications,

agreed, as much as i like gtk i have to move on...i keep coming back
to tk. i don't really like the 'feel' of tk in other languages (than
tcl) because it feels tacked on and the syntax is cumbersome, but for
the most part it works, and a one file executable is possible...
David V. (Guest)
on 2006-01-13 16:16
(Received via mailing list)
On Fri, 13 Jan 2006 08:13:05 +0100, <removed_email_address@domain.invalid> 
wrote:

> On Friday 13 January 2006 06:23 am, David V. wrote:
>> I blame Gtk being mentally associated with a lack of an official binary
>> distribution for Windows - although I'm going out on a limb here, I
>> don't
>
> There are windows binaries for ruby-gtk2 and a gtk installer, what are
> you
> talking about?

I never said they weren't, and am in fact quite aware of them.

The Gtk installer definately seems new to me, although I don't really
follow happenings in Gtk - last time I checked (a _long_ time ago) I'm
not
sure if the available installer was official, and I recall not being
able
to get it to work. As unrelated as these arguments may be to the quality
Gtk itself, they're more than enough for me to go for what Just Works
(tm)
instead of tackling quirks.

>> A frozen API isn't everything, ease of deployment is _very_ valuable in
>> making end-user applications, and fxruby does deliver perfectly in that
>> respect.
>
> A frozen API is very important not only for the programmer, but for
> distribution. When you have an app with 20,000 lines of code, you don't
> want
> the app to break just because you now have to handle another add-in.
>

You might be confusing your environments a little. The convention on
Windows is for applications to bundle their dependencies along and use
those versions. If you keep building your 20,000 lines of code against a
version of a library that works, you're also going to redistribute said
library in this version, and rare is the adventurous end user that will
go
on and replace DLLs applications use. For "single-use" internal tools,
this is a perfectly acceptable way of doing things if it lets you use
"deploy by copy".

Of course, for applications that have to be maintained for a long time,
your point stands.

> and ease of deployment is very easy with Gtk/ruby-gtk2 as well.. if you
> read
> the fine site :)

As I said, I blame some aforementioned pet peeves that would make
someone
not make Gtk his first choice on Windows. I never said Gtk wasn't easy
to
deploy, just that it's understandable that people in a production
environment won't readily switch from something that works like a charm
into the unknown unless their current tools shoot them in the foot.
(That's why personal hacking is so essential to a programmer)

David V.
unknown (Guest)
on 2006-01-13 18:10
(Received via mailing list)
On Friday 13 January 2006 09:59 pm, tony summerfelt wrote:
> David V. wrote on 1/12/2006 4:23 PM:
> > A frozen API isn't everything, ease of deployment is _very_ valuable in
> > making end-user applications,
>
> agreed, as much as i like gtk i have to move on...i keep coming back
> to tk. i don't really like the 'feel' of tk in other languages (than
> tcl) because it feels tacked on and the syntax is cumbersome, but for
> the most part it works, and a one file executable is possible...

If you don't like the feel of tk but are addicted to the toolkit, I
recommend
you look in to the Tk::Tile extension.

Tsume
Joe Van D. (Guest)
on 2006-01-13 19:53
(Received via mailing list)
On 1/13/06, removed_email_address@domain.invalid 
<removed_email_address@domain.invalid> wrote:
> A frozen API is very important not only for the programmer, but for
> distribution. When you have an app with 20,000 lines of code, you don't want
> the app to break just because you now have to handle another add-in.
>
> and ease of deployment is very easy with Gtk/ruby-gtk2 as well.. if you read
> the fine site :)

Some guy recently posted to ruby-gnome2 about a .zip file that he made
that contained a ruby + gnome2 executable that you could run without
having anything installed previously.  Pretty neat.  And the
application looked pretty good too.
Wilson B. (Guest)
on 2006-01-13 21:01
(Received via mailing list)
On 1/13/06, Joe Van D. <removed_email_address@domain.invalid> wrote:
> >
> application looked pretty good too.
Do you have a link to the mailing list posting? I've been struggling
with Rubyscript2EXE, attempting to deploy a Ruby/GTK application I
wrote.  I'm having a lot of trouble bundling non-ruby/dll resources,
such as YAML files and glade configs.  I'm just about ready to write
an NSIS installer instead.
Joe Van D. (Guest)
on 2006-01-13 21:19
(Received via mailing list)
On 1/13/06, Wilson B. <removed_email_address@domain.invalid> wrote:
> > > > respect.
> > having anything installed previously.  Pretty neat.  And the
> > application looked pretty good too.
>
> Do you have a link to the mailing list posting? I've been struggling
> with Rubyscript2EXE, attempting to deploy a Ruby/GTK application I
> wrote.  I'm having a lot of trouble bundling non-ruby/dll resources,
> such as YAML files and glade configs.  I'm just about ready to write
> an NSIS installer instead.

http://sourceforge.net/mailarchive/message.php?msg...
Jamey C. (Guest)
on 2006-01-13 22:14
(Received via mailing list)
On Sat, 14 Jan 2006 04:00:36 +0900
Wilson B. <removed_email_address@domain.invalid> wrote:

> Do you have a link to the mailing list posting? I've been struggling
> with Rubyscript2EXE, attempting to deploy a Ruby/GTK application I
> wrote.  I'm having a lot of trouble bundling non-ruby/dll resources,
> such as YAML files and glade configs.  I'm just about ready to write
> an NSIS installer instead.

Are you putting the non-ruby files in the application directory and
using tar2rubyapp (or whatever it's called) in conjunction with
rubyscript2exe?

I've used rubyscript2exe a lot to deploy both FXRuby apps and Ruby-Gtk2
apps and, if I remember correctly, if you place the non-ruby files like
dlls and image files in the application directory that you use in
conjunction with tar2rubyscript, it will include these files in the exe.

HTH,

Jamey C.

Confidentiality Notice: This email message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and/or privileged information. If you are not the intended
recipient(s), you are hereby notified that any dissemination,
unauthorized review, use, disclosure or distribution of this email and
any materials contained in any attachments is prohibited. If you receive
this message in error, or are not the intended recipient(s), please
immediately notify the sender by email and destroy all copies of the
original message, including attachments.
Hidetoshi NAGAI (Guest)
on 2006-01-14 19:36
(Received via mailing list)
From: removed_email_address@domain.invalid
Subject: Re: Question about GUI API for Ruby
Date: Sat, 14 Jan 2006 01:09:07 +0900
Message-ID: <removed_email_address@domain.invalid>
> If you don't like the feel of tk but are addicted to the toolkit, I recommend
> you look in to the Tk::Tile extension.

Additional Information.;-)
On ruby-1.8.4, "Tk::Tile.__Import_Tile_Widgets__!" method was added.
After calling the method, some widget classes denote classes on Tile
(e.g. TkButton.new generates a Tk::Tile::Button widget).
tony summerfelt (Guest)
on 2006-01-14 20:21
(Received via mailing list)
Jamey C. wrote on 1/13/2006 3:12 PM:

> Are you putting the non-ruby files in the application directory and
> using tar2rubyapp (or whatever it's called) in conjunction with
> rubyscript2exe?

> conjunction with tar2rubyscript, it will include these files in the exe.

tried that, and the dll's are included, but there's still something
missing. i'm thinking it's a gtk directory structure problem, and that
 environment variables will need to be set when the rubyscript2exe exe
is run...

i've worked at it for awhile but no luck yet...
tony summerfelt (Guest)
on 2006-01-14 20:21
(Received via mailing list)
Wilson B. wrote on 1/13/2006 2:00 PM:

>>Some guy recently posted to ruby-gnome2 about a .zip file that he made
>>that contained a ruby + gnome2 executable that you could run without

> Do you have a link to the mailing list posting? I've been struggling
> with Rubyscript2EXE, attempting to deploy a Ruby/GTK application I
> wrote.  I'm having a lot of trouble bundling non-ruby/dll resources,

that's where i'm at with ruby/gtk. i've been on the ruby-gnome mailing
list for a few weeks , but i must have missed that post...
tony summerfelt (Guest)
on 2006-01-14 20:21
(Received via mailing list)
removed_email_address@domain.invalid wrote on 1/13/2006 11:09 AM:

> If you don't like the feel of tk but are addicted to the toolkit, I recommend
> you look in to the Tk::Tile extension.

i will do that :)
unknown (Guest)
on 2006-01-14 23:34
(Received via mailing list)
On Sunday 15 January 2006 02:33 am, Hidetoshi NAGAI wrote:
>
> Additional Information.;-)
> On ruby-1.8.4, "Tk::Tile.__Import_Tile_Widgets__!" method was added.
> After calling the method, some widget classes denote classes on Tile
> (e.g. TkButton.new generates a Tk::Tile::Button widget).

Very nice. Why can't this be used on initialization if tile is
available? Also
have a method to deactivate the feature. I'm arguing because it should
be
what users would want. People want pretty by default. Theres no harm in
doing
so, and I believe most people would be using the line thinking it should
be
default if tile is installed.

Tsume
Hidetoshi NAGAI (Guest)
on 2006-01-15 02:43
(Received via mailing list)
From: removed_email_address@domain.invalid
Subject: Re: Question about GUI API for Ruby
Date: Sun, 15 Jan 2006 06:26:20 +0900
Message-ID: <removed_email_address@domain.invalid>
> Very nice. Why can't this be used on initialization if tile is available?
> Also have a method to deactivate the feature.

If called the method, the feature cannot be deactivated.
The method replaces some commands on *TK INTERPRETER*.
So, some mega-widgets may be able to benefit by Tile extension.
But, it is very risky because Tile widgets are NOT full compatible
to standard widgets.
It means that the method may make some other mega-widgets not work.

In the near future when Tile extension will be one of the standard
library of Tcl/Tk8.5, the risk may not exist or the feature may
be able to be deactivated.
Before that, the dangerous method cannot be called by default.
unknown (Guest)
on 2006-01-15 07:44
(Received via mailing list)
On Sunday 15 January 2006 09:40 am, Hidetoshi NAGAI wrote:
> If called the method, the feature cannot be deactivated.
> The method replaces some commands on *TK INTERPRETER*.
> So, some mega-widgets may be able to benefit by Tile extension.
> But, it is very risky because Tile widgets are NOT full compatible
> to standard widgets.
> It means that the method may make some other mega-widgets not work.

I found how to activate different themes, and notice the errors.
Hopefully
there will be work to make them compatible. Having tile as the default
rendering would be nice to have when programming with Tk.

>
> In the near future when Tile extension will be one of the standard
> library of Tcl/Tk8.5, the risk may not exist or the feature may
> be able to be deactivated.
> Before that, the dangerous method cannot be called by default.

I can imagine when they are integrated the compatibility will be 100%.

Tsume
Wilson B. (Guest)
on 2006-01-16 01:51
(Received via mailing list)
On 1/13/06, Jamey C. <removed_email_address@domain.invalid> wrote:
> using tar2rubyapp (or whatever it's called) in conjunction with
>
Thanks for this reply.  I think it points out something fundamental in
my (lack of) understanding of RubyScript2EXE.  I've been using the
rscript2exe.rb file directly to package the app.  Should I be breaking
it into multiple steps in some way?  The examples on the Rubyscript
page show it being run directly, and from what I saw, they mention
tar2rubyscript only in the form of a dependency, not as something I
should be using myself.

By 'application directory', do you mean the same directory as the main
whatever_my_app_is.rb file that handles the creation of the Gtk
windows, etc?
Guillaume M. (Guest)
on 2006-01-16 15:18
(Received via mailing list)
Here is a quick example. It doesn't contain any C library, but it
behaves the same way:

[gus@hibernatus Perso]$ ls -lR hellotheworld
hellotheworld:
total 4
-rwxrw-r--  1 gus gus 70 Jan 16 08:07 init.rb*
drwxrwxr-x  2 gus gus 80 Jan 16 08:07 lib/

hellotheworld/lib:
total 4
-rw-rw-r--  1 gus gus 66 Jan 16 08:06 hellotheworld.rb
[gus@hibernatus Perso]$ cat hellotheworld/lib/hellotheworld.rb
class Hello
   def say_hello
     puts "Hello the world!"
   end
end
[gus@hibernatus Perso]$ cat hellotheworld/init.rb
#!/usr/bin/env ruby

require 'lib/hellotheworld'

Hello.new.say_hello

The name init.rb is important. That is what tar2rubyscript will launch.
Let pack it:

[gus@hibernatus Perso]$ tar2rubyscript.rb hellotheworld/
Creating archive...
Creating hellotheworld.rb ...
[gus@hibernatus Perso]$ ruby ./hellotheworld.rb
Hello the world!

Good, we have an autonomous script. Let add ruby to it:

[gus@hibernatus Perso]$ rubyscript2exe.rb hellotheworld.rb
Tracing hellotheworld ...
Hello the world!
Gathering files...
Copying files...
Stripping...
Creating hellotheworld_linux ...
[gus@hibernatus Perso]$ ./hellotheworld_linux
Hello the world!

Hope this helps,
Guillaume.

Le 15 janv. 06, à 18:50, Wilson B. a écrit :
unknown (Guest)
on 2006-01-21 16:40
(Received via mailing list)
On Sunday 15 January 2006 02:33 am, Hidetoshi NAGAI wrote:
> After calling the method, some widget classes denote classes on Tile
> (e.g. TkButton.new generates a Tk::Tile::Button widget).

Well, heres a good question. How can one load a different style. I see a
method declared Tile.style, but I can't seem to load Clam style
Tk::Tile.style('Clam')

Tsume
Hidetoshi NAGAI (Guest)
on 2006-01-21 16:40
(Received via mailing list)
From: removed_email_address@domain.invalid
Subject: Re: Question about GUI API for Ruby
Date: Sun, 15 Jan 2006 08:48:44 +0900
Message-ID: <removed_email_address@domain.invalid>
> Well, heres a good question. How can one load a different style. I see a
> method declared Tile.style, but I can't seem to load Clam style
> Tk::Tile.style('Clam')

On my environment,
-----------------------------------------------------
$ /usr/local/bin/irb
irb(main):001:0> require 'tkextlib/tile'
=> true
irb(main):002:0> Tk::Tile::Style.theme_names
=> ["step", "clam", "alt", "default", "classic"]
irb(main):003:0> Tk::Tile::Style.theme_use('clam')
=> ""
irb(main):004:0> Tk::Tile.style('clam')
=> "clam"
This topic is locked and can not be replied to.