使用edit_line元素的Ruby Shoes中的西里尔字符
我在穿鞋时有一个奇怪的问题。我附上了一个非常简单的图形用户界面截图,我正在为一个Ruby脚本构建,我希望用它来帮助我学习俄语。然而,我对西里尔文字有一个奇怪的问题。似乎当我试图设置编辑行的文本时,我只得到了一个问号。这是我的完整代码使用edit_line元素的Ruby Shoes中的西里尔字符,ruby,user-interface,utf-8,shoes,Ruby,User Interface,Utf 8,Shoes,我在穿鞋时有一个奇怪的问题。我附上了一个非常简单的图形用户界面截图,我正在为一个Ruby脚本构建,我希望用它来帮助我学习俄语。然而,我对西里尔文字有一个奇怪的问题。似乎当我试图设置编辑行的文本时,我只得到了一个问号。这是我的完整代码 class Verb attr_accessor :infinitive,:present_first_sing,:present_second_sing,:present_third_sing,:present_first_plu,:present_sec
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,您可以看到我只得到一个要显示的问号。这让我快发疯了。我在这里忽略了什么?我刚刚在Hacketyhack的Mac上运行了你的代码,它运行得非常有趣。那么什么是黑客?我应该使用它吗?hacktyhack()是一种鞋的IDE。我不确定使用它是否真的能帮你解决这个问题,但我想说的是我用的是什么。