我有一个使用鞋子的奇怪问题。我附上了一个非常简单的GUI的截图,我正在为Ruby脚本构建,我希望用它来帮助我学习俄语。但是我对西里尔字符有一个奇怪的问题。似乎当我尝试设置edit_line的文本时,我只是得到一个问号。这是我的完整代码。
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
这是我非常简单的动词类。这里没什么特别的。 我的UI脚本在
下面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
如果我点击带有字符的按钮©我可以看到警告框中的字符被正确显示。但是我将值分配给代码
中编辑行的文本button("й") {
@user_input_box.text = "й"
alert("й")
}
然而,如果再看一下gui,你会发现我只会显示一个问号。这让我疯了。我在这里俯瞰什么?