2
# tkextlib/tcllib/getstring.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
5
# * Part of tcllib extension
6
# * A dialog which consists of an Entry, OK, and Cancel buttons.
11
require 'tkextlib/tcllib.rb'
13
# TkPackage.require('getstring', '0.1')
14
TkPackage.require('getstring')
17
class GetString_Dialog < TkWindow
18
PACKAGE_NAME = 'getstring'.freeze
23
def self.package_version
25
TkPackage.require('getstring')
34
class Tk::Tcllib::GetString_Dialog
35
TkCommandNames = ['::getstring::tk_getString'.freeze].freeze
36
WidgetClassName = 'TkSDialog'.freeze
37
WidgetClassNames[WidgetClassName] = self
40
dialog = self.new(*args)
42
[dialog.status, dialog.value]
44
def self.display(*args)
48
def initialize(*args) # args = (parent=nil, text='', keys=nil)
50
if keys.kind_of?(Hash)
52
@keys = _symbolkey2str(keys)
64
@variable = TkVariable.new
77
@status = bool(tk_call(self.class::TkCommandNames[0],
78
@path, @variable, @text, *hash_kv(@keys)))
99
def configure(slot, value=None)
100
if slot.kind_of?(Hash)
101
slot.each{|k, v| configure(k, v)}
104
value = _symbolkey2str(value) if value.kind_of?(Hash)
105
if value && value != None
122
def configinfo(slot = nil)
125
[ slot, nil, nil, nil, ( (slot == 'text')? @text: @keys[slot] ) ]
127
@keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
128
<< [ 'text', nil, nil, nil, @text ]