Module: Tk

Extended by:
Tk, Encoding
Includes:
TkCore
Included in:
Tk, BLT::PlotComponent::Element, BLT::PlotComponent::Marker, BLT::Table, BLT::Table, BWidget::DragSite, BWidget::DragSite, BWidget::DropSite, BWidget::DropSite, BWidget::DynamicHelp, BWidget::DynamicHelp, BWidget::SelectColor, BWidget::SelectFont, BWidget::Widget, BWidget::Widget, Clock, ICONS, Itcl, Itcl, Itk, Itk, TreeCtrl::BindCallback, TreeCtrl::BindCallback, TkBgError, TkClipboard, TkClipboard, TkComposite, TkComposite, TkConsole, TkConsole, TkDialogObj, TkFont, TkFont::CoreMethods, TkGrid, TkGrid, TkImage, TkKinput, TkKinput, TkMacResource, TkManageFocus, TkMsgCatalog, TkNamespace, TkNamespace::ScopeArgs, TkObject, TkOptionDB, TkOptionDB, TkPack, TkPack, TkPalette, TkPalette, TkPlace, TkPlace, TkSelection, TkSelection, TkVariable, TkVirtualEvent, TkWinDDE, TkWinRegistry, TkWinfo, TkWinfo, TkXIM, TkXIM, TkcItem
Defined in:
lib/tk/autoload.rb,
lib/tk/wm.rb,
lib/tk/clock.rb,
sample/irbtk.rb,
lib/tk/macpkg.rb,
lib/tk/variable.rb,
lib/tkextlib/vu.rb,
lib/tk/optionobj.rb,
lib/tkextlib/blt.rb,
lib/tk/encodedstr.rb,
lib/tk/scrollable.rb,
lib/tk/validation.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tile.rb,
lib/tkextlib/tkDND.rb,
lib/tkextlib/tkimg.rb,
lib/tkextlib/tcllib.rb,
lib/tkextlib/vu/pie.rb,
lib/tkextlib/bwidget.rb,
lib/tkextlib/version.rb,
lib/tkextlib/vu/dial.rb,
lib/tkextlib/iwidgets.rb,
lib/tkextlib/tkimg/ps.rb,
lib/tkextlib/tclx/tclx.rb,
lib/tkextlib/tkimg/bmp.rb,
lib/tkextlib/tkimg/gif.rb,
lib/tkextlib/tkimg/ico.rb,
lib/tkextlib/tkimg/pcx.rb,
lib/tkextlib/tkimg/png.rb,
lib/tkextlib/tkimg/ppm.rb,
lib/tkextlib/tkimg/sgi.rb,
lib/tkextlib/tkimg/sun.rb,
lib/tkextlib/tkimg/tga.rb,
lib/tkextlib/tkimg/xbm.rb,
lib/tkextlib/tkimg/xpm.rb,
lib/tkextlib/vu/charts.rb,
lib/tkextlib/tcllib/ico.rb,
lib/tkextlib/tile/style.rb,
lib/tkextlib/tkimg/jpeg.rb,
lib/tkextlib/tkimg/tiff.rb,
lib/tkextlib/vu/spinbox.rb,
lib/tkextlib/ICONS/icons.rb,
lib/tkextlib/itk/incr_tk.rb,
lib/tkextlib/tile/dialog.rb,
lib/tkextlib/tile/tentry.rb,
lib/tkextlib/tile/tframe.rb,
lib/tkextlib/tile/tlabel.rb,
lib/tkextlib/tile/tpaned.rb,
lib/tkextlib/tile/tscale.rb,
lib/tkextlib/tkDND/shape.rb,
lib/tkextlib/tkDND/tkdnd.rb,
lib/tkextlib/trofs/trofs.rb,
lib/tkextlib/vu/bargraph.rb,
lib/tkextlib/bwidget/tree.rb,
lib/tkextlib/tcllib/ctext.rb,
lib/tkextlib/tile/tbutton.rb,
lib/tkextlib/tile/tsquare.rb,
lib/tkextlib/tkimg/pixmap.rb,
lib/tkextlib/tkimg/window.rb,
lib/tkextlib/bwidget/entry.rb,
lib/tkextlib/bwidget/label.rb,
lib/tkextlib/itcl/incr_tcl.rb,
lib/tkextlib/tcllib/cursor.rb,
lib/tkextlib/tcllib/cursor.rb,
lib/tkextlib/tile/sizegrip.rb,
lib/tkextlib/tile/treeview.rb,
lib/tkextlib/winico/winico.rb,
sample/demos-en/tkencoding.rb,
lib/tkextlib/bwidget/bitmap.rb,
lib/tkextlib/bwidget/button.rb,
lib/tkextlib/bwidget/dialog.rb,
lib/tkextlib/bwidget/widget.rb,
lib/tkextlib/iwidgets/shell.rb,
lib/tkextlib/iwidgets/watch.rb,
lib/tkextlib/tile/tcombobox.rb,
lib/tkextlib/tile/tnotebook.rb,
lib/tkextlib/bwidget/listbox.rb,
lib/tkextlib/bwidget/spinbox.rb,
lib/tkextlib/iwidgets/dialog.rb,
lib/tkextlib/iwidgets/tabset.rb,
lib/tkextlib/tcllib/ip_entry.rb,
lib/tkextlib/tile/tscrollbar.rb,
lib/tkextlib/tile/tseparator.rb,
lib/tkextlib/tktable/tktable.rb,
lib/tkextlib/tktrans/tktrans.rb,
lib/tkextlib/bwidget/combobox.rb,
lib/tkextlib/bwidget/dragsite.rb,
lib/tkextlib/bwidget/dropsite.rb,
lib/tkextlib/bwidget/notebook.rb,
lib/tkextlib/iwidgets/menubar.rb,
lib/tkextlib/iwidgets/spinint.rb,
lib/tkextlib/iwidgets/spinner.rb,
lib/tkextlib/iwidgets/toolbar.rb,
lib/tkextlib/tcllib/datefield.rb,
lib/tkextlib/tcllib/plotchart.rb,
lib/tkextlib/tile/tlabelframe.rb,
lib/tkextlib/tile/tmenubutton.rb,
lib/tkextlib/bwidget/buttonbox.rb,
lib/tkextlib/bwidget/mainframe.rb,
lib/tkextlib/bwidget/passwddlg.rb,
lib/tkextlib/bwidget/separator.rb,
lib/tkextlib/bwidget/statusbar.rb,
lib/tkextlib/iwidgets/calendar.rb,
lib/tkextlib/iwidgets/checkbox.rb,
lib/tkextlib/iwidgets/combobox.rb,
lib/tkextlib/iwidgets/feedback.rb,
lib/tkextlib/iwidgets/notebook.rb,
lib/tkextlib/iwidgets/radiobox.rb,
lib/tkextlib/iwidgets/spindate.rb,
lib/tkextlib/iwidgets/spintime.rb,
lib/tkextlib/tcllib/autoscroll.rb,
lib/tkextlib/tcllib/autoscroll.rb,
lib/tkextlib/tcllib/autoscroll.rb,
lib/tkextlib/tcllib/tkpiechart.rb,
lib/tkextlib/tile/tcheckbutton.rb,
lib/tkextlib/tile/tprogressbar.rb,
lib/tkextlib/tile/tradiobutton.rb,
lib/tkextlib/tkHTML/htmlwidget.rb,
lib/tkextlib/bwidget/labelentry.rb,
lib/tkextlib/bwidget/labelframe.rb,
lib/tkextlib/bwidget/messagedlg.rb,
lib/tkextlib/bwidget/panelframe.rb,
lib/tkextlib/bwidget/scrollview.rb,
lib/tkextlib/bwidget/selectfont.rb,
lib/tkextlib/bwidget/titleframe.rb,
lib/tkextlib/iwidgets/buttonbox.rb,
lib/tkextlib/iwidgets/dateentry.rb,
lib/tkextlib/iwidgets/datefield.rb,
lib/tkextlib/iwidgets/extbutton.rb,
lib/tkextlib/iwidgets/hierarchy.rb,
lib/tkextlib/iwidgets/hyperhelp.rb,
lib/tkextlib/iwidgets/timeentry.rb,
lib/tkextlib/iwidgets/timefield.rb,
lib/tkextlib/bwidget/arrowbutton.rb,
lib/tkextlib/bwidget/dynamichelp.rb,
lib/tkextlib/bwidget/panedwindow.rb,
lib/tkextlib/bwidget/progressbar.rb,
lib/tkextlib/bwidget/progressdlg.rb,
lib/tkextlib/bwidget/selectcolor.rb,
lib/tkextlib/iwidgets/entryfield.rb,
lib/tkextlib/iwidgets/finddialog.rb,
lib/tkextlib/iwidgets/mainwindow.rb,
lib/tkextlib/iwidgets/messagebox.rb,
lib/tkextlib/iwidgets/optionmenu.rb,
lib/tkextlib/iwidgets/pushbutton.rb,
lib/tkextlib/treectrl/tktreectrl.rb,
lib/tkextlib/bwidget/pagesmanager.rb,
lib/tkextlib/iwidgets/dialogshell.rb,
lib/tkextlib/iwidgets/panedwindow.rb,
lib/tkextlib/iwidgets/tabnotebook.rb,
lib/tkextlib/iwidgets/labeledframe.rb,
lib/tkextlib/iwidgets/promptdialog.rb,
lib/tkextlib/iwidgets/scopedobject.rb,
lib/tkextlib/iwidgets/scrolledhtml.rb,
lib/tkextlib/iwidgets/scrolledtext.rb,
lib/tkextlib/iwidgets/selectionbox.rb,
lib/tkextlib/tcllib/tablelist_core.rb,
lib/tkextlib/tcllib/tablelist_tile.rb,
lib/tkextlib/bwidget/scrolledwindow.rb,
lib/tkextlib/iwidgets/labeledwidget.rb,
lib/tkextlib/iwidgets/messagedialog.rb,
lib/tkextlib/iwidgets/scrolledframe.rb,
lib/tkextlib/bwidget/scrollableframe.rb,
lib/tkextlib/iwidgets/canvasprintbox.rb,
lib/tkextlib/iwidgets/scrolledcanvas.rb,
lib/tkextlib/iwidgets/scrolledwidget.rb,
lib/tkextlib/iwidgets/disjointlistbox.rb,
lib/tkextlib/iwidgets/scrolledlistbox.rb,
lib/tkextlib/iwidgets/selectiondialog.rb,
lib/tkextlib/iwidgets/fileselectionbox.rb,
lib/tkextlib/iwidgets/canvasprintdialog.rb,
lib/tkextlib/iwidgets/extfileselectionbox.rb,
lib/tkextlib/iwidgets/fileselectiondialog.rb,
lib/tkextlib/iwidgets/extfileselectiondialog.rb,
lib/tk.rb,
lib/tk.rb,
lib/tk.rb,
lib/tk.rb,
lib/tk.rb

Overview

freeze core modules TclTkLib.freeze TclTkIp.freeze TkUtil.freeze TkKernel.freeze TkComm.freeze TkComm::Event.freeze TkCore.freeze Tk.freeze

Defined Under Namespace

Modules: BLT, BWidget, Clock, Encoding, Img, Itcl, ItemValidateConfigure, Itk, Iwidgets, Scrollable, TclX, Tcllib, Tile, TkDND, TkTrans, Trofs, ValidateConfigure, Vu, Wm, XScrollable, YScrollable Classes: BinaryString, EncodedString, HTML_Widget, ICONS, OptionObj, ScrollFrame, TkTable, TreeCtrl, UTF8_String, Winico

Constant Summary collapse

MAINLOOP =
Thread.new{ mainloop }
AUTO_PATH =
TkVarAccess.new('auto_path', auto_path)
TCL_PACKAGE_PATH =

AUTO_OLDPATH = tk_split_simplelist(INTERP._invoke(‘set’, ‘auto_oldpath’))

AUTO_OLDPATH.each{|s| s.freeze}
AUTO_OLDPATH.freeze
TkVarAccess.new('tcl_pkgPath')
PACKAGE_PATH =
TCL_PACKAGE_PATH
TCL_LIBRARY_PATH =
TkVarAccess.new('tcl_libPath')
LIBRARY_PATH =
TCL_LIBRARY_PATH
TCL_PRECISION =
TkVarAccess.new('tcl_precision')
X_Scrollable =
XScrollable
Y_Scrollable =
YScrollable
Tkextlib_RELEASE_DATE =
'2007-01-26'.freeze
INTERP =
TkCore::INTERP
TreeCtrl_Widget =
TreeCtrl
TCL_VERSION =
INTERP._invoke_without_enc("info", "tclversion").freeze
TCL_PATCHLEVEL =
INTERP._invoke_without_enc("info", "patchlevel").freeze
TCL_MAJOR_VERSION =
major.to_i
TCL_MINOR_VERSION =
minor.to_i
TK_VERSION =
INTERP._invoke_without_enc("set", "tk_version").freeze
TK_PATCHLEVEL =
INTERP._invoke_without_enc("set", "tk_patchLevel").freeze
TK_MAJOR_VERSION =
major.to_i
TK_MINOR_VERSION =
minor.to_i
JAPANIZED_TK =
(INTERP._invoke_without_enc("info", "commands", 
"kanji") != "").freeze
RELEASE_DATE =
'2007-01-26'.freeze

Constants included from Encoding

Encoding::TkCommandNames

Constants included from TkCore

TkCore::EventFlag, TkCore::WIDGET_DESTROY_HOOK

Constants included from TkComm

TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames

Constants included from TkUtil

TkUtil::None

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Encoding

encoding_convertfrom, encoding_convertto, encoding_dirs, encoding_dirs=, encoding_names, encoding_system, encoding_system=

Methods included from TkCore

#_tk_call_to_list_core, #after, #after_cancel, #after_idle, #appname, #appsend, #appsend_deny, #appsend_displayof, callback, #callback_break, #callback_continue, #callback_return, #chooseColor, #chooseDirectory, #do_one_event, #event_generate, #getMultipleOpenFile, #getMultipleSaveFile, #getOpenFile, #getSaveFile, #get_eventloop_tick, #get_eventloop_weight, #get_no_event_wait, #inactive, #inactive_displayof, #info, #ip_eval, #ip_eval_with_enc, #ip_eval_without_enc, #ip_invoke, #ip_invoke_with_enc, #ip_invoke_without_enc, #is_mainloop?, #load_cmd_on_ip, #mainloop, #mainloop_exist?, #mainloop_thread?, #mainloop_watchdog, #messageBox, #rb_appsend, #rb_appsend_displayof, #reset_inactive, #reset_inactive_displayof, #restart, #scaling, #scaling_displayof, #set_eventloop_tick, #set_eventloop_weight, #set_no_event_wait, #tk_call, #tk_call_to_list, #tk_call_to_list_with_enc, #tk_call_to_list_without_enc, #tk_call_to_simplelist, #tk_call_to_simplelist_with_enc, #tk_call_to_simplelist_without_enc, #tk_call_with_enc, #tk_call_without_enc, #windowingsystem

Methods included from TkComm

_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, #bind, #bind_all, #bind_append, #bind_append_all, #bind_remove, #bind_remove_all, #bindinfo, #bindinfo_all, bool, image_obj, install_cmd, list, num_or_str, number, procedure, simplelist, string, #subst, tk_tcl2ruby, uninstall_cmd, window

Methods included from TkUtil

_conv_args, #_conv_args, #_fromUTF8, _get_eval_enc_str, #_get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, bool, #bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd

Methods included from TkEvent

#install_bind, #install_bind_for_event_class

Class Method Details

.add_kinsoku(chars, mode = 'both') ⇒ Object



2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
# File 'lib/tk.rb', line 2151

def Tk.add_kinsoku(chars, mode='both')
  begin
    if /^8\.*/ === TK_VERSION  && JAPANIZED_TK
      tk_split_simplelist(tk_call('kinsoku', 'add', mode, 
                                  *(chars.split(''))))
    else
      []
    end
  rescue
    []
  end
end

.bell(nice = false) ⇒ Object



2000
2001
2002
2003
2004
2005
2006
2007
# File 'lib/tk.rb', line 2000

def Tk.bell(nice = false)
  if nice
    tk_call_without_enc('bell', '-nice')
  else
    tk_call_without_enc('bell')
  end
  nil
end

.bell_on_display(win, nice = false) ⇒ Object



2009
2010
2011
2012
2013
2014
2015
2016
# File 'lib/tk.rb', line 2009

def Tk.bell_on_display(win, nice = false)
  if nice
    tk_call_without_enc('bell', '-displayof', win, '-nice')
  else
    tk_call_without_enc('bell', '-displayof', win)
  end
  nil
end

.BinaryString(str) ⇒ Object



192
# File 'lib/tk/autoload.rb', line 192

def Tk.BinaryString(str); Tk::BinaryString.new(str); end

.const_missing(sym) ⇒ Object



1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
# File 'lib/tk.rb', line 1823

def Tk.const_missing(sym)
  case(sym)
  when :TCL_LIBRARY
    INTERP._invoke_without_enc('global', 'tcl_library')
    INTERP._invoke("set", "tcl_library").freeze

  when :TK_LIBRARY
    INTERP._invoke_without_enc('global', 'tk_library')
    INTERP._invoke("set", "tk_library").freeze

  when :LIBRARY
    INTERP._invoke("info", "library").freeze

  #when :PKG_PATH, :PACKAGE_PATH, :TCL_PACKAGE_PATH
  #  INTERP._invoke_without_enc('global', 'tcl_pkgPath')
  #  tk_split_simplelist(INTERP._invoke('set', 'tcl_pkgPath'))

  #when :LIB_PATH, :LIBRARY_PATH, :TCL_LIBRARY_PATH
  #  INTERP._invoke_without_enc('global', 'tcl_libPath')
  #  tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath'))

  when :PLATFORM, :TCL_PLATFORM
    if $SAFE >= 4
      fail SecurityError, "can't get #{sym} when $SAFE >= 4"
    end
    INTERP._invoke_without_enc('global', 'tcl_platform')
    Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', 
                                                         'tcl_platform'))]

  when :ENV
    INTERP._invoke_without_enc('global', 'env')
    Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))]

  #when :AUTO_PATH   #<=== 
  #  tk_split_simplelist(INTERP._invoke('set', 'auto_path'))

  #when :AUTO_OLDPATH
  #  tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))

  when :AUTO_INDEX
    INTERP._invoke_without_enc('global', 'auto_index')
    Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'auto_index'))]

  when :PRIV, :PRIVATE, :TK_PRIV
    priv = {}
    if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != ""
      var_nam = 'tk::Priv'
    else
      var_nam = 'tkPriv'
    end
    INTERP._invoke_without_enc('global', var_nam)
    Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 
                                             var_nam))].each{|k,v|
      k.freeze
      case v
      when /^-?\d+$/
        priv[k] = v.to_i
      when /^-?\d+\.?\d*(e[-+]?\d+)?$/
        priv[k] = v.to_f
      else
        priv[k] = v.freeze
      end
    }
    priv

  else
    raise NameError, 'uninitialized constant Tk::' + sym.id2name
  end
end

.current_grabs(win = nil) ⇒ Object



2103
2104
2105
2106
2107
2108
2109
# File 'lib/tk.rb', line 2103

def Tk.current_grabs(win = nil)
  if win
    window(tk_call_without_enc('grab', 'current', win))
  else
    tk_split_list(tk_call_without_enc('grab', 'current'))
  end
end

.cursor_display(parent = None) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/tkextlib/tcllib/cursor.rb', line 46

def self.cursor_display(parent=None)
  # Pops up a dialog with a listbox containing all the cursor names. 
  # Selecting a cursor name will display it in that dialog. 
  # This is simply for viewing any available cursors on the platform .
  #tk_call_without_enc('::cursor::display', parent)
  Tk::Tcllib::Cursor.cursor_display(parent)
end

.delete_kinsoku(chars, mode = 'both') ⇒ Object



2163
2164
2165
2166
2167
2168
2169
2170
2171
# File 'lib/tk.rb', line 2163

def Tk.delete_kinsoku(chars, mode='both')
  begin
    if /^8\.*/ === TK_VERSION  && JAPANIZED_TK
      tk_split_simplelist(tk_call('kinsoku', 'delete', mode, 
                          *(chars.split(''))))
    end
  rescue
  end
end

.destroy(*wins) ⇒ Object



2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
# File 'lib/tk.rb', line 2018

def Tk.destroy(*wins)
  #tk_call_without_enc('destroy', *wins)
  tk_call_without_enc('destroy', *(wins.collect{|win|
                                     if win.kind_of?(TkWindow)
                                       win.epath
                                     else
                                       win
                                     end
                                   }))
end

.EncodedString(str, enc = nil) ⇒ Object



189
# File 'lib/tk/autoload.rb', line 189

def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end

.errorCodeObject



1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
# File 'lib/tk.rb', line 1898

def Tk.errorCode
  INTERP._invoke_without_enc('global', 'errorCode')
  code = tk_split_simplelist(INTERP._invoke_without_enc('set', 'errorCode'))
  case code[0]
  when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP'
    begin
      pid = Integer(code[1])
      code[1] = pid
    rescue
    end
  end
  code
end

.errorInfoObject



1893
1894
1895
1896
# File 'lib/tk.rb', line 1893

def Tk.errorInfo
  INTERP._invoke_without_enc('global', 'errorInfo')
  INTERP._invoke_without_enc('set', 'errorInfo')
end

.exitObject



2029
2030
2031
# File 'lib/tk.rb', line 2029

def Tk.exit
  tk_call_without_enc('destroy', '.')
end

.focus(display = nil) ⇒ Object



2111
2112
2113
2114
2115
2116
2117
# File 'lib/tk.rb', line 2111

def Tk.focus(display=nil)
  if display == nil
    window(tk_call_without_enc('focus'))
  else
    window(tk_call_without_enc('focus', '-displayof', display))
  end
end

.focus_lastfor(win) ⇒ Object



2127
2128
2129
# File 'lib/tk.rb', line 2127

def Tk.focus_lastfor(win)
  window(tk_call_without_enc('focus', '-lastfor', win))
end

.focus_next(win) ⇒ Object



2131
2132
2133
# File 'lib/tk.rb', line 2131

def Tk.focus_next(win)
  TkManageFocus.next(win)
end

.focus_prev(win) ⇒ Object



2135
2136
2137
# File 'lib/tk.rb', line 2135

def Tk.focus_prev(win)
  TkManageFocus.prev(win)
end

.focus_to(win, force = false) ⇒ Object



2119
2120
2121
2122
2123
2124
2125
# File 'lib/tk.rb', line 2119

def Tk.focus_to(win, force=false)
  if force
    tk_call_without_enc('focus', '-force', win)
  else
    tk_call_without_enc('focus', win)
  end
end

.fromUTF8(str, encoding = nil) ⇒ Object



2177
2178
2179
# File 'lib/tk.rb', line 2177

def Tk.fromUTF8(str, encoding = nil)
  _fromUTF8(str, encoding)
end

.grid(*args) ⇒ Object



2043
2044
2045
# File 'lib/tk.rb', line 2043

def Tk.grid(*args)
  TkGrid.configure(*args)
end

.grid_forget(*args) ⇒ Object



2046
2047
2048
# File 'lib/tk.rb', line 2046

def Tk.grid_forget(*args)
  TkGrid.forget(*args)
end

.has_mainwindow?Boolean

Returns:

  • (Boolean)


1912
1913
1914
# File 'lib/tk.rb', line 1912

def Tk.has_mainwindow?
  INTERP.has_mainwindow?
end

.load_tcllibrary(file, pkg_name = None, interp = None) ⇒ Object



1929
1930
1931
# File 'lib/tk.rb', line 1929

def Tk.load_tcllibrary(file, pkg_name=None, interp=None)
  tk_call('load', file, pkg_name, interp)
end

.load_tclscript(file, enc = nil) ⇒ Object



1920
1921
1922
1923
1924
1925
1926
1927
# File 'lib/tk.rb', line 1920

def Tk.load_tclscript(file, enc=nil)
  if enc
    # TCL_VERSION >= 8.5
    tk_call('source', '-encoding', enc, file)
  else
    tk_call('source', file)
  end
end

.load_tclscript_rsrc(resource_name, file = None) ⇒ Object



12
13
14
15
# File 'lib/tk/macpkg.rb', line 12

def Tk.load_tclscript_rsrc(resource_name, file=None)
  # Mac only
  tk_call('source', '-rsrc', resource_name, file)
end

.load_tclscript_rsrcid(resource_id, file = None) ⇒ Object



17
18
19
20
# File 'lib/tk/macpkg.rb', line 17

def Tk.load_tclscript_rsrcid(resource_id, file=None)
  # Mac only
  tk_call('source', '-rsrcid', resource_id, file)
end

.lower_window(win, below = None) ⇒ Object



2094
2095
2096
2097
# File 'lib/tk.rb', line 2094

def Tk.lower_window(win, below=None)
  tk_call('lower', _epath(win), _epath(below))
  nil
end

.pack(*args) ⇒ Object



2033
2034
2035
# File 'lib/tk.rb', line 2033

def Tk.pack(*args)
  TkPack.configure(*args)
end

.pack_forget(*args) ⇒ Object



2036
2037
2038
# File 'lib/tk.rb', line 2036

def Tk.pack_forget(*args)
  TkPack.forget(*args)
end

.pkgconfig_get(mod, key) ⇒ Object



1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
# File 'lib/tk.rb', line 1963

def Tk.pkgconfig_get(mod, key)
  # Tk8.5 feature
  if mod.kind_of?(Module)
    if mod.respond_to?(:package_name)
      pkgname = mod.package_name
    else
      fail NotImplementedError, 'may not be a module for a Tcl extension'
    end
  else
    pkgname = mod.to_s
  end

  pkgname = '::' << pkgname unless pkgname =~ /^::/

  tk_call(pkgname + '::pkgconfig', 'get', key)
end

.pkgconfig_list(mod) ⇒ Object



1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
# File 'lib/tk.rb', line 1944

def Tk.pkgconfig_list(mod)
  # Tk8.5 feature
  if mod.kind_of?(Module)
    if mod.respond_to?(:package_name)
      pkgname = mod.package_name
    elsif mod.const_defined?(:PACKAGE_NAME)
      pkgname = mod::PACKAGE_NAME
    else
      fail NotImplementedError, 'may not be a module for a Tcl extension'
    end
  else
    pkgname = mod.to_s
  end

  pkgname = '::' << pkgname unless pkgname =~ /^::/

  tk_split_list(tk_call(pkgname + '::pkgconfig', 'list'))
end

.place(*args) ⇒ Object



2053
2054
2055
# File 'lib/tk.rb', line 2053

def Tk.place(*args)
  TkPlace.configure(*args)
end

.place_forget(*args) ⇒ Object



2056
2057
2058
# File 'lib/tk.rb', line 2056

def Tk.place_forget(*args)
  TkPlace.forget(*args)
end

.raise_window(win, above = None) ⇒ Object



2098
2099
2100
2101
# File 'lib/tk.rb', line 2098

def Tk.raise_window(win, above=None)
  tk_call('raise', _epath(win), _epath(above))
  nil
end

.show_kinsoku(mode = 'both') ⇒ Object



2143
2144
2145
2146
2147
2148
2149
2150
# File 'lib/tk.rb', line 2143

def Tk.show_kinsoku(mode='both')
  begin
    if /^8\.*/ === TK_VERSION  && JAPANIZED_TK
      tk_split_simplelist(tk_call('kinsoku', 'show', mode))
    end
  rescue
  end
end

.strictMotif(mode = None) ⇒ Object



2139
2140
2141
# File 'lib/tk.rb', line 2139

def Tk.strictMotif(mode=None)
  bool(tk_call_without_enc('set', 'tk_strictMotif', mode))
end

.subst_tk_backslash(str) ⇒ Object



2189
2190
2191
# File 'lib/tk.rb', line 2189

def Tk.subst_tk_backslash(str)
  Tk::EncodedString.subst_tk_backslash(str)
end

.subst_utf_backslash(str) ⇒ Object



2186
2187
2188
# File 'lib/tk.rb', line 2186

def Tk.subst_utf_backslash(str)
  Tk::EncodedString.subst_utf_backslash(str)
end

.tcl_pkgconfig_get(key) ⇒ Object



1985
1986
1987
1988
# File 'lib/tk.rb', line 1985

def Tk.tcl_pkgconfig_get(key)
  # Tk8.5 feature
  Tk.pkgconfig_get('::tcl', key)
end

.tcl_pkgconfig_listObject



1980
1981
1982
1983
# File 'lib/tk.rb', line 1980

def Tk.tcl_pkgconfig_list
  # Tk8.5 feature
  Tk.pkgconfig_list('::tcl')
end

.thread_update(idle = nil) ⇒ Object

NOTE

If no eventloop-thread is running, “thread_update” method is same to “update” method. Else, “thread_update” method waits to complete idletask operation on the eventloop-thread.



2083
2084
2085
2086
2087
2088
2089
# File 'lib/tk.rb', line 2083

def Tk.thread_update(idle=nil)
  if idle
    tk_call_without_enc('thread_update', 'idletasks')
  else
    tk_call_without_enc('thread_update')
  end
end

.thread_update_idletasksObject



2090
2091
2092
# File 'lib/tk.rb', line 2090

def Tk.thread_update_idletasks
  thread_update(true)
end

.tk_pkgconfig_get(key) ⇒ Object



1995
1996
1997
1998
# File 'lib/tk.rb', line 1995

def Tk.tk_pkgconfig_get(key)
  # Tk8.5 feature
  Tk.pkgconfig_get('::tk', key)
end

.tk_pkgconfig_listObject



1990
1991
1992
1993
# File 'lib/tk.rb', line 1990

def Tk.tk_pkgconfig_list
  # Tk8.5 feature
  Tk.pkgconfig_list('::tk')
end

.to_backslash_sequence(str) ⇒ Object



2198
2199
2200
# File 'lib/tk.rb', line 2198

def Tk.to_backslash_sequence(str)
  Tk::EncodedString.to_backslash_sequence(str)
end

.toUTF8(str, encoding = nil) ⇒ Object



2173
2174
2175
# File 'lib/tk.rb', line 2173

def Tk.toUTF8(str, encoding = nil)
  _toUTF8(str, encoding)
end

.ungrid(*args) ⇒ Object



2049
2050
2051
# File 'lib/tk.rb', line 2049

def Tk.ungrid(*args)
  TkGrid.forget(*args)
end

.unload_tcllibrary(*args) ⇒ Object



1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
# File 'lib/tk.rb', line 1933

def Tk.unload_tcllibrary(*args)
  if args[-1].kind_of?(Hash)
    keys = _symbolkey2str(args.pop)
    nocomp = (keys['nocomplain'])? '-nocomplain': None
    keeplib = (keys['keeplibrary'])? '-keeplibrary': None
    tk_call('unload', nocomp, keeplib, '--', *args)
  else
    tk_call('unload', *args)
  end
end

.unpack(*args) ⇒ Object



2039
2040
2041
# File 'lib/tk.rb', line 2039

def Tk.unpack(*args)
  TkPack.forget(*args)
end

.unplace(*args) ⇒ Object



2059
2060
2061
# File 'lib/tk.rb', line 2059

def Tk.unplace(*args)
  TkPlace.forget(*args)
end

.update(idle = nil) ⇒ Object



2063
2064
2065
2066
2067
2068
2069
# File 'lib/tk.rb', line 2063

def Tk.update(idle=nil)
  if idle
    tk_call_without_enc('update', 'idletasks')
  else
    tk_call_without_enc('update')
  end
end

.update_idletasksObject



2070
2071
2072
# File 'lib/tk.rb', line 2070

def Tk.update_idletasks
  update(true)
end

.UTF8_String(str) ⇒ Object



195
# File 'lib/tk/autoload.rb', line 195

def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end

.utf_to_backslash(str) ⇒ Object



2195
2196
2197
# File 'lib/tk.rb', line 2195

def Tk.utf_to_backslash(str)
  Tk::EncodedString.utf_to_backslash_sequence(str)
end

.utf_to_backslash_sequence(str) ⇒ Object



2192
2193
2194
# File 'lib/tk.rb', line 2192

def Tk.utf_to_backslash_sequence(str)
  Tk::EncodedString.utf_to_backslash_sequence(str)
end

Instance Method Details

#encodingObject



39
40
41
# File 'sample/demos-en/tkencoding.rb', line 39

def encoding
  INTERP.encoding
end

#encoding=(name) ⇒ Object



35
36
37
# File 'sample/demos-en/tkencoding.rb', line 35

def encoding=(name)
  INTERP.encoding = name
end

#rootObject



1916
1917
1918
# File 'lib/tk.rb', line 1916

def root
  TkRoot.new
end

#update(idle = nil) ⇒ Object



2073
2074
2075
2076
2077
# File 'lib/tk.rb', line 2073

def update(idle=nil)
  # only for backward compatibility (This never be recommended to use)
  Tk.update(idle)
  self
end