WxHaskell on OS X

I want to use wxHaskell for OS X (Snow Leopard, MacBook Pro). I managed to install the library successfully and the script below:

module Main where import Graphics.UI.WX main :: IO () main = start hello hello :: IO () hello = do f <- frame [text := "Hello!"] quit <- button f [text := "Quit", on command := close f] set f [layout := widget quit] 

causes the window to be displayed with a single button, as indicated. However, nothing happens when I press a button - I don’t even get a visual response from the button, turning blue to indicate that it is pressed (ha ha, no pun intended).

I heard that you need to run a package called "macosx-app" in wxHaskell binaries in order to get them to run, but I cannot find it anywhere. This is not on my machine or (as far as I can tell) on WX or wxHaskell distributions.

Does anyone know what I need to do to make this work?

+4
source share
2 answers

The original version contains a file called macosx-app-template in the bin . This file is used by the following part of the configure script to create macosx-app :

 cat > config/macosx-app-temp << EOF #!/bin/sh rezcomp="$wxinstallrezcomp" rezfile="$wxinstallrezfile" EOF cat config/macosx-app-temp bin/macosx-app-template > config/macosx-app rm -f config/macosx-app-temp chmod a+x config/macosx-app 

If you have already installed wxHaskell and are not using the configure script, you can simply duplicate these steps, that is, copy macosx-app-template to macosx-app , make it executable and add the following lines at the top:

 #!/bin/sh libdir="" wxrezcomp="`wx-config --rezflags`" wxrezfile="" if test "$wxrezcomp"; then for word in $wxrezcomp; do temp="`echo $word | grep '[^_]*_mac-[^r]*r'`" if test "$temp"; then wxrezfile="$temp" fi done fi if test "$wxrezfile"; then wxrezdir="`echo $wxrezfile | sed -e 's|\(.*\)/libwx_mac.*|\1|'`" wxinstallrezcomp="`echo \"${wxrezcomp}\" | sed -e \"s|${wxrezdir}|${libdir}|g\"`" wxinstallrezfile="`echo \"${wxrezfile}\" | sed -e \"s|${wxrezdir}|${libdir}|g\"`" fi rezcomp="$wxinstallrezcomp" rezfile="$wxinstallrezfile" 

Note that you need to change libdir="" to indicate the directory where the wxHaskell library files are installed, and if wx-config not in your path, you will also need to change this line.

+2
source

I installed wxhaskell using cabal and read other explanations that I do as follows to work with macosx-app:

  • I download wxhaskell sources from http://haskell.org/haskellwiki/WxHaskell/Download

  • I will unzip the downloaded file:

    wxhaskell-src-XXX.zip

    where XXX is the version number.

  • I run configure in the unpacked directory. This creates the config / macosx-app file from the template.

    .configure

  • I copy the sudo file to the bin / usr / local / bin directory

    sudo cp config / macosx-app / usr / local / bin

  • I delete directories with source files

It works for me!

0
source

Source: https://habr.com/ru/post/1312655/


All Articles