I have a strange problem using shoes. I have attached a screenshot of a very simple GUI I am building for a Ruby Script that I hope to use to assist me in learning the Russian language. However I am having a strange problem with Cyrillic characters. It seems that when I try to set the text of an edit_line I just get a question mark. Here is my complete code.
class Verb
attr_accessor :infinitive,:present_first_sing,:present_second_sing,:present_third_sing,:present_first_plu,:present_second_plu,:present_third_plu
def initialize(verb_infinitive)
@infinitive = verb_infinitive
case @infinitive
when "думать"
@present_first_sing,@present_second_sing,@present_third_sing,@present_first_plu,@present_second_plu,@present_third_plu = "думаю","думаешь","думает","думаем","думаете","думают"
#puts "Added Dymat"
when "смотреть"
@present_first_sing,@present_second_sing,@present_third_sing,@present_first_plu,@present_second_plu,@present_third_plu = "смотрю","смотришь","смотрит","смотрим","смотрите","смотрят"
#puts "Added Smatret"
else
puts "Dunno what to do with that dude"
end
end
def get_available_conjugations
answers = Hash.new
answers["1st-sg-pres"] = @present_first_sing
answers["2nd-sg-pres"] = @present_second_sing
answers["3rd-sg-pres"] = @present_third_sing
answers["1st-pl-pres"] = @present_first_plu
answers["2nd-pl-pres"] = @present_second_plu
answers["3rd-pl-pres"] = @present_third_plu
return answers;
end
def to_s
return @infinitive
end
end
This is my very simple verb class. Nothing Special here. My UI script is below
require "verb"
verb1 = Verb.new("думать")
verb2 = Verb.new("смотреть")
quizVerbs = Hash.new
quizVerbs[verb1.infinitive]=verb1
quizVerbs[verb2.infinitive]=verb2
qa_hash = Hash.new
Shoes.app :width => 600, :height=> 200 do
stack do
@flow1 = flow do
para "Subject Verb: "
@verb_list = list_box :items => quizVerbs.keys
@verb_list.change do |vl|
@current_verb = vl.text
@p1.text = @current_conjugation
end
end
@flow2 = flow do
@p1 = para "#{@current_conjugation}"
@user_input_box = edit_line :width => 400
@user_input_box.text = "й"
@rwpara = para "Nothing answered yet"
end
@flow3 = flow do
button("Next") do
@rwpara.text = ""
@user_input_box.text.each_codepoint {|c| @rwpara.text= @rwpara.text+c}
end
end
@flow4 = flow do
button("й") {
@user_input_box.text = "й"
alert("й")
}
button("ц") {
@user_input_box.text = "ц"
alert("ц")
}
button("у") { alert("Good job.") }
button("к") { alert("Good job.") }
button("е") { alert("Good job.") }
button("н") { alert("Good job.") }
button("г") { alert("Good job.") }
button("ш") { alert("Good job.") }
button("щ") { alert("Good job.") }
button("з") { alert("Good job.") }
button("х") { alert("Good job.") }
button("ъ") { alert("Good job.") }
end
@flow5 = flow do
button("ф") { alert("Good job.") }
button("ы") { alert("Good job.") }
button("в") { alert("Good job.") }
button("а") { alert("Good job.") }
button("п") { alert("Good job.") }
button("р") { alert("Good job.") }
button("о") { alert("Good job.") }
button("л") { alert("Good job.") }
button("д") { alert("Good job.") }
button("ж") { alert("Good job.") }
button("э") { alert("Good job.") }
button("ё") { alert("Good job.") }
end
@flow6 = flow do
button("я") { alert("Good job.") }
button("ч") { alert("Good job.") }
button("с") { alert("Good job.") }
button("м") { alert("Good job.") }
button("и") { alert("Good job.") }
button("т") { alert("Good job.") }
button("ь") { alert("Good job.") }
button("б") { alert("Good job.") }
button("ю") { alert("Good job.") }
end
end
end
If I click on the button with character й I can see the character in the alert box is correctly displayed. However I assign the value to the text of the edit line in the code
button("й") {
@user_input_box.text = "й"
alert("й")
}
However if you look at the gui again you can see that I am only getting a question mark to display. This is driving me nuts. What am I overlooking here?