HomeContact
Archive
Run z-Tree on a Mac: OSX, MacPorts, and Wine
Jon Page
May 08, 2013
3 min

Table Of Contents

01
Preparation
02
Step 1: Install Xcode
03
Step 2: Install Command Line Tools
04
Step 3: Install MacPorts
05
Step 4: Install Wine
06
Step 5: Run z-Tree
07
(Optional) Step 6: Setup a shortcut to z-Tree
08
(Optional) Step 7: Start zleafs for testing
09
Concluding Remarks

As the late, great Agatha Christie wrote:

I don’t think necessity is the mother of invention — invention, in my opinion, arises directly from idleness, possibly also from laziness. To save oneself trouble.

As I was working on my MacBook Pro, adjacent to a less attractive (and currently off) PC, I decided to run z-Tree. As purveyors of fine (or bland) economic experiments will know, z-Tree is currently Windows only. As I am too lazy and disinterested in my PC to fire it up and run z-Tree on it, I decided to get it running on my Mac and share with you how easy it actually is.

Preparation

We will be installing Xcode, Command Line Tools, MacPorts, and Wine. So, if you have any of these installed feel free to skip the relevant sections. This tutorial assumes you have a copy of ztree.exe and zleaf.exe. If you do not have these files, you will need to request them via snail-mail using the license contract here or find a friend with a copy.

Step 1: Install Xcode

Download and install Xcode from the App Store [EDIT: If you are on OS X 10.6, follow the instructions for Snow Leopard here]

Step 2: Install Command Line Tools

Command Line Tools
Command Line Tools
Click “Install” to install the Command Line Tools

  1. Open Xcode
  2. Select the menu option “Xcode -> Preferences …” or press Command+,
  3. Click the “Downloads” tab
  4. Under “Components” click on “Install” on the line for “Command Line Tools”

Step 3: Install MacPorts

Using MacPorts makes it a snap to download and install open-source software on OS X.

  1. Download the MacPorts “pkg” for your OS X version (I tested this while running Mountain Lion) here.
  2. After downloading the MacPorts “pkg”, install MacPorts with the default settings.

Step 4: Install Wine

Wine allows you to run Windows applications within OS X (and Linux) without requiring a copy of Microsoft Window.

  1. Open a terminal: either
    • press Command+Space, type ”terminal”, then press Return/Enter,
    • or open Launchpad, and find Terminal in the “Other” group or type ”terminal”, then press Return/Enter
  2. Enter the following command:
sudo port install wine-devel
  1. Enter your password and wait. This will take a while.

Step 5: Run z-Tree

Open a terminal, navigate to the folder containing “z-tree.exe” (i.e., use) and enter the following command:

wine ztree.exe

This will launch the z-Tree program.

(Optional) Step 6: Setup a shortcut to z-Tree

  1. Open Automator (open Launchpad, and find Automator in the “Other” group or type ”automator”, then press Return/Enter)
  2. Select “Application” and click “Choose”
    Select Application
    Select Application
    Select Application
  3. Type ”shell” where your cursor is (in the search field that says).
  4. Double-click the “Run Shell Script” option.
    Select "Run Shell Script"
    Select "Run Shell Script"
    Select “Run Shell Script”
  5. Replace “cat” with
    /opt/local/bin/wine /path/to/ztree/ztree.exe
    
    Be sure to change “/path/to/ztree/” with the actual path to your copy of “ztree.exe”.
  6. Test your application by clicking “Run” (the play button in the top-right corner)
  7. If it works as expected, save your application as “zTree” in the Applications folder.

zTree can now be launched just as you would any other application.

(Optional) Add z-Tree icon to Automator Application

  1. Download a 512x512 z-Tree icon here.
  2. Open “Finder”
  3. Click “Downloads” on the left (assuming that’s where you saved the file) and double-click the file “ztree.hqx”.
  4. Click on the newly created “ztree” icon file.
  5. Press Command+C to copy the icon.
  6. Click “Applications” on the left and find “zTree”.
  7. Control-Click or right-click (or two-finger-click) the “zTree” application
  8. Select “Get Info”
  9. Click on the Automator logo near the top (it will get a blue halo)

Click the icon near the top-left.
Click the icon near the top-left.

and press Command+V to paste the icon.

Congratulations! Now you have zTree running in Mac and it looks native!

(Optional) Step 7: Start zleafs for testing

To run a zleaf for testing purposes enter the following command into a terminal while in the directory containing zleaf.exe:

wine zleaf.exe /name test1

where ”test1” is the name you assign to the zleaf. You can then create another zleaf by changing ”test1” to ”test2” in order to test a 2-subject experiment.

(Optional) Automate zleaf

  1. Open Automator (open Launchpad, and find Automator in the “Other” group or type ”automator”, then press Return/Enter)
  2. Select “Application” and click “Choose” as in step 6
  3. Type ”ask” where your cursor is (in the search field that says).
  4. Double-click on “Ask for Text”
  5. For “Question”, type ”Type a name for this zleaf.
  6. Leave “Default Answer” blank.
  7. Check “Require an answer”
  8. Change the text “OK” to “Launch zleaf”
  9. Type ”shell” where your cursor is (in the search field that says).
  10. Double-click the “Run Shell Script” option.
  11. Change “to stdin” to “as arguments”
  12. Replace ”cat” with
    /opt/local/bin/wine /path/to/ztree/zleaf.exe "$@"
    
    Be sure to change ”/path/to/ztree/” with the actual path to your copy of “zleaf.exe”.
    Your Automator should look like this.
    Your Automator should look like this.
    Your Automator should look like this.
  13. Test your application by clicking “Run” (the play button in the top-right corner)
  14. If it works as expected, save your application as “zLeaf” in the Applications folder.

(Optional) Automate the launching of multiple zleafs

For an application that launches multiple zLeafs at once, replace the above shell command (the section that used to say) with the following:

for i in $(seq 1 $@) do /opt/local/bin/wine /path/to/ztree/zleaf.exe /name "Player $i" & done

Again, remember to replace ”/path/to/ztree/” with the actual path to your copy of “zleaf.exe”. You should also change the prompt in the “Ask for Text” section to something like ”How many zLeafs would you like to run?”. I also changed the “Default Answer” to ”1”. Save this application as “zLeafs”.

(Optional) Add z-Leaf and z-Leafs icons

To change the icons follow the instructions above and use the following icons:

  • 512x512 z-Leaf icon here.
  • 512x512 z-Leafs icon here.

Concluding Remarks

I hope my efforts will help some of you. Please let me know if you have any questions or problems related to this tutorial in the comments section below.


Tags

#macports#wine#ztree

Related Posts

Creating Your First PDF with LaTeX and Atom
February 27, 2016
2 min
© 2022, All Rights Reserved.

Quick Links

About UsContact Us

Social Media