Search code examples
macosuser-interfaceshoes

simple Mavericks GUI


I need some help with a simple GUI in mavericks. Right now I am trying to do it in shoes, but I am open to something else. My basic needs are a GUI with a background image, 3 graphic buttons with text under them. I need 1 of the buttons to reboot the computer, and the other 2 will copy a file from one location and paste it in another directory. It also needs to over write the existing file with no confirmation, or delete it before it pastes the copied one.

In shoes I have the background set, and 2 graphic buttons, but don't know how to make it copy and paste a file when clicked. Thank for the help.

Here is my code, I know it is very ugly but I am still learning it and once I get it to work I was going to start cleaning it up...

Shoes.app(title: "OS Boost Selector", width: 650, heigth: 400 ) do    
background "background.png"
flow left: 100, top: 100 do
button= image "device_ntfs.png" do
FileUtils.cp_r ‘/Volumes/Mavericks/Extra/Windows 7/org.chameleon.Boot.plist', ‘/Volumes/Mavericks/Extra/org.chameleon.Boot.plist', :remove_destination => true 
end
end
stack left: 110, top: 265 do
para "Windows 7", font: "Trebuchet MS", size: 20, stroke: white
end

flow left: 400, top: 100 do
button= image "device_hfsplus_mav.png" do
FileUtils.cp_r ‘/Volumes/Mavericks/Extra/Mavericks/org.chameleon.Boot.plist', ‘/Volumes/Mavericks/Extra/org.chameleon.Boot.plist', :remove_destination => true
end
end
flow left: -100, top: 250 do
buttom= image "logo.png" do
#system(“sudo shutdown -r now”)
end
end
stack left: 295, top: 450 do
para "(Reboot)", font: "Trebuchet MS", size: 16, stroke: white
end
stack left: 415, top: 265 do
para "Mavericks", font: "Trebuchet MS", size: 20, stroke: white
end
end

Solution

  • FileUtils.cp_r("/Volumes/Mavericks/Extra/Windows 7/org.chameleon.Boot.plist", "/Volumes/Mavericks/Extra/org.chameleon.Boot.plist", :remove_destination => true)

    That is what I needed for the copy and overwrite the file.

    This is what I did to get the mac to reboot `open -a reboot'

    when I press the reboot button in my gui it opens reboot app in applications which is an app saved from automator that runs the following applescript:

    ignoring application responses tell application "Finder" restart end tell end ignoring

    This works exactly now like I was wanting. thanks for all the help and patience!