code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'openssl'
| Ruby |
=begin
= $RCSfile$ -- Ruby-space predefined Cipher subclasses
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: cipher.rb 12496 2007-06-... | Ruby |
=begin
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: bn.rb... | Ruby |
=begin
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=en... | Ruby |
=begin
= $RCSfile$ -- PKCS7
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: digest.rb 12148 2007-04-05 05:59:22Z technorama $
=end
module OpenSSL
class PKCS7
# This class is only provided for backwards compatibility. Use OpenSSL::PKCS7 in the f... | Ruby |
=begin
= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: openss... | Ruby |
=begin
= $RCSfile$ -- Generator for Makefile
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: extconf.rb 32234 2011-06-26 08:58:06Z shy... | Ruby |
begin
require 'win32ole'
rescue LoadError
end
require 'test/unit'
if defined?(WIN32OLE_EVENT)
class TestWIN32OLE_EVENT < Test::Unit::TestCase
def create_temp_html
fso = WIN32OLE.new('Scripting.FileSystemObject')
dummy_file = fso.GetTempName + ".html"
cfolder = fso.getFolder(".")
f = cfo... | Ruby |
require 'win32ole'
def oletypelib_name(pat)
WIN32OLE_TYPE.typelibs.each do |lib|
return lib if pat =~ lib
end
end
module OLESERVER
MS_EXCEL_TYPELIB = oletypelib_name(/^Microsoft Excel .* Object Library$/)
MS_XML_TYPELIB = oletypelib_name(/^Microsoft XML/)
end
| Ruby |
require 'test/unit'
require 'win32ole'
class TestWIN32OLE_PROPERTYPUTREF < Test::Unit::TestCase
def setup
begin
@sapi = WIN32OLE.new('SAPI.SpVoice')
rescue WIN32OLERuntimeError
@sapi = nil
end
end
def test_sapi
if @sapi
new_id = @sapi.getvoices.item(2).Id
@sapi.voice = @sa... | Ruby |
# This is test script to check that WIN32OLE should convert nil to VT_EMPTY in second try.
# [ruby-talk:137054]
require 'win32ole'
require 'test/unit'
class TestNIL2VT_EMPTY < Test::Unit::TestCase
def setup
fs = WIN32OLE.new('Scripting.FileSystemObject')
@path = fs.GetFolder(".").path
end
def test_openS... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'win32ole'
require 'oleserver'
module EXCEL_CONST
end
module CONST1
end
module CONST2
end
module CONST3
end
class TestWin32OLE < RUNIT::TestCase
include OLESERVER
def setup
@e... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLEVARIABLE < RUNIT::TestCase
include OLESERVER
def test_name
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
... | Ruby |
#
# This is test for [ruby-talk:196897]
#
begin
require 'win32ole'
rescue LoadError
end
require "test/unit"
if defined?(WIN32OLE)
class TestWIN32OLE_FOR_PROPERTYPUTREF < Test::Unit::TestCase
def setup
@obj = WIN32OLE.new('Scripting.Dictionary')
end
def test_ole_methods
x = @obj.ole_me... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLETYPE < RUNIT::TestCase
include OLESERVER
def test_s_new
type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
assert_instance_of(WIN32OLE_TYPE, type)
end
def te... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLEPARAM < RUNIT::TestCase
include OLESERVER
def test_name
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
sh = classes.find {|c| c.name == 'Worksheet'}
saveas =... | Ruby |
#
# This is test for [ruby-Bugs#3237]
#
begin
require 'win32ole'
rescue LoadError
end
require "test/unit"
if defined?(WIN32OLE)
class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
def setup
begin
@obj = WIN32OLE.new('Word.Application')
rescue WIN32OLERuntimeError
@obj = nil
... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
class TestWin32OLE_VARIANT < RUNIT::TestCase
include WIN32OLE::VARIANT
def test_variant
assert_equal(2, VT_I2)
assert_equal(3, VT_I4)
assert_equal(4, VT_R4)
assert_equal(5, VT_R8)
assert_eq... | Ruby |
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLEMETHOD < RUNIT::TestCase
include OLESERVER
def setup
@excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
end
def test_s_new
m = WIN32OLE_METHOD.new(@exc... | Ruby |
require 'rubyunit'
require 'win32ole'
puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
# RUNIT::CUI::TestRunner.quiet_mode = true
require "testWIN32OLE"
require "testOLETYPE"
require "testOLEPARAM"
require "testOLEMETHOD"
require "testOLEVARIABLE"
require "testVARIANT"
require "testNIL2VTEMPTY"
require "test_ole_m... | Ruby |
#-----------------------------
# olegen.rb
# $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
# $Revision: 11708 $
#-----------------------------
require 'win32ole'
class WIN32COMGen
def initialize(typelib)
@typelib = typelib
@reciever = ""
end
attr_reader :typelib
def ole_classes(typelib)
b... | Ruby |
require 'win32ole'
url = 'http://www.ruby-lang.org/'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = TRUE
ie.gohome
print "Now navigate Ruby home page... Please enter."
gets
ie.navigate(url)
print "Now quit Internet Explorer... Please enter."
gets
ie.Quit()
| Ruby |
require 'win32ole'
# -4100 is the value for the Excel constant xl3DColumn.
ChartTypeVal = -4100;
# Creates OLE object to Excel
#excel = WIN32OLE.new("excel.application.5")
excel = WIN32OLE.new("excel.application")
# Create and rotate the chart
excel['Visible'] = TRUE;
excel.Workbooks.Add();
excel.Range("a1")['V... | Ruby |
#
# You need WSH(Windows Scripting Host) to run this script.
#
require "win32ole"
def listup(items)
# items.each do |i|
for i in items
puts i.name
end
end
fs = WIN32OLE.new("Scripting.FileSystemObject")
folder = fs.GetFolder(".")
puts "--- folder of #{folder.path} ---"
listup(folder.SubFolders)
puts "--... | Ruby |
require 'win32ole'
#application = WIN32OLE.new('Excel.Application.5')
application = WIN32OLE.new('Excel.Application')
application.visible = TRUE
workbook = application.Workbooks.Add();
sheet = workbook.Worksheets(1);
sheetS = workbook.Worksheets
puts "The number of sheets is #{sheetS.count}"
puts "Now add 2 sheets af... | Ruby |
#
# This file created by olegen.rb as following.
# ruby olegen.rb 'Microsoft XML, version 2.0' > xml.rb
#
require 'win32ole'
require 'win32ole/property'
#
module IXMLDOMImplementation
include WIN32OLE::VARIANT
attr_reader :lastargs
# BOOL hasFeature
# BSTR arg0 --- feature [IN]
# BSTR arg1 --- ver... | Ruby |
require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
=begin
WIN32OLE.const_load(ie)
WIN32OLE.constants.sort.each do |c|
puts "#{c} = #{WIN32OLE.const_get(c)}"
end
=end
module IE_CONST
end
WIN32OLE.const_load(ie, IE_CONST)
IE_CONST.constants.sort.each do |c|
puts "#{c} = #{IE_CONST.const_get(c)}"
... | Ruby |
require 'win32ole'
#application = WIN32OLE.new('Excel.Application.5')
application = WIN32OLE.new('Excel.Application')
application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
worksheet.Range("A1:D1").value = ["North","South","East","West"];
worksheet.Range("A2:B2").value ... | Ruby |
require 'win32ole'
$urls = []
def navigate(url)
$urls << url
end
def stop_msg_loop
puts "Now Stop IE..."
$LOOP = FALSE;
end
def default_handler(event, *args)
case event
when "BeforeNavigate"
puts "Now Navigate #{args[0]}..."
end
end
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = TRU... | Ruby |
# OLEProperty
# helper class of Property with arguments.
class OLEProperty
def initialize(obj, dispid, gettypes, settypes)
@obj = obj
@dispid = dispid
@gettypes = gettypes
@settypes = settypes
end
def [](*args)
@obj._getproperty(@dispid, args, @gettypes)
end
def []=(*args)
@obj._setpro... | Ruby |
#----------------------------------
# extconf.rb
# $Revision: 29867 $
# $Date: 2010-11-22 16:22:26 +0900 (Mon, 22 Nov 2010) $
#----------------------------------
require 'mkmf'
dir_config("win32")
SRCFILES=<<SRC
win32ole.c
SRC
def create_docfile(src)
open(File.expand_path($srcdir) + "/.document", "w") {|ofs|
o... | Ruby |
nul = nil
$:.each_with_index {|path, index|
if /\A(?:\.\/)*-\z/ =~ path
nul = index
break
end
}
if nul
$:[nul..-1] = ["."]
end
| Ruby |
require 'pty'
if ARGV.size == 0 then
ofile = "typescript"
else
ofile = ARGV[0]
end
logfile = File.open(ofile,"a")
system "stty -echo raw lnext ^_"
PTY.spawn("/bin/csh") do |r_pty,w_pty,pid|
Thread.new do
while true
w_pty.print STDIN.getc.chr
w_pty.flush
end
end
begin
while true... | Ruby |
#
# old-fashioned 'shl' like program
# by A. Ito
#
# commands:
# c creates new shell
# C-z suspends shell
# p lists all shell
# 0,1,... choose shell
# q quit
require 'pty'
$shells = []
$n_shells = 0
$r_pty = nil
$w_pty = nil
def writer
system "stty -echo raw"
be... | Ruby |
$expect_verbose = false
class IO
def expect(pat,timeout=9999999)
buf = ''
case pat
when String
e_pat = Regexp.new(Regexp.quote(pat))
when Regexp
e_pat = pat
end
while true
if !IO.select([self],nil,nil,timeout) or eof? then
result = nil
break
end
c... | Ruby |
#
# sample program of expect.rb
#
# by A. Ito
#
# This program reports the latest version of ruby interpreter
# by connecting to ftp server at ruby-lang.org.
#
require 'pty'
require 'expect'
fnames = []
PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
w_f.sync = true
$expect_verbose = false
if !ENV['... | Ruby |
require 'mkmf'
if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM
have_header("sys/stropts.h")
have_func("setresuid")
have_header("libutil.h")
have_header("pty.h")
have_library("util", "openpty")
if have_func("openpty") or
have_func("_getpty") or
have_func("ptsname") or
have_func("ioctl")
c... | 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(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"
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 |
#!/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 |
require 'mkmf'
dir_config('curses')
dir_config('ncurses')
dir_config('termcap')
make=false
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("ncurses", "initscr")
make=true
elsif ... | Ruby |
#!/usr/local/bin/ruby
require "curses"
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)
Curses.init_screen
Curses.nonl
Curses.cbreak
Curses.noecho
$screen = Curses.stdscr
$screen.scrollok(tr... | Ruby |
#!/usr/local/bin/ruby
#
# linear.rb
#
# Solves linear equation system(A*x = b) by LU decomposition method.
# where A is a coefficient matrix,x is an answer vector,b is a constant vector.
#
# USAGE:
# ruby linear.rb [input file solved]
#
require "bigdecimal"
require "bigdecimal/ludcmp"
#
# NOTE:
# Change follow... | Ruby |
#!/usr/local/bin/ruby
#
# pi.rb
#
# Calculates 3.1415.... (the number of times that a circle's diameter
# will fit around the circle) using J. Machin's formula.
#
require "bigdecimal"
require "bigdecimal/math.rb"
include BigMath
if ARGV.size == 1
print "PI("+ARGV[0]+"):\n"
p PI(ARGV[0].to_i)
else
print ... | Ruby |
#!/usr/local/bin/ruby
#
# nlsolve.rb
# An example for solving nonlinear algebraic equation system.
#
require "bigdecimal"
require "bigdecimal/newton"
include Newton
class Function
def initialize()
@zero = BigDecimal::new("0.0")
@one = BigDecimal::new("1.0")
@two = BigDecimal::new("2.0")
@ten = B... | Ruby |
#
# newton.rb
#
# Solves the nonlinear algebraic equation system f = 0 by Newton's method.
# This program is not dependent on BigDecimal.
#
# To call:
# n = nlsolve(f,x)
# where n is the number of iterations required,
# x is the initial value vector
# f is an Object which is used to compute the value... | Ruby |
#
# Solves a*x = b for x, using LU decomposition.
#
module LUSolve
# Performs LU decomposition of the n by n matrix a.
def ludecomp(a,n,zero=0,one=1)
prec = BigDecimal.limit(nil)
ps = []
scales = []
for i in 0...n do # pick up largest(abs. val.) element in each row.
ps <<= i
nrmrow ... | Ruby |
#
# require 'bigdecimal/jacobian'
#
# Provides methods to compute the Jacobian matrix of a set of equations at a
# point x. In the methods below:
#
# f is an Object which is used to compute the Jacobian matrix of the equations.
# It must provide the following methods:
#
# f.values(x):: returns the values of all functio... | Ruby |
#
# BigDecimal utility library.
#
# To use these functions, require 'bigdecimal/util'
#
# The following methods are provided to convert other types to BigDecimals:
#
# String#to_d -> BigDecimal
# Float#to_d -> BigDecimal
# Rational#to_d -> BigDecimal
#
# The following method is provided to convert BigDecimals to ... | Ruby |
#
#--
# Contents:
# sqrt(x, prec)
# sin (x, prec)
# cos (x, prec)
# atan(x, prec) Note: |x|<1, x=0.9999 may not converge.
# exp (x, prec)
# log (x, prec)
# PI (prec)
# E (prec) == exp(1.0,prec)
#
# where:
# x ... BigDecimal number to be computed.
# |x| must be small enough to get con... | Ruby |
require 'mkmf'
base_fig = 0
src = "(BASE * (BASE+1)) / BASE == (BASE+1)"
while try_static_assert(src, nil, "-DBASE=10#{'0'*base_fig}UL")
base_fig += 1
end
$defs << "-DBASE=1#{'0'*base_fig}UL" << "-DBASE_FIG=#{base_fig}"
create_makefile('bigdecimal')
| Ruby |
unless defined? Thread
fail "Thread not available for this ruby interpreter"
end
require 'thread.so'
| Ruby |
require 'mkmf'
enable_config('fastthread', true) or exit
if with_config('mem-pools', true)
$CPPFLAGS << ' -DUSE_MEM_POOLS'
end
create_makefile("thread")
| Ruby |
#
# tkballoonhelp.rb : simple balloon help widget
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
# Add a balloon help to a widget.
# This widget has only poor featureas. If you need more useful features,
# please try to use the Tix extension of Tcl/Tk under Ruby/Tk.
#
# The interval time to di... | 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 |
#!/usr/bin/env ruby
#
# This script generates a directory browser, which lists the working
# directory and allows you to open files or subdirectories by
# double-clicking.
# Create a scrollbar on the right side of the main window and a listbox
# on the left side.
require "tkscrollbox"
# The procedure below is invoke... | Ruby |
#!/usr/bin/env ruby
require 'tk'
TkLabel.new(:text=><<EOT, :justify=>:left).pack
This is a sample of bindtags and usage of
Tk.callback_break/Tk.callback_continue.
Please check the work of following buttons
(attend the difference between before/after
pressing the bottom button), and see the
source code.
EOT
def ... | Ruby |
#
# tkmulticolumnlist.rb : multiple column list widget on scrollable frame
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
class TkMultiColumnList < TkText
include TkComposite
# lbox_height : height of listboxes (pixel)
# title_info : array [ [<title_string>,<init_width>... | 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 = ... | Ruby |
#! /usr/local/bin/ruby
require "tk"
def drawlines()
print Time.now, "\n"
for j in 0 .. 99
print "*"
$stdout.flush
if (j & 1) != 0
col = "blue"
else
col = "red"
end
for i in 0 .. 99
# $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
end
end
print Time.now, "\n"
... | Ruby |
#! /usr/local/bin/ruby
require "tk"
def drawlines()
print Time.now, "\n"
for j in 0 .. 99
print "*"
$stdout.flush
if (j & 1) != 0
col = "blue"
else
col = "red"
end
for i in 0 .. 99
# TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
end
end
print Time.now, "\n"
... | Ruby |
#! /usr/local/bin/ruby
require "tcltk"
def drawlines()
print Time.now, "\n"
for j in 0 .. 99
print "*"
$stdout.flush
if (j & 1) != 0
col = "blue"
else
col = "red"
end
for i in 0 .. 99
# $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
end
end
print Time.now, "... | Ruby |
#! /usr/local/bin/ruby
require "tk"
def drawlines()
print Time.now, "\n"
for j in 0 .. 99
print "*"
$stdout.flush
if (j & 1) != 0
col = "blue"
else
col = "red"
end
for i in 0 .. 99
# TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fi... | Ruby |
#!/usr/bin/env ruby
require 'tcltklib'
master = TclTkIp.new
slave_name = 'slave0'
slave = master.create_slave(slave_name, true)
master._eval("::safe::interpInit #{slave_name}")
master._eval("::safe::loadTk #{slave_name}")
master._invoke('label', '.l1', '-text', 'master')
master._invoke('pack', '.l1', '-padx', '30', '... | Ruby |
#!/usr/bin/env ruby
require 'multi-tk'
TkMessage.new(:text => <<EOM).pack
This is a sample of the safe-Tk slave interpreter. \
On the slave interpreter, 'tkoptdb.rb' demo is running.
( NOTE:: a safe-Tk interpreter can't read options \
from a file. Options are given by the master interpreter \
in this script. )
The wi... | 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 |
#
# 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
# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
require "tk"
root = TkRoot.new(:title=>'realtime timer sample')
f1 = TkFrame.new(:borderwidth=>2, :relief=>:ridge)
f1.pack(:side=>:bottom, :fill=>:both)
TkLabel.new(f1, :text=>'use TkTimer (TkAfter) class').pack(:anch... | Ruby |
require 'tk'
TkMessage.new(:width=>400, :text=><<EOM).pack
This sample shows how to use Tk::EncodedString class. \
This reads 'iso2022-kr' text (from discription of \
Korean language environment of GNU Emacs 20.7.2) \
and inserts the text into the text widget.
EOM
t1 = TkText.new(:height=>5).pack
t2 = TkText.new(:hei... | Ruby |
#
# Editable_TkListbox class
#
# When "DoubleClick-1" on a listbox item, the entry box is opend on the
# item. And when hit "Return" key on the entry box after modifying the
# text, the entry box is closed and the item is changed. Or when hit
# "Escape" key, the entry box is closed without modification.
#
# ... | Ruby |
#!/usr/bin/env ruby
require 'tk'
demo_dir = File.dirname($0)
msgcat_dir = [demo_dir, 'msgs_rb'].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.inst... | Ruby |
#!/usr/bin/env ruby
# square --
# This script generates a demo application containing only
# a "square" widget. It's only usable if Tk has been compiled
# with tkSquare.c and with the -DSQUARE_DEMO compiler switch.
# This demo arranges the following bindings for the widget:
#
# Button-1 press/drag: moves... | Ruby |
#!/usr/bin/env ruby
#
# timer --
# This script generates a counter with start,stop and reset buttons.
#
# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp)
# last update: Sat Jun 27 12:24:14 JST 1998
#
require "tk"
require "thread"
require "tkafter"
$time = "0.00"
$m = Mutex.new
$loop = false
def timer_stop
... | Ruby |
#!/usr/bin/env ruby
#
# rolodex --
# This script is a part of Tom LaStrange's rolodex
#
# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
# Time-stamp: "03/08/02 12:45:21 nagai"
#
require "tk"
def show_help(topic,x=0,y=0)
if( topic.is_a?(TkWindow) )
w = TkWinfo.containing(x,y)
if( TkWinfo.exist... | Ruby |
#!/usr/bin/env ruby
# ixset --
# A nice interface to "xset" to change X server settings
#
require 'tk'
class Xsettings
#
# Button actions
#
def quit
@root.destroy
end
def ok
writesettings
quit
end
def cancel
readsettings
dispsettings
end
# apply is just "writesettings"
... | Ruby |
#!/usr/bin/env ruby
# browse --
# This script generates a directory browser, which lists the working
# directory and allow you to open files or subdirectories by
# double-clicking.
require 'tk'
# Create a scrollbar on the right side of the main window and a listbox
# on the left side.
listbox = TkListbox.new(ni... | Ruby |
#!/usr/bin/env ruby
# browse --
# This script generates a directory browser, which lists the working
# directory and allow you to open files or subdirectories by
# double-clicking.
require 'tk'
class Browse
BROWSE_WIN_COUNTER = TkVariable.new(0)
def initialize(dir)
BROWSE_WIN_COUNTER.value = BROWSE_WIN_C... | Ruby |
#!/usr/bin/env ruby
# rmt --
# This script implements a simple remote-control mechanism for
# Tk applications. It allows you to select an application and
# then type commands to that application.
require 'tk'
class Rmt
def initialize(parent=nil)
win = self
unless parent
parent = TkRoot.new
... | Ruby |
#!/usr/bin/env ruby
require "tk"
root = TkFrame.new
top = TkFrame.new(root) {
relief 'raised'
border 1
}
msg = TkMessage.new(top) {
text "File main.c hasn't been saved to disk since \
it was last modified. What should I do?"
justify 'center'
aspect 200
font '-Adobe-helvetica-medium-r-normal--*-240*'
pa... | 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 Ma... | 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' ... | 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 |
#!/usr/bin/env ruby
#
# TkTextIO class :: handling I/O stream on a TkText widget
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
# NOTE: TkTextIO supports 'character' (not 'byte') access only.
# So, for example, TkTextIO#getc returns a character, TkTextIO#pos
# means the ch... | Ruby |
#!/usr/local/bin/ruby
#
# irbtk.rb - irb with Ruby/Tk
#
# If you want to use 'multi-tk.rb', give option '--multi-tk'.
# And if you want to use 'remote-tk.rb', give option '--remote-tk'.
# If you want both, you don't need to give both options, because
# 'remote-tk.rb' includes 'multi-tk.rb'.
# ( There is n... | Ruby |
require "tkclass"
$tkline_init = FALSE
def start_random
return if $tkline_init
$tkline_init = TRUE
if defined? Thread
Thread.start do
loop do
sleep 2
Line.new($c, rand(400), rand(200), rand(400), rand(200))
end
end
end
end
Label.new('text'=>'Please press or drag button-1')... | 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
require 'remote-tk'
# start sub-process
ip_name = 'remote_ip'
ip_list = TkWinfo.interps
fork{
exec "/usr/bin/env ruby -r tk -e \"Tk.appname('#{ip_name}');Tk.mainloop\""
}
sleep 1 until (app = (TkWinfo.interps - ip_list)[0]) && app =~ /^#{ip_name}/
p TkWinfo.interps
# create RemoteTkIp object
ip... | Ruby |
#!/usr/bin/env ruby
# This script is a sample of MultiTkIp class
require "multi-tk"
###############################
TkLabel.new(:text=>'This is the Default Master Ipnterpreter').pack(:padx=>5, :pady=>3)
TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack(:pady=>3)
TkFrame.new(:borderwidth=>2, :height=>3,
... | 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 |
#!/usr/bin/env ruby
#
# menubutton sample : based on sample menubuttons on the Tcl/Tk demo script
#
require 'tk'
TkLabel.new(:text=>'Sample of TkMenubutton').pack(:side=>:top)
TkFrame.new{|f|
pack(:side=>:top)
TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
:direction=>:right, ... | 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 ... | Ruby |
require 'tk'
v = TkVariable.new(0)
l = TkLabel.new(:textvariable=>v).pack(:pady=>[1, 10])
a = TkButton.new(:text=>"button A :: proc{p ['AAA', v.value]}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
a.command{p ['AAA', v.value]}
TkLabel.new(:text=>'Callback of the button B returns LIFO order').pack
b = TkButton.new(:t... | Ruby |
#
# Tk::ScrollFrame class
#
# This widget class is a frame widget with scrollbars.
# The ScrollFrame doesn't propagate the size of embedded widgets.
# When it is configured, scrollregion of the container is changed.
#
# Scrollbars can be toggled by Tk::ScrollFrame#vscroll & hscroll.
# If horizontal or v... | Ruby |
#!/usr/bin/env ruby
require "tk"
TkMessage.new(:width=>360, :text=><<EOM).pack
This sample shows how to use a binary sequence between Ruby and Tk. \
This reads the image data from the file as the binary sequence.
To treat the difference of encodings between on Ruby and on Tk seamlessly, \
Ruby/Tk converts the encodi... | Ruby |
#!/usr/bin/env ruby
require 'tk'
demo_dir = File.dirname($0)
msgcat_dir = [demo_dir, 'msgs_tk'].join(File::Separator)
top_win = nil
#msgcat = TkMsgCatalog.new('::tk')
msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
default_locale = msgcat.locale
msgcat.load_tk(msgcat_dir)
col_proc = TkComm.install_bind(proc{|w, color, ... | Ruby |
require "tk"
TkButton.new(nil,
:text => 'hello',
:command => proc{print "hello\n"}).pack(:fill=>'x')
TkButton.new(nil,
:text => 'quit',
:command => proc{exit}).pack(:fill=>'x')
Tk.mainloop
| Ruby |
#!/usr/bin/env ruby
#
# sample script of Tk::OptionObj
#
require "tk"
optobj = Tk::OptionObj.new('foreground'=>'red', 'background'=>'black')
f = TkFrame.new.pack(:side=>:left, :anchor=>:n, :padx=>5, :pady=>30)
b1 = TkButton.new(f, :text=>'AAA').pack(:fill=>:x)
b2 = TkButton.new(f, :text=>'BBB').pack(:fill=>:x)
b3 =... | 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 |
require 'tk'
class Button_with_Frame < TkButton
def create_self(keys)
@frame = TkFrame.new('widgetname'=>@path, 'background'=>'yellow')
install_win(@path) # create new @path which is a daughter of old @path
super(keys)
TkPack(@path, :padx=>7, :pady=>7)
@epath = @frame.path
end
def epath
@... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.