Program that uses Mac status bar - macos

I'm looking to make a program that would have an icon and drop-down menu on the status bar. Are there any resources on how to do this? I'd prefer building it in Ruby, but I also wouldn't mind doing it in Python, C++ or Bash (if possible).

Take a look at MacRuby, RubyMotion, or PyObjC.
For programming in Ruby, MacRuby is the open source version and precursor to RubyMotion (which recently added support for Mac development).
For programming in Python, take a look at PyObjC. PyObjC is a wrapper while MacRuby and RubyMotion are built directly on top of the objective-c runtime, so they will be more performant than PyObjC.

Have you looked at MacRuby => http://macruby.org? Maybe something like this would do what you want: https://gist.github.com/245402/f4a7bc1c7b32bd3975d0203f22cd7a920af2fe56

This may have appeared only in the time since the previous answers: As a Python option, have a look at Jared Suttles's rumps; the name signifies "Ridiculously Uncomplicated Mac os x Python Statusbar."

Related

Ruby GUI support on OSX Mavericks (Not Shoes or Ruby Motion) plus OSX app package support

This has been asked many times. Some of the answers are pretty old now. I have looked around everywhere for 2 things.This the last resort before I give up. Looking for:
Bindings that will enable GUI programming using Ruby (not Shoes) using Mavericks. I have found plenty bindings but with no activity for the past 3 or 4 years, with the exception of RubyMotion which seems very expensive while not taking advantage of Xcode features / does not have an IDE.
Way to package app for users as a regular OSX app so the user does not have to install anything by hand on OSX (if mutiplatform even better to target Windows too)
I have fallen in love with Ruby but without a means to tackle the above will be difficult to deploy for users, while I am not interested in Rails.
Feels like Rails popularity has in effect killed Ruby by putting it into a niche when it could be so much more.
Any new news on either of these 2 fronts or everything is abandoned / dead ?
Should I move on with Python / Objective-C ? (Which I like both but enjoy Ruby more)
I succesfully compiled scripts with tk, green shoes and gosu as a GUI to an executable with ocra but only have experience doing so on windows. If you want an actual, cross platform GUI try the java swing framework with jruby, here an example.
If you deploy a JAR or an executable nu further installations are needed.
I suppose you use MRI ruby now, the step to jruby is not so difficult.
require 'java'
# With the 'require' above, we can now refer to things that are part of the
# standard Java platform via their full paths.
frame = javax.swing.JFrame.new("Window") # Creating a Java JFrame
label = javax.swing.JLabel.new("Hello")
# We can transparently call Java methods on Java objects, just as if they were defined in Ruby.
frame.getContentPane.add(label) # Invoking the Java method 'getContentPane'.
frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)
frame.pack
frame.setVisible(true)
RubyMotion is the best alternative. But if don't want to spend the money you should be able to use macruby.
Here are some resources
http://blog.phusion.nl/2010/03/12/creating-our-very-first-mac-application-with-ruby-how-exciting/
I must say that using macruby for a big project might not be a good idea. You should expect stuff breaking and few support. As of 2015, the [MacRuby page on GitHub][3] says that the project is in an indefinite hiatus due to the changes made by Apple in the Objective C garbage collection support that MacRuby depends on. They suggest using RubyMotion.
RubyMotion seems to be really good for what you want but for development the lack of a IDE is really a huge downside. Also from my experience rubymotion only comes handy if you already know the cocoa framework really well.
So my recommendation is for you to test rubymotion if you can. They give your money back in the first 30 days if you only want to try it out. So if you have the money give it a try.
If you are new to osx development and only want to develop for osx I think you should go with objective-c. The language is not that bad and you will get the best development environment available for it for free.

Smalltalk with GUI on Mac OS X Lion (10.7)

I need some smalltalk with GUI for my homework, and I'm running Mac OS X Lion (10.7).
I've seen that unix users usually use GNU Smalltalk and GTK+.
I've tried to install them from different versions of sources and all of them give some errors.
Then I've used MacPorts, but that installation breaks GTK+ bindings for gst.
Finally I've tried to install it using fing package manager (because GNU states that I should install everything nice) but there is no smalltalk package for 10.7 OS (though there is for previous ones).
Is there some way to use smalltalk under Mac OS Lion, or should I for example run Ubuntu on virtual machine?
You could also try Pharo, which is a fork of Squeak.
http://www.pharo-project.org/home
Uko,
Have you looked at Squeak? Its an open source version of Smalltalk which is really fun to use and is supported on most platforms.
See:
http://squeak.org/
You will need a specific SqueakVM for the Mac:
http://www.squeakvm.org/mac/
Let me know if you have any further questions...
Squeak or Pharo are real Smalltalks (unlike GNU). This means they have a Smalltalk specific IDE. IDEs were invented by the creators of Smalltalk, so whatever you think you know about IDEs, you probably don't.
My video series, Squeak from the very start, shows how to download the latest Squeak Smalltalk and get started with it. Pharo isn't any harder to install either.
http://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all
You can also give the Personal Use version of VisualWorks a spin:
http://www.cincomsmalltalk.com/main/developer-community/trying-cincom-smalltalk/try-cincom-smalltalk/
I'm assuming you'll get a 7.8(.1?) version there. The OSX skin is pretty dated. I promise it's getting better. Look for 7.9 soon now.

MacRuby: How to write an app/script that generates native Mac apps?

So I'm basically trying to recreate what this app: Fluid, already does. I want to write a Ruby script, or MacRuby app that accepts a few parameters and can generate a simple native app.
Since their code is not open-sourced, I can't see how they do it. And I don't know how I would begin to accomplish something like this.
Also, I would like this script to be run on Windows (not that the user could install the generated app, but so the app could be distributed to Mac users).
How could I do something like this?
Solution:
Here is a project that does exactly the same thing that I'm trying to do. It takes an app bundle and does some string replacing on some files in the bundle. I'm going to use it as an example to imitate.
https://github.com/maccman/macgap-rb
MacRuby can already create native app bundles on OS X (it's a compiler as well as an interpreter), so in a sense there's no question to be answered here. If you want to write an app in MacRuby or Objective-C for OS X, the experience is essentially the same (though, of course, MacRuby has different command line flags for generating the final result, in this case the -deploy flag to MacRuby vs some linker invocation for ObjC). That said, nothing you write in MacRuby will run natively in Windows. Depending on the complexity of the app you have in mind, you may have to go to some cross-platform solution (like Unity) for that.
Check out Prism. It's not Ruby, but it does exactly what you describe and is open-source. One thing you'll to do is embed a web browser into a window, so look for libraries that do that. I'm assuming you'll use Cocoa for GUI since you're using MacRuby. In the end, the simplest way would be just have a window with web browser in it.

What graphical toolkits exist with "good" Ruby bindings?

I want to create a tool with Ruby which works with all 3 of the major OSes (Windows, Linux, Mac OS X). What choices do I have for toolkits where the bindings for Ruby is "good"? By good I mean not just quick direct mapping of the C/C++ API onto Ruby, for instance using blocks where appropriate and other Ruby features.
I would say QTRuby (so bindings for QT) seem to be the most advanced and also quite cross platform without requiring some pre-installed virtual machine - like in the case of Ruby (JRuby Java Swing Bridge - another very good solution if the user already has Swing know-how)
Until recently, pretty much the best options were Swing and SWT. And you know that there is something seriously wrong if Swing is your best option. But now, there's also WPF.
All three, Swing, SWT and WPF work great on Windows, OSX, Linux and probably a dozen others.
For OS X I would say MacRuby - http://www.macruby.org/ because of HotCocoa http://www.macruby.org/hotcocoa.html
By far the most thoroughly supported is Tk (Ruby/Tk: http://ruby-doc.org/docs/ProgrammingRuby/html/ext_tk.html), and it'll run on just about anything. Down side is, it isn't very pretty.
Here's another good guide for using Ruby/Tk: _http://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
If you're looking for something a little nicer looking, try gtk(2): _http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk

Package Ruby to a standalone Mac OS X application?

I know Python has py2app. I was wondering if Ruby has anything like that. I know there is OCRA (One-Click Ruby Application builder) for Windows, but what about for Mac OS X?
Take a look at Platypus; it may do what you want.
From its homepage:
Platypus is a developer tool for the
Mac OS X operating system. It can be
used to create native, flawlessly
integrated Mac OS X applications from
interpreted scripts such as shell
scripts or Perl and Python programs.
This is done by wrapping the script in
an application bundle directory
structure along with an executable
binary that runs the script.
Edit per #XtraSimplicity in a comment: Platypus can't handle any input or output from stdin or stdout. That will rule it out in some cases.
MacRuby seems like the most likely candidate without knowing more details about what you're doing. It can make standalone native binaries.
http://www.macruby.org/ for more info.
RubyCocoa includes a script (standaloneify.rb) to package all the Ruby files your project uses into the app wrapper, and MacRuby (recommended if you're targeting 10.5+) compiles to native code and thus it's no more work making a standalone app than with Objective-C.
Compared to Windows, Ruby and Python are prebuilt for Mac OS X, so the easiest way might be using Cocoa with Ruby. You can get good information out of the book Programming Cocoa with Ruby.

Resources