code
stringlengths
1
1.73M
language
stringclasses
1 value
# -*- ruby -*- # for backward compatibility warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use dl directly instead" if $VERBOSE require 'dl' class Win32API DLL = {} TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG} def initialize(dllname, ...
Ruby
=begin = Win32 DNS and DHCP I/F =end require "dl/import" require 'win32/registry' module Win32 module Resolv API = Registry::API def self.get_hosts_path path = get_hosts_dir path = File.expand_path('hosts', path) File.exist?(path) ? path : nil end def self.get_resolv_info ...
Ruby
require 'dl/import' module Win32 =begin rdoc = Win32 Registry win32/registry is registry accessor library for Win32 platform. It uses dl/import to call Win32 Registry APIs. == example Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg| value = reg['foo'] # read a valu...
Ruby
# # = win32/sspi.rb # # Copyright (c) 2006-2007 Justin Bailey # # Written and maintained by Justin Bailey <jgbailey@gmail.com>. # # This program is free software. You can re-distribute and/or # modify this program under the same terms of ruby itself --- # Ruby Distribution License or GNU General Public License. # requ...
Ruby
if compiled?('dl') and $mswin||$bccwin||$mingw||$cygwin create_makefile('win32') end
Ruby
#!ruby -s $output ||= "callback" $out = open("#{$output}.c", "w") $dl_h = ARGV[0] || "dl.h" # import DLSTACK_SIZE, DLSTACK_ARGS and so on File.open($dl_h){|f| pre = "" f.each{|line| line.chop! if( line[-1] == ?\\ ) line.chop! line.concat(" ") pre += line next end if( pre.si...
Ruby
require 'mkmf' if compiled?("dl") callbacks = (0..8).map{|i| "callback-#{i}"}.unshift("callback") callback_srcs = callbacks.map{|basename| "#{basename}.c"} callback_objs = callbacks.map{|basename| "#{basename}.o"} $distcleanfiles << '$(SRCS)' $srcs = callback_srcs $objs = callback_objs $INCFLAGS << " -I...
Ruby
require 'dl.so' begin require 'fiddle' unless Object.const_defined?(:Fiddle) rescue LoadError end module DL def self.fiddle? Object.const_defined?(:Fiddle) end end
Ruby
require 'dl' require 'dl/pack.rb' module DL class CStruct def CStruct.entity_class() CStructEntity end end class CUnion def CUnion.entity_class() CUnionEntity end end module CStructBuilder def create(klass, types, members) new_class = Class.new(klass){ define_m...
Ruby
require 'dl' module DL module PackInfo ALIGN_MAP = { TYPE_VOIDP => ALIGN_VOIDP, TYPE_CHAR => ALIGN_CHAR, TYPE_SHORT => ALIGN_SHORT, TYPE_INT => ALIGN_INT, TYPE_LONG => ALIGN_LONG, TYPE_FLOAT => ALIGN_FLOAT, TYPE_DOUBLE => ALIGN_DOUBLE, -TYPE_CHAR => ALIGN_CHAR...
Ruby
require 'dl' require 'dl/func.rb' require 'dl/struct.rb' require 'dl/cparser.rb' module DL class CompositeHandler def initialize(handlers) @handlers = handlers end def handlers() @handlers end def sym(symbol) @handlers.each{|handle| if( handle ) begin ...
Ruby
require 'dl' require 'dl/callback' require 'dl/stack' require 'dl/value' require 'thread' module DL parent = DL.fiddle? ? Fiddle::Function : Object class Function < parent include DL include ValueUtil def initialize cfunc, argtypes, abi = nil, &block if DL.fiddle? abi ||= Fiddle::Functi...
Ruby
require 'dl' module DL module ValueUtil def unsigned_value(val, ty) case ty.abs when TYPE_CHAR [val].pack("c").unpack("C")[0] when TYPE_SHORT [val].pack("s!").unpack("S!")[0] when TYPE_INT [val].pack("i!").unpack("I!")[0] when TYPE_LONG [val].pack("l!...
Ruby
module DL module CParser def parse_struct_signature(signature, tymap=nil) if( signature.is_a?(String) ) signature = signature.split(/\s*,\s*/) end mems = [] tys = [] signature.each{|msig| tks = msig.split(/\s+(\*)?/) ty = tks[0..-2].join(" ") member =...
Ruby
module DL # Adds Windows type aliases to the including class for use with # DL::Importer. # # The aliases added are: # * ATOM # * BOOL # * BYTE # * DWORD # * DWORD32 # * DWORD64 # * HANDLE # * HDC # * HINSTANCE # * HWND # * LPCSTR # * LPSTR # * PBYTE # * PDWORD # * PHANDLE # * PV...
Ruby
require 'dl' module DL class Stack def self.[](*types) new(types) end def initialize(types) parse_types(types) end def size() @size end def types() @types end def pack(ary) case SIZEOF_VOIDP when SIZEOF_LONG ary.pack(@template).unpac...
Ruby
require 'dl' require 'thread' module DL # The mutual exclusion (Mutex) semaphore for the DL module SEM = Mutex.new # :nodoc: if DL.fiddle? # A Hash of callback Procs # # Uses Fiddle CdeclCallbackProcs = {} # :nodoc: # A Hash of the addresses of callback Proc # # Uses Fiddle Cdecl...
Ruby
require 'mkmf' if RbConfig::CONFIG['GCC'] == 'yes' $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer" end $INSTALLFILES = [ ["dl.h", "$(HDRDIR)"], ] check = true if( have_header("dlfcn.h") ) have_library("dl") check &&= have_func("dlopen") check &&= have_func("dlclose") check &&= have_func("dlsym") h...
Ruby
# # extconf.rb # # $Id: extconf.rb 37561 2012-11-08 08:34:18Z usa $ # require 'mkmf' require 'rbconfig' dir_config 'zlib' if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset')} and have_header('zlib.h') then defines = [] message 'checking for kind of operating system... ' os_c...
Ruby
# date.rb: Written by Tadayoshi Funaba 1998-2011 require 'date_core' require 'date/format' class Date class Infinity < Numeric # :nodoc: include Comparable def initialize(d=1) @d = d <=> 0 end def d() @d end protected :d def zero? () false end def finite? () false end def infinite?...
Ruby
# format.rb: Written by Tadayoshi Funaba 1999-2011
Ruby
require 'mkmf' create_makefile('date_core')
Ruby
$expect_verbose = false class IO # Reads from the IO until pattern +pat+ matches or the +timeout+ is over. # It returns an array with the read buffer, followed by the matches. # If a block is given, the result is yielded to the block and returns nil. # # The optional timeout parameter defines, in seconds, th...
Ruby
require 'mkmf' if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM have_header("sys/stropts.h") have_func("setresuid") have_header("libutil.h") have_header("util.h") # OpenBSD openpty have_header("pty.h") have_library("util", "openpty") if have_func("posix_openpt") or have_func("openpty") or have_func("...
Ruby
# # = pathname.rb # # Object-Oriented Pathname Class # # Author:: Tanaka Akira <akr@m17n.org> # Documentation:: Author and Gavin Sinclair # # For documentation, see class Pathname. # # <tt>pathname.rb</tt> is distributed with Ruby since 1.8.0. # require 'pathname.so' class Pathname # :stopdoc: if RUBY_VERSION < ...
Ruby
require 'mkmf' create_makefile('pathname')
Ruby
require 'mkmf' create_makefile 'strscan'
Ruby
#!/usr/local/bin/ruby require "curses" include Curses def show_message(message) width = message.length + 6 win = Window.new(5, width, (lines - 5) / 2, (cols - width) / 2) win.box(?|, ?-) win.setpos(2, 3) win.addstr(message) win.refresh win.getch win.close end init_screen begin crmode # show_m...
Ruby
#!/usr/local/bin/ruby require "curses" # A curses based file viewer class FileViewer # Create a new fileviewer, and view the file. def initialize(filename) @data_lines = [] @screen = nil @top = nil init_curses load_file(filename) interact end # Perform the curses setup def init_cu...
Ruby
#!/usr/local/bin/ruby # rain for a curses test require "curses" include Curses def onsig(sig) close_screen exit sig end def ranf rand(32767).to_f / 32767 end # main # for i in 1 .. 15 # SIGHUP .. SIGTERM if trap(i, "SIG_IGN") != 0 then # 0 for SIG_IGN trap(i) {|sig| onsig(sig) } end end init_screen...
Ruby
#!/usr/local/bin/ruby require "curses" include Curses # # main # if ARGV.size != 1 then printf("usage: view file\n"); exit end begin fp = open(ARGV[0], "r") rescue raise "cannot open file: #{ARGV[1]}" end # signal(SIGINT, finish) init_screen #keypad(stdscr, TRUE) nonl cbreak noecho #scrollok(stdscr, TRUE) ...
Ruby
#!/usr/local/bin/ruby require "curses" include Curses def show_message(*msgs) message = msgs.join width = message.length + 6 win = Window.new(5, width, (lines - 5) / 2, (cols - width) / 2) win.keypad = true win.attron(color_pair(COLOR_RED)){ win.box(?|, ?-, ?+) } win.setpos(2, 3) win.addstr(m...
Ruby
require 'mkmf' dir_config('curses') dir_config('ncurses') dir_config('termcap') make=false headers = [] have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM have_library("tinfo", "tgetent") or have_library("termcap", "tgetent") if have_header(*curses=%w"ncurses.h") and (have_library("ncursesw", "initscr") or...
Ruby
#! /usr/bin/ruby require 'rbconfig' require 'optparse' # http://www.ctan.org/get/macros/texinfo/texinfo/gnulib/lib/config.charset # Tue, 25 Dec 2007 00:00:00 GMT HEADER = <<SRC require 'iconv.so' class Iconv case RUBY_PLATFORM SRC def charset_alias(config_charset, mapfile = nil) found = nil src = [HEADER] o...
Ruby
#! /usr/bin/ruby # :stopdoc: require 'rbconfig' require 'optparse' # http://www.ctan.org/get/macros/texinfo/texinfo/gnulib/lib/config.charset # Tue, 25 Dec 2007 00:00:00 GMT OS = RbConfig::CONFIG["target_os"] SHELL = RbConfig::CONFIG['SHELL'] class Hash::Ordered < Hash def [](key) val = super and val.last en...
Ruby
require 'mkmf' dir_config("iconv") conf = File.exist?(File.join($srcdir, "config.charset")) conf = with_config("config-charset", enable_config("config-charset", conf)) if have_func("iconv", "iconv.h") or have_library("iconv", "iconv", "iconv.h") check_signedness("size_t") if checking_for("const of iconv() 2n...
Ruby
require 'mkmf' create_makefile('fcntl')
Ruby
# extconf.rb for tcltklib require 'mkmf' is_win32 = (/mswin|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM) #is_macosx = (/darwin/ =~ RUBY_PLATFORM) have_func("ruby_native_thread_p", "ruby.h") have_func("rb_errinfo", "ruby.h") have_func("rb_safe_level", "ruby.h") have_struct_member("struct RArray", "ptr", "ruby.h") have_stru...
Ruby
begin has_tk = compiled?('tk') rescue NoMethodError # Probably, called manually (NOT from 'extmk.rb'). Force to make Makefile. has_tk = true end if has_tk require 'mkmf' have_func("rb_obj_instance_exec", "ruby.h") have_func("rb_obj_untrust", "ruby.h") have_func("rb_obj_taint", "ruby.h") have_func("rb_...
Ruby
#!/usr/bin/env ruby # This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class. require "tk" # new notation : # * symbols are acceptable as keys or values of the option hash # * the parent widget can be given by :parent key on the option hash root = TkRoot.new(:title=>'timer sample') label = T...
Ruby
#!/usr/bin/env ruby # # irbtkw.rb : IRB console with Ruby/Tk # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # release = '2008/03/08' require 'tk' begin require 'tktextio' rescue LoadError require File.join(File.dirname(File.expand_path(__FILE__)), 'tktextio.rb') end require 'irb'...
Ruby
# # tkalignbox.rb : align widgets with same width/height # # by Hidetoshi NAGAI # # The box size depends on 'reqheight' and 'reqwidth' of contained widgets. # If you want to give the box size when those requested sizes are 0, # please set box.propagate = false (See the tes...
Ruby
require 'multi-tk.rb' th = Thread.new{Tk.mainloop} TkLabel.new(:text=>'this is a primary master').pack ip1 = MultiTkIp.new_slave(:safe=>1) ip2 = MultiTkIp.new_slave(:safe=>2) cmd = proc{|s| require 'tk' TkButton.new(:text=>'b1: p self', :command=>proc{p self}).pack(:fill=>:x) sleep s TkButton.new(:text=>'b...
Ruby
# # tkmultilistbox.rb : multiple listbox widget # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' class TkMultiListbox < TkListbox include TkComposite # lbox_height : height of listboxes (pixel) # title_info : array [ [<title_string>,<init_width>], ... ] # keys :...
Ruby
########################################################################## # TkTree widget class # # see <http://wiki.tcl.tk/10615> # # Note: optional argument '-font' of the Tcl library is changed to # 'itemfont' on this Ruby library, because of avoiding font # operation trouble in 'initialize' me...
Ruby
#!/usr/bin/env ruby require 'tk' class Button_clone < TkLabel def initialize(*args) @command = nil if args[-1].kind_of?(Hash) keys = _symbolkey2str(args.pop) @command = keys.delete('command') keys['highlightthickness'] = 1 unless keys.key?('highlightthickness') keys['padx'] = '3m' ...
Ruby
#!/usr/bin/env ruby # # ttk_wrapper.rb -- use Ttk widgets as default on old Ruby/Tk scripts # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # version = '0.1.3' # ########################################################################## # parse commandline arguments ###########################...
Ruby
#!/usr/bin/env ruby if ARGV[0] != '-d' unless $DEBUG exit if fork end else ARGV.shift end if ARGV.length == 0 if ENV['MAIL'] $spool = ENV['MAIL'] else $spool = '/var/spool/mail/' + ENV['USER'] end else $spool = ARGV[0] end require "parsedate" require "base64" include ParseDate class Mail ...
Ruby
#!/usr/bin/env ruby require 'tk' TkLabel.new(:text=>"Please click the bottom frame").pack f = TkFrame.new(:width=>400, :height=>100, :background=>'yellow', :relief=>'ridge', :borderwidth=>5).pack # TkPack.propagate(f, false) # <== important!! f.pack_propagate(false) # <== important!! list = (1....
Ruby
# # tkcombobox.rb : auto scrollbox & combobox # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' module Tk module RbWidget class AutoScrollListbox < TkListbox end class Combobox < TkEntry end end end class Tk::RbWidget::AutoScrollListbox include TkComposite ...
Ruby
# # menubar sample 1 : use frame and menubuttons # require 'tk' radio_var = TkVariable.new('y') menu_spec = [ [['File', 0], {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0}, '---', ['Check_A', TkVariable.new(true), 6], {:type=>'checkbutton', :label=>'Check_B', :...
Ruby
#!/usr/bin/env ruby require 'tk' demo_dir = File.dirname($0) msgcat_dir = [demo_dir, 'msgs_rb2'].join(File::Separator) top_win = nil #msgcat = TkMsgCatalog.new('::tk') msgcat = TkMsgCatalog.new('::tkmsgcat_demo') default_locale = msgcat.locale #msgcat.load_rb(msgcat_dir) msgcat.load(msgcat_dir) col_proc = TkComm.ins...
Ruby
# # tkmultilistframe.rb : multiple listbox widget on scrollable frame # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' class TkMultiListFrame < TkListbox include TkComposite # lbox_height : height of listboxes (pixel) # title_info : array [ [<title_string>,<init_width>], ....
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' ####################################### c = TkCanvas.new.pack begin st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) rescue Tk.messageBox(:type=>'ok', :title=>"No sticker Item", :message=>"This build of vu does not include the sticker ite...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu' ####################################### puts "Show off barchart and dial widgets" speed = TkVariable.new(0) dial = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1, :showvalue=>true, :minortickinterval=>0.01, ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/dial' ####################################### v_volume = TkVariable.new v_speed = TkVariable.new v_dir = TkVariable.new v_rot = TkVariable.new v_linked = TkVariable.new v_needle = TkVariable.new volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' ####################################### xbm = File.join(File.dirname(File.expand_path(__FILE__)), 'm128_000.xbm') sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ] l0 = TkLabel.new(:width=>128, :height=>128, :bitmap=>"@#{xbm}", :relief=>:gr...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' ####################################### Tk.root.geometry('+30+30') delay = 2000 c = TkCanvas.new.pack begin st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10) rescue Tk.messageBox(:type=>'ok', :title=>"No sticker Item", :message=>"This bu...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/pie' pie = Tk::Vu::Pie.new(:label=>"My Revolving Budget"){ itemconfigure('Welfare', :value=>3.004) itemconfigure('Military', :value=>7.006) itemconfigure('Transport', :value=>1.6, :explode=>15) itemconfigure('Parks', :value=>0.9) itemconfigure('Sc...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' #---USAGE info = "...the heart of a Realtime Oscilloscope, where the PCIs joystick port gives 4 digtal inputs and 4 analog 8 bit values with an resolution of ~1 millisecond (!!!) running Realtime Linux. <p> creates DEMO.ps <B1-Motion> see what happens" put...
Ruby
# # Demo: Bitmaps # def demoBitmaps(t) #if $Version_1_1_OrLater if @has_bgimg t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items', :showheader=>false, :backgroundimage=>@images['sky']) else t.con...
Ruby
# # Demo: MailWasher # def demoMailWasher(t) init_pics('*checked') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:showroot=>false, :showrootbutton=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse, :xscrollinc...
Ruby
# # Demo: Outlook Express folder list # def demoOutlookFolders(t) init_pics('outlook-*') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>true, :showroot=>true, :showrootbutton=>false, :showbuttons=>true) if ...
Ruby
# # Demo: Help contents # def demoHelpContents(t) height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('help-*') if $Version_1_1_OrLater t.column_create(:tex...
Ruby
# # Demo: Outlook Express newsgroup messages # def demoOutlookNewsgroup(t) init_pics('outlook-*') height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false, :showroot=>false, :showrootbutton=>false, :showbuttons=>true) ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/treectrl' $ScriptDir = File.dirname(File.expand_path(__FILE__)) $HasColumnCreate = Tk::TreeCtrl::HasColumnCreateCommand $Version_1_1_OrLater = (TkPackage.vcompare(Tk::TreeCtrl.package_version, '1.1') >= 0) #if Hash.instance_methods.include?(:key) if TkCore::WITH_R...
Ruby
def demoInternetOptions (t) @Option = TkVarAccess.new_hash('::Option') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('internet-*') if $HasColumnCre...
Ruby
# # Demo: iMovie # def demoIMovie(t) t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :selectmode=>:browse, :orient=>:horizontal, :wrap=>:window, :showheader=>false, :background=>'#dcdcdc') if $HasColumnCreate t.column_create end init_pics('imovie-*') ca...
Ruby
def demoExplorerAux(t, dir_proc, file_proc) base_dir = File.dirname(File.dirname(@ScriptDir)) clicks = Tk::Clock.clicks globDirs = Dir.glob(File.join(base_dir, '*')).find_all{|file| FileTest.directory?(file) } clickGlobDirs = Tk::Clock.clicks - clicks clicks = Tk::Clock.clicks list = globDirs.sort ...
Ruby
# # Demo: Layout # def demoLayout(t) t.configure(:showroot=>false, :showrootbutton=>true, :showbuttons=>true, :showlines=>true, :itemheight=>0, :selectmode=>:browse) if $HasColumnCreate t.column_create(:text=>'Layout') else t.column_configure(0, :text=>'Layout') end t.element_create('e...
Ruby
# def random_N @RandomN[0] || 500 end # # Demo: random N items # def demoRandom(t) init_pics('folder-*', 'small-*') height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:extended, :showroot=>true, :showrootbutton=>true, :showbuttons=>true...
Ruby
#!/usr/bin/env ruby # # viewIcons.rb # # -- Display icons from icon library. # # -- Copy the clicked icon data (command string of creating # a TkPhotoImage instance) to the clipboard. # require 'tk' require 'tkextlib/ICONS' class ViewIcons ##################################### private #######...
Ruby
#!/usr/bin/env ruby ## ## debug.rb ## ## This demo uses most features of the table widget ## ## ( based on 'debug.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table ary = TkVariable.new_hash rows = 25 cols = 20 # fill table variable ((-(rows))..rows).eac...
Ruby
#!/usr/bin/env ruby ## ## basic.rb ## ## This demo shows the basic use of the table widget ## ## ( based on 'basic.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' ary = TkVariable.new_hash rows = 8 cols = 8 # fill table variable ((-(rows))..rows).each{|x| ((-(cols)).....
Ruby
#!/usr/bin/env ruby ## ## spreadsheet.rb ## ## This demos shows how you can simulate a 3D table ## and has other basic features to begin a basic spreadsheet ## ## ( based on 'spreadsheet.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' rows = 10 cols = 10 cur_var = TkVaria...
Ruby
#!/usr/bin/env ruby ## ## maxsize.rb ## ## This demo uses a really big table. The big startup time is in ## filling the table's Tcl array var. ## ## ( based on 'maxsize.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' ary = TkVariable.new_hash rows = 40000 cols = 10 # f...
Ruby
#!/usr/bin/env ruby ## ## command.rb ## ## This demo shows the use of the table widget's -command options ## ## ( based on 'command.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table data = TkVariable.new_hash rows = 10 cols = 10 # fill table variable ((-...
Ruby
#!/usr/bin/env ruby ## ## dynarows.rb ## ## This demos shows the use of the validation mechanism of the table ## and uses the table's cache (no -command or -variable) with a cute ## dynamic row routine. ## ## ( based on 'dynarows.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tkta...
Ruby
#!/usr/bin/env ruby ## ## buttons.rb ## ## demonstrates the simulation of a button array ## ## ( based on 'buttons.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table tab = TkVariable.new_hash rows = 20 cols = 20 table = Tk::TkTable.new(:rows=>rows + 1, :...
Ruby
#!/usr/bin/env ruby ## ## valid.rb ## ## This demos shows the use of the validation mechanism of the table ## and uses the table's cache (no -command or -variable) ## ## ( based on 'valid.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' rows = 10 cols = 10 def colorize(nu...
Ruby
#!/usr/bin/env ruby # # Tk::Img demo # # -- This script is based on demo.tcl of Tcl/Tk's 'Img' extention. # Image data in this script is those of demo.tcl. # Please read 'license_terms_of_Img_extension' file. # require 'tk' require 'tkextlib/tkimg' # # Make the Image format available. # class TkImg_...
Ruby
#!/usr/bin/env ruby # # Demo for 'tile' package. # require 'tk' demodir = File.dirname($0) themesdir = File.join(demodir, 'themes') Tk::AUTO_PATH.lappend('.', demodir, themesdir) Dir.foreach(themesdir){|name| next if name == '.' || name == '..' dir = File.join(themesdir, name) Tk::AUTO_PATH.lappend(dir) if File...
Ruby
# # kroc.rb # # based on: # >> kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk> # imgdir = File.join(File.dirname(__FILE__), 'kroc', 'kroc') $images = Tk::Tile.load_images(imgdir, '*.gif') if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0 $TNotebook_Tab = Tk::Tile::TNotebook.style('Tab') else ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} TkButton.new(:text=>'QUIT', :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10) Tk::Iwidgets::Selectiondialog.new.activate mainloop.join
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb| pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) TkTimer.new(500, 20, proc{fb.step}).start(2500) } Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, :side=>:left, :padx=>10, :pady=>10) # Add two pages to the tabnotebook, # labelled "Page On...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' df = Tk::Iwidgets::Datefield.new(:command=>proc{puts(df.get)}) df.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # # Non-editable Dropdown Combobox # cb1 = Tk::Iwidgets::Combobox.new(:labeltext=>'Month:', :selectioncommand=>proc{ puts(cb1.get_curselection) }, ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, :labeltext=>'Messages', :labelpos=>:n, :height=>120, :width=>550, :savedir=>'/tmp', :textbackgroun...
Ruby
#!/usr/bin/env ruby ######################################################### # # set $KCODE to 'utf' for a utf8 charecter # ######################################################### unless defined?(::Encoding.default_external) $KCODE='utf' else DEFAULT_TK_ENCODING = 'UTF-8' end require 'tk' require 'tkextlib/iwi...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180, :labeltext=>'scrolledframe') cs = sf.child_site TkButton.new(cs, :text=>'Hello').pack(:pady=>10) TkButton.new(cs, :text=>'World').pack(:pady=>10) TkButton.n...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} # # Standard question message dialog used for confirmation. # md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog', :text=>'Are you sure ? ', ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' def get_files(file) dir = (file.empty?)? ENV['HOME'] : TkComm._fromUTF8(file) Dir.chdir(dir) rescue return '' Dir['*'].sort.collect{|f| [TkComm._toUTF8(File.join(dir, f)), TkComm._toUTF8(f)] } end Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' ########################################## # icon images editcopy22 = TkPhotoImage.new(:data=><<'EOD') R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxa XMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy 7Pzu5PTm3NTKvIR+fJyGfHxu...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, :labeltext=>'Messages', :labelpos=>:n, :height=>120, :width=>550, :savedir=>'/tmp', :textbackgroun...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' helpvar = TkVariable.new viewmode = TkVariable.new menu_spec = [ [:menubutton, 'file', { :text=>'File', :menu=>[ [:options, {:tearoff=>false}], [:command, 'new', { :label=>'New', :helpstr=>'Open new document', ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Canvasprintdialog.new.activate Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Dateentry.new.pack Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none, :labeltext=>'Password File') st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) st.import('/etc/passwd') Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} # # Non-modal example # nmfsd = Tk::Iwidgets::Extfileselectiondialog.new(:title=>'Non-Modal') nmfsd.buttonconfigure('OK', :command=>proc{ puts "You selected #{nmfsd.get}" nmf...
Ruby