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
- Open Xcode
- Select the menu option “Xcode -> Preferences …” or press
Command+,
- Click the “Downloads” tab
- 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.
- Download the MacPorts “pkg” for your OS X version (I tested this while running Mountain Lion) here.
- 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.
- Open a terminal: either
- press
Command+Space
, type “terminal
“, then pressReturn
/Enter
, - or open Launchpad, and find Terminal in the “Other” group or type “
terminal
“, then pressReturn
/Enter
- press
- Enter the following command:
sudo port install wine-devel
- 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 “cd
“) and enter the following command:
wine ztree.exe
This will launch the z-Tree program.
(Optional) Step 6: Setup a shortcut to z-Tree
- Open Automator (open Launchpad, and find Automator in the “Other” group or type “
automator
“, then pressReturn
/Enter
) - Select “Application” and click “Choose”
- Type “
shell
” where your cursor is (in the search field that says “Name”). - Double-click the “Run Shell Script” option.
- 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”.
- Test your application by clicking “Run” (the play button in the top-right corner)
- 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
- Download a 512×512 z-Tree icon here.
- Open “Finder”
- Click “Downloads” on the left (assuming that’s where you saved the file) and double-click the file “ztree.hqx”.
- Click on the newly created “ztree” icon file.
- Press
Command+C
to copy the icon. - Click “Applications” on the left and find “zTree”.
- Control-Click or right-click (or two-finger-click) the “zTree” application
- Select “Get Info”
- Click on the Automator logo near the top (it will get a blue halo) 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
- Open Automator (open Launchpad, and find Automator in the “Other” group or type “
automator
“, then pressReturn
/Enter
) - Select “Application” and click “Choose” as in step 6
- Type “
ask
” where your cursor is (in the search field that says “Name”). - Double-click on “Ask for Text”
- For “Question”, type “
Type a name for this zleaf.
“ - Leave “Default Answer” blank.
- Check “Require an answer”
- Change the text “OK” to “Launch zleaf”
- Type “
shell
” where your cursor is (in the search field that says “ask”). - Double-click the “Run Shell Script” option.
- Change “to stdin” to “as arguments”
- 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”. - Test your application by clicking “Run” (the play button in the top-right corner)
- 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 “cat
“) 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:
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.
Thanks a lot for this great tutorial – this works perfect on Snow Leopard as well!
Jon thank you so much for this post! With a few modifications it worked for my ancient MacBook.
hey its working gr8 on mac but i wanted to know where is the payment file stored or rather the results
To my knowledge the payment file does not get stored. You can look at the
*.xls
and*.sbj
files that gets created in your home directory. You can get to the home directory by typingin Terminal or in Finder by selecting
GO > Go to Folder ...
in the menu and entering~
as the folder to go to.Hope this helps!
hey der thanks a ton, i found the result file
hey how do workout the server issue i want to use my mac book as a server
In order to use your Macbook as a server, you will need to actually run z-Tree in Windows using something like Parallels or Boot Camp. For a general guide on running Windows on a Mac see this Apple support page.
Nice post! I tried using Winebottler to “bottle” the zTree directly, and it went fine! But I’m having a hard time creating different zLeaves to test my treatments. Any thoughts on how to do this, within WineBottler?
@Diogo: Unfortunately I haven’t worked with WineBottler. I believe you can create a zleaf.app out of zleaf.exe. You should then be able to create an automator similar to the one in the tutorial.
Hi Diego, I have also used Winebottler to get zTree running and am having the same problem with creating different zLeaves at a time. Did you figure out how to fix this? I get an error every time I try to create an automator.
Works really well!
Two questions that would help streamline the process that I can’t seem to figure out.
1. Is there a way to change the default drop for the data?
2. Is there a way to close out of the zLeaf program without a Force Quit? Can’t get it to shut down otherwise…
@Erich: I’m glad the tutorial worked for you! The answer to your questions are “I don’t thinks so.”
Thanks a lot Jonathan! I got everything to work except for “Automate the launching of multiple zleafs.” I do everything as you say, but Automator says “Workflow completed” after only 2 seconds, and nothing happened. “Automate zleaf” worked fine, but I cannot not run it multiple times in order to get multiple zIeafs. I have Snow Leopard. Any ideas how I could fix this?
@Sanne: I’m not sure. I would first check to make sure the shell script reads:
If the zLeaf Automator worked for you, I don’t know why the zLeafs Automator would not. If you post a screenshot of your Automator screen I can help to debug further (make sure not to include any private data).
The screen shot does not seem to work, can I send it to you via email?
@Sanne: Can you upload the screen shot to an image hosting site (like http://tinypic.com/)? After that, add a comment with a link to the image.
@Jonathan: Thanks for the advice. Here is the screenshot: [IMG]http://i44.tinypic.com/10s5579.png[/IMG]
Hi Jonathan,
I double checked it, but cannot find the problem. Here is the screen shot:
Thanks for your help!
Sanne
Hi
This is really helpful thanks for posting it. I have got stuck at level 6 though (I’m really useless at this sort of thing). How do I specify the path to ZTree (my ztree.exe file is in a folder Called “ZTree” that is in “Documents”).
Sorry for the very easy question! nichola
Should be something like “/Users//Documents/ZTree/ztree.exe”.
Right click on the ztree.exe file and go to “Get Info” to verify this.
Good luck!
Sorry, lost the “”.
Like this: “/Users/’your_user_name’/Documents/ZTree/ztree.exe”
Thanks for the help 🙂
I am still encountering errors unfortunately. Specifically, when I enter the code like you said:
/opt/local/bin/wine “/Users/nichola/Documents/ZTree/z.tree.exe”
I get an error message saying :
To test this application within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow. Remove or disable the action before running the workflow outside of Automator.
I tried doing that but still getting a generic error message as follows:
The action “Run Shell Script” encountered an error. Check the actionʼs properties and try running the workflow again.
Any ideas why this might be?? I am using the /bin/bash option for the Shell and it passes input to stdin.
Do I need to get the specified finder items like Automator says to before I run the script? Or is that unnecessary?
Thanks for any help you might be able to provide.
Nichola
By the way, not sure if this makes a difference but I am using Mavericks OS.
The /Users/nichola/Documents/ZTree/z.tree.exe should not be in quotes. Does that help?
YES!! thanks so much 🙂 (sorry I was so hopeless at this but hopefully the thread will help other hopeless people like me)
Glad to help. Best of luck!
Hey Erich
A new problem! Did you ever figure out how to get the zleafs to work? I think I have the same issue as you – it works fine in Automator but then doesn’t work from the Applications folder – i.e. I click on the icon and nothing happens. Zleaf (the single one) works fine though.
thanks! nichola
Actually, in order to run multiple Zleafs I use a program that a colleague of mine made. The link is on this page: http://john.jensenius.com/programming.html
Just download the file under “Launch z-Leafs with GUI (executable).” Move that file to the Zleaf and ZTree directory. Then set up like Jonathan showed for part 6. But you will use /Users/nichola/Documents/ZTree/LaunchZleafsWin.exe instead of /Users/nichola/Documents/ZTree/z.tree.exe
Then, after you have ZTree open, you can open multiple ZLeaf windows. The first time you run the LaunchZleafsWin.exe you will need to specify where the Zleaf.exe file is.
Hope that works.
Best,
Erich
Hi again
Thanks for this advice. I installed the Z-leafs with GUI like you said – seemed to work fine but again when I click it (when zTree is open) nothing happens.
How do I specify where the Zleaf.exe file is? Maybe that’s the problem? thanks nichola
I should say – it does ask me how many zleafs want to open but then after i specify a number nothing happens.
Thanks for your patience.
Glad to help.
On the screen where it asks about the zleafs, there should be a button in the lower left corner: “View or Change All Settings” Click on it. In the box for Z-Leaf path, you should put C:\Users\nichola\Documents\ZTree\zleaf.exe
That work?
Hello again!
Do you mean the pop-up screen that says ‘How many zleafs do you want to open’? I literally just get a pop up box asking that question with two options: cancel or launch zleafs. No button in lower left hand corner.
I’m sorry. It has been a while since I opened it the first time, but I think the initial setup screen is accessible somewhere. Possibly after hitting “Cancel” or in the File drop down menu.
Cool thanks – I will figure it out!
Hi!
Thanks for this useful post. While following the steps I faced a problem. In Step 4: Install Wine when I type “sudo port install wine-devel” in terminal I get an “Error: Port wine-devel not found”.
I did not download anything from wine webpage as the tutorial did not suggested it. Also I did not find any “Command Line Tools” in download tab when I installed xCode. I use OS X Mavericks.
Thanks for your help!
Homa
Hi Homa! Did you find solution to your problem? I have the same thing, but I am not sure which wine to download. (BTW: are you friends with Hillary?)
Hi Kristian! Sorry for such a late reply, I just got an notification for some other comments and saw yours. I did not find any solutions and I asked my boss for a windows laptop! Which Hillary? Clinton? Haha no I live in Berlin and no Hillary yet 🙂
Cool thank you I used it to run it on wine within ubuntu 12.04 too
always show wine command not found
I’m having problems using Multimedia Box and I’m wondering if it is related to my use of wine. I am inserting the correct link to the file name, but when I run the program no image is showing up. Could this be due to my use of wine to run z-Tree?
Thanks so much for this tutorial. How should I default the language to be English after this setup? I cannot create a shortcut as in the regular setup tutorials. Thanks so much?
In step 6.5, add “/language en” after “…/zleaf.exe”. Can also use this option for the zleaf files.
Thank you for this! I ended up using the homebrew installer because I kept getting error messages in the terminal install of wine. Combining the general instructions at http://www.davidbaumgold.com/tutorials/wine-mac/#will-it-work and the specifi z-tree info here, I was able to get everything to work. If only there was an easier way to close the z-leafs.
Excuse me for the very simple question, but how can I close the zleaf? I have created a leaf as explained with the automator. However, when I try to close Wine nothing happens for the zleaf and I end up closing it using “Force Quit”. Is there a way to do the alt+f4 in mac to close the zleaf? Thank you so much for your help.
Does running z-tree via Wine on 10.10.4 yield the full functionality? I.e. the same functionality as running z-tree on a Windows machine? If not, does it work better over Parallels? Thanks
Thanks – this worked perfectly! However, do I get exactly the same functionality as when running z-tree with a conventional Windows PC? If not, what issues should I expect?
I have a problem about installing wine. When I try this it started with computing dependencies and then ended with a fail. Could anyone help me about that?
Hi, I have problem when proceeding in Step 5, it says, “could not get window handle”……Could you please help, I am using the EI Capitan. Thank you!