wxMac/wxHaskell focus problem, a quick solution

I was trying to go through some of the wxHaskell examples, and they wouldn't work on my (Tiger) mac. Same thing happened with a few other wx apps I downloaded from Hackage. A bit of a rummage on the internet turned up an issue with wxMac[1]. You need to put the haskell executable in an OSX Application Bundle or you can't get focus on the window. Since I don't know how to use XCode (and quickly got bored of trying to find what I needed to do with it for my needs) I setup an applescript that builds a bare bones app bundle, with a basic plist file too. This is probably something others have gone though and, just in case it might be some use to others, I stuck it here (might be a little bit of overkill using Sourceforge, but I wasn't go to pay for the download space on my blog considering I have zero cash right now). http://sourceforge.net/projects/makebundle/ The applescript has a perl script in it too, so you'll need perl on your machine for it to work. Everything you need to know is in the readme. Iain [1] http://wiki.wxwidgets.org/WxMac_Issues#My_app_can. 27t_be_brought_to_the_front.21

Isn't that what macosx-app is for? Iain Barnett wrote:
I was trying to go through some of the wxHaskell examples, and they wouldn't work on my (Tiger) mac. Same thing happened with a few other wx apps I downloaded from Hackage. A bit of a rummage on the internet turned up an issue with wxMac[1]. You need to put the haskell executable in an OSX Application Bundle or you can't get focus on the window.
Since I don't know how to use XCode (and quickly got bored of trying to find what I needed to do with it for my needs) I setup an applescript that builds a bare bones app bundle, with a basic plist file too.
This is probably something others have gone though and, just in case it might be some use to others, I stuck it here (might be a little bit of overkill using Sourceforge, but I wasn't go to pay for the download space on my blog considering I have zero cash right now).
http://sourceforge.net/projects/makebundle/
The applescript has a perl script in it too, so you'll need perl on your machine for it to work. Everything you need to know is in the readme.
Iain
[1] http://wiki.wxwidgets.org/WxMac_Issues#My_app_can.27t_be_brought_to_the_fron...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 29 Oct 2009, at 15:41, Gregory Crosswhite wrote:
You don't have to turn a program into an application in order to make the GUI work
This is true, but I don't think it's better to import extra code where simple packaging (folders and a plist), which is actually very convenient, can do the job. On 29 Oct 2009, at 15:16, Miguel Mitrofanov wrote:
Isn't that what macosx-app is for?
Maybe, but it's no use if no one knows about it, and I just googled it and found this (and only this). http://darcs.haskell.org/wxhaskell/bin/macosx-app-template It's not in the documentation that came with my download of wxcore either. Hardly a great help to a newbie, like myself - is there any documentation? Is it a bash script or should I just guess and hope? Oh, sorry, I see it's in the unfindable wiki page! ;-) In contrast to both of these methods, my script is easy, quick, and doesn't rely on memory - just go to the OSX Applescript menu! It's less code (it doesn't even touch the code) and less work, just run an applescript and keep everything neat. Add to that, what I've done can be used generally, not just for wxHaskell (or even Haskell). Open up XCode and there are a lot of different types of projects to choose from, and then you have to know how to use the IDE. This is just a quick project set up for anything you want to do that is straightforward. Iain

Isn't that what macosx-app is for?
Maybe, but it's no use if no one knows about it, and I just googled it and found this (and only this).
http://darcs.haskell.org/wxhaskell/bin/macosx-app-template
It's not in the documentation that came with my download of wxcore either. Hardly a great help to a newbie, like myself - is there any documentation? Is it a bash script or should I just guess and hope? Oh, sorry, I see it's in the unfindable wiki page! ;-)
MigMit$ /usr/local/wxhaskell/bin/macosx-app --help
usage:
macosx-app [options]
Add to that, what I've done can be used generally, not just for wxHaskell (or even Haskell).
Seems like the same applies to macosx-app.
Open up XCode and there are a lot of different types of projects to choose from, and then you have to know how to use the IDE. This is just a quick project set up for anything you want to do that is straightforward.
So... Does it mean that you LIKE programming in XCode, even when using Haskell? Wow.

On 29 Oct 2009, at 20:52, Miguel Mitrofanov wrote:
Open up XCode and there are a lot of different types of projects to choose from, and then you have to know how to use the IDE. This is just a quick project set up for anything you want to do that is straightforward.
So... Does it mean that you LIKE programming in XCode, even when using Haskell? Wow.
I don't understand what you mean? What I meant is that I never use XCode, and therefore I don't know which projects to choose or how to use it, and it would take a lot of time to change that.
Seems like it just works. Of course, I agree that it's a bit hard to find, but it's here without installing any third-party scripts.
macosx-app *is* a 3rd party script - it doesn't come with OSX does it? and it's still not as easy to use as an applescript. That's why applescript refuses to die while being the hardest language ever devised to write in. I also think the plist the macosx-app script builds isn't that good.
MigMit$ /usr/local/wxhaskell/bin/macosx-app --help
It's pretty difficult to run the --help arg if you don't know the script even exists. What's wrong with a README that says "If you're having problems running your executable on OSX then you need to use macosx-app in the bin dir..." ?
usage: macosx-app [options]
options: [defaults in brackets] --help | -? show this information --verbose | -v be verbose
help and verbose. That's not helpful at all. Use whichever method suits you best, but I shouldn't have to dick around all day finding badly documented scripts that don't even work as well as the one I had to do for myself, and perhaps others feel the same. Iain

So... Does it mean that you LIKE programming in XCode, even when using Haskell? Wow.
I don't understand what you mean? What I meant is that I never use XCode, and therefore I don't know which projects to choose or how to use it, and it would take a lot of time to change that.
Just wondering, what XCode has to do with all that. I never use it too, which is why I don't even know that there is some project list to choose from.
Seems like it just works. Of course, I agree that it's a bit hard to find, but it's here without installing any third-party scripts.
macosx-app *is* a 3rd party script - it doesn't come with OSX does it?
No, but it comes with wxHaskell.
and it's still not as easy to use as an applescript.
???
MigMit$ /usr/local/wxhaskell/bin/macosx-app --help
It's pretty difficult to run the --help arg if you don't know the script even exists. What's wrong with a README that says "If you're having problems running your executable on OSX then you need to use macosx-app in the bin dir..." ?
http://haskell.org/haskellwiki/WxHaskell/MacOS_X - works for me.
usage: macosx-app [options]
options: [defaults in brackets] --help | -? show this information --verbose | -v be verbose
help and verbose. That's not helpful at all.
On the contrary, it shows that there isn't anything you have to customize. Just run it and enjoy the results.

On Oct 29, 2009, at 1:00 PM, Iain Barnett wrote:
On 29 Oct 2009, at 15:41, Gregory Crosswhite wrote:
You don't have to turn a program into an application in order to make the GUI work
This is true, but I don't think it's better to import extra code where simple packaging (folders and a plist), which is actually very convenient, can do the job.
It depends on what you are doing. I completely concur that in many (and perhaps most) cases your script is ideal, especially when one is packaging a program for distribution. However, although your packaging makes it easier to run the binary from the Finder, it makes it less convenient to run it from the command line, and in cases where for whatever reason you want to easily run it from the command line (which I have run into in practice) the EnableGUI module is very helpful. Cheers, Greg

You don't have to turn a program into an application in order to make the GUI work, you just have to make some calls to enable GUI events to be delivered to your program (or something like that, at least). I've attached a script that I got from somewhere on the internet (can't remember exactly where) that does this, so all you need to do is run "enableGUI" at the beginning of "main", rather than having to do additional packaging to make your program work. Cheers, Greg On Oct 29, 2009, at 7:08 AM, Iain Barnett wrote:
I was trying to go through some of the wxHaskell examples, and they wouldn't work on my (Tiger) mac. Same thing happened with a few other wx apps I downloaded from Hackage. A bit of a rummage on the internet turned up an issue with wxMac[1]. You need to put the haskell executable in an OSX Application Bundle or you can't get focus on the window.
Since I don't know how to use XCode (and quickly got bored of trying to find what I needed to do with it for my needs) I setup an applescript that builds a bare bones app bundle, with a basic plist file too.
This is probably something others have gone though and, just in case it might be some use to others, I stuck it here (might be a little bit of overkill using Sourceforge, but I wasn't go to pay for the download space on my blog considering I have zero cash right now).
http://sourceforge.net/projects/makebundle/
The applescript has a perl script in it too, so you'll need perl on your machine for it to work. Everything you need to know is in the readme.
Iain
[1] http://wiki.wxwidgets.org/WxMac_Issues#My_app_can.27t_be_brought_to_the_fron...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Would someone like to make a Haskell wiki page explaining all this? Very helpful for people using wx for the first time. Maybe there is one already? Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Gregory Crosswhite | Sent: 29 October 2009 15:44 | To: Iain Barnett; Haskell Cafe | Subject: Re: [Haskell-cafe] wxMac/wxHaskell focus problem, a quick solution | | You don't have to turn a program into an application in order to make | the GUI work, you just have to make some calls to enable GUI events to | be delivered to your program (or something like that, at least). I've | attached a script that I got from somewhere on the internet (can't | remember exactly where) that does this, so all you need to do is run | "enableGUI" at the beginning of "main", rather than having to do | additional packaging to make your program work. | | Cheers, | Greg |

Simon Peyton-Jones wrote:
Would someone like to make a Haskell wiki page explaining all this? Very helpful for people using wx for the first time. Maybe there is one already?
The enableGUI thing is mentioned here: http://www.haskell.org/haskellwiki/WxHaskell/MacOS_X Not that easy to find, though. Regards, apfelmus -- http://apfelmus.nfshost.com

Hi Iain, I'm taking the liberty of cc'ing wxhaskell-users. Iain said:
I was trying to go through some of the wxHaskell examples, and they wouldn't work on my (Tiger) mac. Same thing happened with a few other wx apps I downloaded from Hackage. A bit of a rummage on the internet turned up an issue with wxMac[1]. You need to put the haskell executable in an OSX Application Bundle or you can't get focus on the window.
Since I don't know how to use XCode (and quickly got bored of trying to find what I needed to do with it for my needs) I setup an applescript that builds a bare bones app bundle, with a basic plist file too.
Thanks for your efforts!
This is probably something others have gone though and, just in case it might be some use to others, I stuck it here (might be a little bit of overkill using Sourceforge, but I wasn't go to pay for the download space on my blog considering I have zero cash right now).
http://sourceforge.net/projects/makebundle/
The applescript has a perl script in it too, so you'll need perl on your machine for it to work. Everything you need to know is in the readme.
I've also done something similar http://koweycode.blogspot.com/2009/09/cabal-installing-graphical-apps-on.htm... only in Haskell and attempting to integrate into a Cabal Setup script. You may want to know about work by Andy Gimblett to package this up nicely: http://www.mail-archive.com/wxhaskell-users@lists.sourceforge.net/msg00725.h... I hope his work will one day may the macosx-app shell script obsolete. Cheers, -- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9
participants (6)
-
Eric Y. Kow
-
Gregory Crosswhite
-
Heinrich Apfelmus
-
Iain Barnett
-
Miguel Mitrofanov
-
Simon Peyton-Jones