mirror of
https://github.com/Oreolek/Togataltu.git
synced 2024-05-01 16:49:33 +03:00
Добавил заглушку на редактирование словаря.
This commit is contained in:
parent
fd2e3e9036
commit
6eba0c6289
37
DictFrame.rb
Normal file
37
DictFrame.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env ruby
|
||||
#encoding: utf-8
|
||||
class DictFrame < Frame
|
||||
def initialize(title)
|
||||
super( nil, :title => title, :size => [800, 200] )
|
||||
sizer_add_word = BoxSizer.new(Wx::HORIZONTAL)
|
||||
sizer_add_word_main = BoxSizer.new(Wx::VERTICAL)
|
||||
@new_word = Wx::TextCtrl.new(self, -1, 'Введите слово на исходном языке',Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE);
|
||||
@new_translation = Wx::TextCtrl.new(self, -1, 'Введите перевод',Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE);
|
||||
button_save_word = Wx::Button.new(self, -1, 'Сохранить перевод слова')
|
||||
button_save_word_and_close = Wx::Button.new(self, -1, 'Сохранить перевод слова и закрыть диалог')
|
||||
button_close = Wx::Button.new(self, -1, 'Закрыть диалог без сохранения изменений')
|
||||
sizer_add_word.add(@new_word, 1, Wx::GROW|Wx::ALL, 2)
|
||||
sizer_add_word.add(@new_translation, 1, Wx::GROW|Wx::ALL, 2)
|
||||
sizer_add_word_main.add(sizer_add_word, 0, Wx::GROW|Wx::ALL|Wx::ALIGN_CENTER_HORIZONTAL, 2)
|
||||
sizer_add_word_main.add(button_save_word, 0, Wx::ALL|Wx::ALIGN_CENTER_HORIZONTAL, 2)
|
||||
sizer_add_word_main.add(button_save_word_and_close, 0, Wx::ALL|Wx::ALIGN_CENTER_HORIZONTAL, 2)
|
||||
sizer_add_word_main.add(button_close, 0, Wx::ALL|Wx::ALIGN_CENTER_HORIZONTAL, 2)
|
||||
self.set_sizer(sizer_add_word_main)
|
||||
evt_button(button_save_word.get_id, :on_save)
|
||||
evt_button(button_save_word_and_close.get_id, :on_save_and_close)
|
||||
evt_button(button_close.get_id, :on_close)
|
||||
end
|
||||
def on_save
|
||||
output = File.open('dictionaries/user.txt', 'a')
|
||||
output.puts(@new_word.value)
|
||||
output.puts(' '+@new_translation.value)
|
||||
output.close
|
||||
end
|
||||
def on_save_and_close
|
||||
self.on_save()
|
||||
self.on_close()
|
||||
end
|
||||
def on_close
|
||||
self.destroy()
|
||||
end
|
||||
end
|
|
@ -32,6 +32,6 @@ class WordFrame < Frame
|
|||
self.on_close()
|
||||
end
|
||||
def on_close
|
||||
self.hide()
|
||||
self.destroy()
|
||||
end
|
||||
end
|
8
main.rb
8
main.rb
|
@ -10,6 +10,8 @@ $:.unshift File.dirname(__FILE__)
|
|||
require "source.rb"
|
||||
include Wx
|
||||
require "WordFrame"
|
||||
require "DictFrame"
|
||||
|
||||
class MainFrame < Frame
|
||||
ID_EDIT_DICTIONARY = Wx::ID_HIGHEST+1
|
||||
ID_ADD_WORD = Wx::ID_HIGHEST+1
|
||||
|
@ -57,7 +59,6 @@ require "WordFrame"
|
|||
evt_button(button_start.get_id, :on_start)
|
||||
@opendialog = Wx::FileDialog.new(nil,"Открыть файл")
|
||||
@savedialog = Wx::FileDialog.new(nil,"Открыть файл",:style => Wx::FD_SAVE | Wx::FD_OVERWRITE_PROMPT)
|
||||
@frame_add = WordFrame.new('Добавление слова в словарь')
|
||||
end
|
||||
def on_quit
|
||||
close
|
||||
|
@ -94,7 +95,7 @@ require "WordFrame"
|
|||
@translation.clear()
|
||||
@log << "\nФайл закрыт."
|
||||
@frame_add.destroy()
|
||||
self.dispose()
|
||||
self.destroy()
|
||||
end
|
||||
def on_save
|
||||
if @savedialog.show_modal == Wx::ID_OK
|
||||
|
@ -103,8 +104,11 @@ require "WordFrame"
|
|||
end
|
||||
end
|
||||
def on_edit_dictionary
|
||||
@frame_edit = DictFrame.new('Редактирование словаря')
|
||||
@frame_edit.show
|
||||
end
|
||||
def on_add_word
|
||||
@frame_add = WordFrame.new('Добавление слова в словарь')
|
||||
@frame_add.show
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue