Anda di halaman 1dari 11

TUTORIAL RUBY DENGAN GUI SHOES

Oleh :SLAMET NURHADI

TEKNIK INFORMATIKA
UNIVERSITAS NASIONAL
1. membuat tulisan
Shoes.app :height => 300, :width => 300 do
para "What do you",
em(" want "),
strong("to build"),
code("today?")
end

Shoes.app :title =>"Resizable Sample", :resizable => false,


:width => 400, :height => 70 do

@text = para "blue with an underline"


@text.stroke = blue
@text.underline = "single"
End
Shoes.app do
stack :margin => 10 do
@edit = edit_box :width => 1.0 do
@para.text = @edit.text
end
@para = para " "
end
end

1.a Mencoba dengan Alert

alert "Documents Not Match"

name = ask("Please, enter your name")


Coba dengan kode dibawah ini maka akan tampil seperti dibawah ini

Shoes.app :width => 300, :height => 70 do


@a=para " Who Am I ?"

button "Click here" do


@a.text = ask("Please, enter your name")

end
end

2.Stack dan Flow

Shoes.app :width => 300, :height => 70 do

flow:width => 300 do


stack :width => 100 do
background black
para "black", :stroke =>white, :margin => 25
end

stack :width => 100 do


background yellow
para "yellow", :margin =>25
end
stack :width => 100 do
background red
para "red", :margin =>25
end
end
end

Shoes.app :width => 400, :height => 70 do

flow:width => 400 do

stack :width => 100 do


background black
para "black", :stroke =>white, :margin => 25
end

stack :width => 100 do


background yellow
para "yellow", :margin =>25
end

stack :width => 100 do


background red
para "red", :stroke =>white, :margin =>25
end

stack :width => 100 do


background maroon
para "maroon", :stroke =>white, :margin =>25
end
end
end
Shoes.app :title => "Background Hitam ", :width =>300, :height =>
70 do
background black
end

Cara 1 Mengubah Background


Shoes.app :title => "Background ", :width =>300, :height => 70 do

button "Change a color" do


background backcolor= ask_color("Pick a background")
end
end
Cara 2 mengubah background

backcolor= ask_color("Pick a background")


Shoes.app do
background backcolor
end
3.InputBox

Shoes.app :width =>300, :height => 70 do

@in = edit_line :width => 250


button "What did I type again?" do
alert @in.text
end
end

4.Form
Shoes.app :width => 320, :height =>350 do

stack :margin => 40 do


stack :margin => 10 do
para "Name"
@name = list_box :items => ["yes,please!", "No, No thankyou."]
end
stack :margin => 10 do
para "Address"
@address = edit_line
end
stack :margin => 10 do
para "Phone"
@phone = edit_line
end
stack :margin => 10 do
button "View" do
alert [@name.text, @address.text, @phone.text]
end
end
end
end
5.Window

Shoes.app :title => "Fakultas Teknologi Komunikasi dan


Informatika" do
para "First Form "
button "Spawm" do
window :title => "Field of Department" do
para "Teknik Informatika\n"
para "Sistem Informasi\n"
para "Telekomunikasi\n"
para "Manajemen Informatika\n"
end
end
end
Perhatian:bilamana ada kesulitan dalam mempelajari Ruby, anda
dapat kontak ke slametnhd@gmail.com

tutorial diatas menggunakan Shoes codename “policeman”.


Shoes dapat berjalan di Windows, Mac OS X atau Linux.

Anda mungkin juga menyukai