[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Best OS-X GUI creator for non-programmer

12 34

7/28/2007 7:08:00 PM

I've written a relatively simple script which has about five
files/directories that need to be selected and several other options.
They are currently manually set in the script, i.e., as variables. I'd
like to have a GUI and here is what I think are my requirements:

OS X-prefer native, but web would be OK since I don't need a fancy
interface
Select files (show the last selection used as the default, even if used
weeks later)
Select folders (show the last selection used as the default, even if
used weeks later)
Drop down selection for some options
Check boxes for other options
A confirmation window listing the options selected with "a go back" or
"go ahead choice"
Run the script
Progress bar
Report when finished.

I'm not a programmer. Not obvious to me how to implement this in XCode.
My XCode experience is pretty much limited to a simple AppleScript app
about two years ago. I am missing that when creating an AppleScript app
that after creating the UI (in IB), XCode creates such things "on awake
from nib" and "on clicked" which got me over one big hump. I'm looking
for something similar for Ruby--RubyCocoa doesn't seem to do this; and
this is the difficult part for me. Or am I missing something? Or is this
going to be in Leopard?

I've read at least 20 threads on this site and via Google. I've looked
at some of the documentation for the universal GUIs and the learning
curves seems as tough as XCode. None of the tutorials that I've seen for
XCode go as deep as selecting files/folders and saving the choices.

I can imagine how this might be done in Rails (zero experience, but I've
done a little PHP and imagine that choices can be stored in MySQL
databases,text files or YAML).

Maybe my question is: Is XCode or Rails the easiest way to go for a
non-programmer? I also looked at newcocoa, but since I don't know Rails,
it wasn't a help.

I realize this is a big question, but thanks for any ideas. Or books to
read?
--
Posted via http://www.ruby-....

22 Answers

John Joyce

7/28/2007 7:15:00 PM

0


On Jul 28, 2007, at 2:07 PM, 12 34 wrote:

> I've written a relatively simple script which has about five
> files/directories that need to be selected and several other options.
> They are currently manually set in the script, i.e., as variables. I'd
> like to have a GUI and here is what I think are my requirements:
>
> OS X-prefer native, but web would be OK since I don't need a fancy
> interface
> Select files (show the last selection used as the default, even if
> used
> weeks later)
> Select folders (show the last selection used as the default, even if
> used weeks later)
> Drop down selection for some options
> Check boxes for other options
> A confirmation window listing the options selected with "a go back" or
> "go ahead choice"
> Run the script
> Progress bar
> Report when finished.
>
> I'm not a programmer. Not obvious to me how to implement this in
> XCode.
> My XCode experience is pretty much limited to a simple AppleScript app
> about two years ago. I am missing that when creating an AppleScript
> app
> that after creating the UI (in IB), XCode creates such things "on
> awake
> from nib" and "on clicked" which got me over one big hump. I'm looking
> for something similar for Ruby--RubyCocoa doesn't seem to do this; and
> this is the difficult part for me. Or am I missing something? Or is
> this
> going to be in Leopard?
>
> I've read at least 20 threads on this site and via Google. I've looked
> at some of the documentation for the universal GUIs and the learning
> curves seems as tough as XCode. None of the tutorials that I've
> seen for
> XCode go as deep as selecting files/folders and saving the choices.
>
> I can imagine how this might be done in Rails (zero experience, but
> I've
> done a little PHP and imagine that choices can be stored in MySQL
> databases,text files or YAML).
>
> Maybe my question is: Is XCode or Rails the easiest way to go for a
> non-programmer? I also looked at newcocoa, but since I don't know
> Rails,
> it wasn't a help.
>
> I realize this is a big question, but thanks for any ideas. Or
> books to
> read?
> --
> Posted via http://www.ruby-....
>

Consider Rails, but there is a lot to learn there. It's Ruby, but not
quite like working with a usual script.
Perhaps easier, and definitely native GUI look, consider Platypus:
http://www.sveinbjorn.or...

12 34

7/28/2007 7:19:00 PM

0

John Joyce wrote:
> On Jul 28, 2007, at 2:07 PM, 12 34 wrote:
>
>> Select folders (show the last selection used as the default, even if
>> XCode.
>>
>>
>>
> Consider Rails, but there is a lot to learn there. It's Ruby, but not
> quite like working with a usual script.
> Perhaps easier, and definitely native GUI look, consider Platypus:
> http://www.sveinbjorn.or...

I had downloaded Platypus and didn't see anything about selecting files
and folders. But maybe I don't know the terminology.
--
Posted via http://www.ruby-....

John Joyce

7/28/2007 7:37:00 PM

0


On Jul 28, 2007, at 2:19 PM, 12 34 wrote:

> John Joyce wrote:
>> On Jul 28, 2007, at 2:07 PM, 12 34 wrote:
>>
>>> Select folders (show the last selection used as the default, even if
>>> XCode.
>>>
>>>
>>>
>> Consider Rails, but there is a lot to learn there. It's Ruby, but not
>> quite like working with a usual script.
>> Perhaps easier, and definitely native GUI look, consider Platypus:
>> http://www.sveinbjorn.or...
>
> I had downloaded Platypus and didn't see anything about selecting
> files
> and folders. But maybe I don't know the terminology.
> --
> Posted via http://www.ruby-....
>
I hate to say it, but read the docs for it. I've never used it, but
on macosxhints.com (a good source for things like this for OS X) it
is pretty highly rated. It also gets mentioned on various cocoa and
os x prorgramming mailing lists pretty often.
Short of learning Rails or learning Cocoa.
you could also look into RubyCocoa, but you'll still need a book on
XCode and some understanding of Cocoa framework to really start to
make something, you might checkout the WROX publishing book (one of
the red ones) Beginning OS X Programming. They might talk about some
of this stuff, but I don't recall.
If there is one thing I have learned about programming, it's the GUI
part of frameworks that can be hard.
But rewarding too!
If you do choose to go the XCode route, you will find that it's
actually pretty easy to build the interface in XCode, it's just a
little confusing about how to wire everything up. If you plan to do
more of these, then you really should go out and get Aaron Hillegass'
book Cocoa Programming for OS X, it's the 'pickaxe' book of OS X
programming.
A new version will be out at the end of this year or early next year,
but it's still a worthwhile purchase if you're into OS X programming
at all.

OH, wait a second, there is one more alternative: AppleScript.
There is also an AppleScript gem to allow you to use Ruby with
applescript a little differently.
AppleScript can also create fully GUI apps.

but again, you'll want one of the books on AppleScript before jumping
into that. The language itself is not hard, and it gives you a lot of
hooks in to a lot of OS X apps.

matt

7/28/2007 8:21:00 PM

0

12 34 <rubyforum@web.knobby.ws> wrote:

> I've written a relatively simple script which has about five
> files/directories that need to be selected and several other options.
> They are currently manually set in the script, i.e., as variables. I'd
> like to have a GUI and here is what I think are my requirements:
>
> OS X-prefer native, but web would be OK since I don't need a fancy
> interface
> Select files (show the last selection used as the default, even if used
> weeks later)
> Select folders (show the last selection used as the default, even if
> used weeks later)
> Drop down selection for some options
> Check boxes for other options
> A confirmation window listing the options selected with "a go back" or
> "go ahead choice"
> Run the script
> Progress bar
> Report when finished.
>
> I'm not a programmer. Not obvious to me how to implement this in XCode.
> My XCode experience is pretty much limited to a simple AppleScript app
> about two years ago. I am missing that when creating an AppleScript app
> that after creating the UI (in IB), XCode creates such things "on awake
> from nib" and "on clicked" which got me over one big hump. I'm looking
> for something similar for Ruby--RubyCocoa doesn't seem to do this

You're wrong about that. RubyCocoa is Cocoa; indeed, you get far *more*
events / notifications than you do with AppleScript Studio.

If I were doing what you are doing, though I would just write a native
Objective-C Cocoa app with the Ruby script built in, calling the Ruby
script thru NSTask at the appropriate moment. You could in fact do the
same thing with AppleScript Studio, just as in the example in my book
where AppleScript suddenly turns to Perl to do some heavy lifting.

m.

--
matt neuburg, phd = matt@tidbits.com, http://www.tidbits...
Tiger - http://www.takecontrolbooks.com/tiger-custom...
AppleScript - http://www.amazon.com/gp/product/...
Read TidBITS! It's free and smart. http://www.t...

12 34

7/28/2007 8:45:00 PM

0

John Joyce wrote:
> On Jul 28, 2007, at 2:19 PM, 12 34 wrote:
>
Thanks for your comments. They are helping.
> I hate to say it, but read the docs for it.
I did, but am missing the select files dialog. But I'll look again.

I've never used it, but
> on macosxhints.com (a good source for things like this for OS X) it
> is pretty highly rated. It also gets mentioned on various cocoa and
> os x prorgramming mailing lists pretty often.

> Short of learning Rails or learning Cocoa.
> you could also look into RubyCocoa, but you'll still need a book on
> XCode and some understanding of Cocoa framework to really start to
> make something, you might checkout the WROX publishing book (one of
> the red ones) Beginning OS X Programming.

I don't think the distintion between Cocoa and Objective-C had quite
sunk in. Thanks.

snip

> then you really should go out and get Aaron Hillegass'
> book Cocoa Programming for OS X, it's the 'pickaxe' book of OS X
> programming.

On my Amazon wish list now. Awaiting more discussion and perusing.

> OH, wait a second, there is one more alternative: AppleScript.
> There is also an AppleScript gem to allow you to use Ruby with
> applescript a little differently.
> AppleScript can also create fully GUI apps.

It can? I didn't think so. Can create some interaction, but I think you
need another tool (such as Platypus, Pashua, or XCode) to have more than
line at time dialogs.
>
> but again, you'll want one of the books on AppleScript before jumping
> into that. The language itself is not hard, and it gives you a lot of
> hooks in to a lot of OS X apps.

I'm trying to get away from AS, that's why I went to Ruby. As I said I'm
not a programmer, but I can write much faster in Ruby--probably because
the Standard Library and Built in Classes and Modules are so much
broader. I just go to PickAxe and/or Black and find what I need. And I
seem to be able to put the pieces together and they generally work. They
almost never do for me in AS.

I'm presuming you're thinking of rb-appscript. Maybe there's a way to
create and XCode AppleScript application which will then give me the
hooks to the UI and then use Ruby, but that seems too tortured.

Ah! your suggestion leads me to using "dialog display" or "choose file"
via rb-appscript from the Ruby script. I'll give that a try. Not quite a
GUI, but might be good enough for now or until I learn Cocoa.

Enough rambling.

Thanks for your comments John.
--
Posted via http://www.ruby-....

12 34

7/28/2007 9:01:00 PM

0

matt neuburg wrote:
> 12 34 <rubyforum@web.knobby.ws> wrote:
>
>>
>>I am missing that when creating an AppleScript app
>> that after creating the UI (in IB), XCode creates such things "on awake
>> from nib" and "on clicked" which got me over one big hump. I'm looking
>> for something similar for Ruby--RubyCocoa doesn't seem to do this
>
Maybe I'm misremembering, but I thought XCode created the on clicks,
etc. automatically which gave a framework to put in the AS script
pieces. But I'd better look at this again in both AS and RubyCocoa apps.
But what I understood in my RubyCocoa reading was that the user had to
create all the links to the UI.

> You're wrong about that. RubyCocoa is Cocoa; indeed, you get far *more*
> events / notifications than you do with AppleScript Studio.
>
I think I get that, but to me it looks like another language to learn.
But as I said in another response I may do it.

> If I were doing what you are doing, though I would just write a native
> Objective-C Cocoa app with the Ruby script built in, calling the Ruby
> script thru NSTask at the appropriate moment. You could in fact do the
> same thing with AppleScript Studio, just as in the example in my book
> where AppleScript suddenly turns to Perl to do some heavy lifting.
>
> m.
Matt

If I knew Obj-C I'd probably have enough experience to handle Cocoa
easily. I'm afraid there's too much interaction with the Ruby script to
make the going back and forth to AS worthwhile, but I'll consider it.
Just to confirm, you're talking about Chap. 23, p.364 "Do shell script"?

BTW, it was your article on Ruby that got me to dive into Ruby.
--
Posted via http://www.ruby-....

12 34

7/28/2007 10:12:00 PM

0

John Joyce wrote:
> On Jul 28, 2007, at 2:19 PM, 12 34 wrote:
>
>>> Perhaps easier, and definitely native GUI look, consider Platypus:

>>
>> I had downloaded Platypus and didn't see anything about selecting
>> files and folders. But maybe I don't know the terminology.
>>
> I hate to say it, but read the docs for it.

OK found it. CocoaDialog. Platypus uses this to create the dialog boxes.
And it can be used directly from Ruby.
--
Posted via http://www.ruby-....

John Joyce

7/28/2007 11:03:00 PM

0


On Jul 28, 2007, at 4:01 PM, 12 34 wrote:

> matt neuburg wrote:
>> 12 34 <rubyforum@web.knobby.ws> wrote:
>>
>>>
>>> I am missing that when creating an AppleScript app
>>> that after creating the UI (in IB), XCode creates such things "on
>>> awake
>>> from nib" and "on clicked" which got me over one big hump. I'm
>>> looking
>>> for something similar for Ruby--RubyCocoa doesn't seem to do this
>>
> Maybe I'm misremembering, but I thought XCode created the on clicks,
> etc. automatically which gave a framework to put in the AS script
> pieces. But I'd better look at this again in both AS and RubyCocoa
> apps.
> But what I understood in my RubyCocoa reading was that the user had to
> create all the links to the UI.
>
>> You're wrong about that. RubyCocoa is Cocoa; indeed, you get far
>> *more*
>> events / notifications than you do with AppleScript Studio.
>>
> I think I get that, but to me it looks like another language to learn.
> But as I said in another response I may do it.
>
>> If I were doing what you are doing, though I would just write a
>> native
>> Objective-C Cocoa app with the Ruby script built in, calling the Ruby
>> script thru NSTask at the appropriate moment. You could in fact do
>> the
>> same thing with AppleScript Studio, just as in the example in my book
>> where AppleScript suddenly turns to Perl to do some heavy lifting.
>>
>> m.
> Matt
>
> If I knew Obj-C I'd probably have enough experience to handle Cocoa
> easily. I'm afraid there's too much interaction with the Ruby
> script to
> make the going back and forth to AS worthwhile, but I'll consider it.
> Just to confirm, you're talking about Chap. 23, p.364 "Do shell
> script"?
>
> BTW, it was your article on Ruby that got me to dive into Ruby.
> --
> Posted via http://www.ruby-....
>
Been a while since I messed with Obj-C and Cocoa, but as I remember,
yes, InterfaceBuilder and XCode together can somehow or other
generate a lot of the glue. but I am out the loop on that stuff now.


John Joyce

7/28/2007 11:04:00 PM

0


On Jul 28, 2007, at 5:11 PM, 12 34 wrote:

> John Joyce wrote:
>> On Jul 28, 2007, at 2:19 PM, 12 34 wrote:
>>
>>>> Perhaps easier, and definitely native GUI look, consider Platypus:
>
>>>
>>> I had downloaded Platypus and didn't see anything about selecting
>>> files and folders. But maybe I don't know the terminology.
>>>
>> I hate to say it, but read the docs for it.
>
> OK found it. CocoaDialog. Platypus uses this to create the dialog
> boxes.
> And it can be used directly from Ruby.
> --
> Posted via http://www.ruby-....
>
Cool, let me know how it goes with that! I myself would like to try
using it in the near future.

12 34

7/28/2007 11:41:00 PM

0

John Joyce wrote:
> On Jul 28, 2007, at 5:11 PM, 12 34 wrote:
>
>>
>> OK found it. CocoaDialog.
>> And it can be used directly from Ruby.
>> --
>> Posted via http://www.ruby-....
>>
> Cool, let me know how it goes with that! I myself would like to try
> using it in the near future.

http://cocoadialog.source...

The download is one file, a Mac application which I put in my Utilities
folder

Here's a cleaned up testing script I put together from the Perl examples
(TextMate just crashed on me and now won't run scripts, so I hope this
script is all good. I was doing some final polishing before posting.):

#!/usr/bin/env ruby
# The Perl script seemed to have a path to the file, but
# Ruby / OS X seems to have found it without any help.

response = `CocoaDialog yesno-msgbox --title "Delete backups--test 1"
--text "Delete all the backups?" --informative-text "This cannot be
un-done"`
puts "Delete backups--test 1"
puts response

response2 =`CocoaDialog inputbox --title "Search--Test 2" --no-newline
--informative-text "Enter your search term" --text "foobar" --button1
"Search" --button2 "Search all" --width 600`
puts "Search--Test 2"
puts response2
puts

searchText = "foobar"
resp=`CocoaDialog inputbox --title "Search--Test 3" --no-newline
--informative-text "Enter your search term" --text #{searchText}
--button1 "Search" --button2 "Search all" --width 600`
response4 = resp.split
puts "Search--Test 3"
if response4[0]=="1"
puts " You asked to search for #{response4[1]}"
elsif response4[0]=="2"
puts " You asked to search ALL for #{response4[1]}."
else
puts "response4[0]: #{response4[0]}, but not working like it should.
"
end
--
Posted via http://www.ruby-....