Class: Rediscover::Frame::CreateKey
- Inherits:
-
Wx::Frame
- Object
- Wx::Frame
- Rediscover::Frame::CreateKey
- Includes:
- Wx
- Defined in:
- lib/rediscover/frame/create_key.rb
Instance Method Summary collapse
- #create_evt ⇒ Object
-
#initialize(window) ⇒ CreateKey
constructor
A new instance of CreateKey.
- #on_create(&block) ⇒ Object
- #setup_panel ⇒ Object
Constructor Details
#initialize(window) ⇒ CreateKey
Returns a new instance of CreateKey.
6 7 8 9 10 11 12 13 14 |
# File 'lib/rediscover/frame/create_key.rb', line 6 def initialize(window) @redis = get_app.redis super(window, -1, 'Create a Key') set_icon(Rediscover::Icon.new('key_add')) setup_panel show end |
Instance Method Details
#create_evt ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rediscover/frame/create_key.rb', line 39 def create_evt key = @key_textbox.get_value value = @value_textbox.get_value begin @redis[key] = value rescue => e ExceptionHandler.modal(self, e) return end @on_create_block.call() if @on_create_block close end |
#on_create(&block) ⇒ Object
35 36 37 |
# File 'lib/rediscover/frame/create_key.rb', line 35 def on_create(&block) @on_create_block = block end |
#setup_panel ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rediscover/frame/create_key.rb', line 16 def setup_panel @panel = Wx::Panel.new(self) @key_label = StaticText.new(@panel, :label => 'Key') @key_textbox = TextCtrl.new(@panel) @value_label = StaticText.new(@panel, :label => 'Value') @value_textbox = TextCtrl.new(@panel) @create_button = Button.new(@panel, :label => 'Create') @create_button, :create_evt @panel_sizer = BoxSizer.new(VERTICAL) @panel.set_sizer(@panel_sizer) @panel_sizer.add(@key_label, 0, GROW|ALL, 2) @panel_sizer.add(@key_textbox, 0, GROW|ALL, 2) @panel_sizer.add(@value_label, 0, GROW|ALL, 2) @panel_sizer.add(@value_textbox, 0, GROW|ALL, 2) @panel_sizer.add(@create_button, 0, GROW|ALL, 2) end |