code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# ttkbut.rb
#
# This demonstration script creates a toplevel window containing several
# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and
# radiobuttons.
#
# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
if defined?($ttkbut_demo) && $ttkbut_demo
$ttkbut_demo.destroy
$ttkbut_... | Ruby |
# paned1.rb
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows horizontally.
#
# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned1_demo) && $paned1_demo
$paned1_demo.destroy
$paned1_demo = nil
end
$paned1_demo = TkToplevel.n... | Ruby |
# bind.rb
#
# This demonstration script creates a text widget with bindings set
# up for hypertext-like effects.
#
# text (tag bindings) widget demo (called by 'widget')
#
# toplevel widget
if defined?($bind_demo) && $bind_demo
$bind_demo.destroy
$bind_demo = nil
end
# demo toplevel widget
$bind_demo = TkToplevel... | Ruby |
# bitmap.rb
#
# This demonstration script creates a toplevel window that displays
# all of Tk's built-in bitmaps.#
# bitmap widget demo (called by 'widget')
#
# bitmapRow --
# Create a row of bitmap items in a window.
#
# Arguments:
# w - The parent window that is to contain the row.
# args - The name... | Ruby |
# button.rb
#
# This demonstration script creates a toplevel window containing
# several button widgets.
#
# button widget demo (called by 'widget')
#
# toplevel widget
if defined?($button_demo) && $button_demo
$button_demo.destroy
$button_demo = nil
end
# demo toplevel widget
$button_demo = TkToplevel.new {|w|
... | Ruby |
#
# checkbutton widget demo2 (called by 'widget')
#
# delete old toplevel widget
if defined?($check2_demo) && $check2_demo
$check2_demo.destroy
$check2_demo = nil
end
# create demo toplevel widget
$check2_demo = TkToplevel.new {|w|
title("Checkbutton Demonstration 2")
iconname("check2")
positionWindow(w)
}
... | Ruby |
# states.rb
#
# This demonstration script creates a listbox widget that displays
# the names of the 50 states in the United States of America.
#
# listbox widget demo 'states' (called by 'widget')
#
# toplevel widget
if defined?($states_demo) && $states_demo
$states_demo.destroy
$states_demo = nil
end
# demo topl... | Ruby |
# label.rb
#
# This demonstration script creates a toplevel window containing
# several label widgets.
#
# label widget demo (called by 'widget')
#
# toplevel widget
if defined?($label_demo) && $label_demo
$label_demo.destroy
$label_demo = nil
end
# demo toplevel widget
$label_demo = TkToplevel.new {|w|
title("... | Ruby |
# clrpick.rb
#
# This demonstration script prompts the user to select a color.
#
# widget demo prompts the user to select a color (called by 'widget')
#
# Note: don't support ttk_wrapper. work with standard widgets only.
#
# toplevel widget
if defined?($clrpick_demo) && $clrpick_demo
$clrpick_demo.destroy
$clrpic... | Ruby |
# image3.rb
#
# This demonstration script creates a simple collection of widgets
# that allow you to select and view images in a Tk label.
#
# widget demo 'load image' (called by 'widget')
#
# toplevel widget
if defined?($image3_demo) && $image3_demo
$image3_demo.destroy
$image3_demo = nil
end
# demo toplevel wid... | Ruby |
# ttkmenu.rb --
#
# This demonstration script creates a toplevel window containing several Ttk
# menubutton widgets.
#
# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
if defined?($ttkmenu_demo) && $ttkmenu_demo
$ttkmenu_demo.destroy
$ttkmenu_demo = nil
end
$ttkmenu_demo = TkToplevel.new {|w|
titl... | 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 06:23:06 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 |
# entry3.rb --
#
# This demonstration script creates several entry widgets whose
# permitted input is constrained in some way. It also shows off a
# password entry.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($entry3_demo) && $entry3_demo
$entry3_demo.destroy
$entry3_demo = nil
end
$entry3_demo = TkTopleve... | 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 squ... | Ruby |
# puzzle.rb
#
# This demonstration script creates a 15-puzzle game using a collection
# of buttons.
#
# widet demo 'puzzle' (called by 'widget')
#
# toplevel widget
if defined?($puzzle_demo) && $puzzle_demo
$puzzle_demo.destroy
$puzzle_demo = nil
end
# demo toplevel widget
$puzzle_demo = TkToplevel.new {|w|
tit... | Ruby |
# image2.rb
#
# This demonstration script creates a simple collection of widgets
# that allow you to select and view images in a Tk label.
#
# widget demo 'load image' (called by 'widget')
#
# toplevel widget
if defined?($image2_demo) && $image2_demo
$image2_demo.destroy
$image2_demo = nil
end
# demo toplevel wid... | Ruby |
#
# animated label widget demo (called by 'widget')
#
# based on Tcl/Tk8.5a2 widget demos
if defined?($anilabel_demo) && $anilabel_demo
$anilabel_demo.destroy
$anilabel_demo = nil
end
# demo toplevel widget
$anilabel_demo = TkToplevel.new {|w|
title("Animated Label Demonstration")
iconname("anilabel")
posit... | Ruby |
# items.rb
#
# This demonstration script creates a canvas that displays the
# canvas item types.
#
# canvas item types widget demo (called by 'widget')
#
# toplevel widget
if defined?($items_demo) && $items_demo
$items_demo.destroy
$items_demo = nil
end
# demo toplevel widget
$items_demo = TkToplevel.new {|w|
t... | Ruby |
# ttkpane.rb --
#
# This demonstration script creates a Ttk pane with some content.
#
# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
if defined?($ttkpane_demo) && $ttkpane_demo
$ttkpane_demo.destroy
$ttkpane_demo = nil
end
$ttkpane_demo = TkToplevel.new {|w|
title("Themed Nested Panes")
iconna... | Ruby |
## image1.rb
#
# This demonstration script displays two image widgets.
#
# two image widgets demo (called by 'widget')
#
# toplevel widget
if defined?($image1_demo) && $image1_demo
$image1_demo.destroy
$image1_demo = nil
end
# demo toplevel widget
$image1_demo = TkToplevel.new {|w|
title('Image Demonstration #1... | Ruby |
# text.rb
#
# This demonstration script creates a text widget that describes
# the basic editing functions.
#
# text (basic facilities) widget demo (called by 'widget')
#
# toplevel widget
if defined?($text_demo) && $text_demo
$text_demo.destroy
$text_demo = nil
end
# demo toplevel widget
$text_demo = TkToplevel.... | Ruby |
# -*- ruby -*-
#
# tkencoding.rb
# written by ttate@jaist.ac.jp
class TclTkIp
alias __eval _eval
alias __invoke _invoke
private :__eval
private :__invoke
attr_accessor :encoding
def _eval(cmd)
if( @encoding )
_fromUTF8(__eval(_toUTF8(cmd,@encoding)),@encoding)
else
__eval(cmd)
end... | Ruby |
require "tkcanvas"
if defined?($hscale_demo) && $hscale_demo
$hscale_demo.destroy
$hscale_demo = nil
end
$hscale_demo = TkToplevel.new {|w|
title("Horizontal Scale Demonstration")
iconname("hscale")
}
positionWindow($hscale_demo)
base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true)
msg =... | Ruby |
# combo.rb --
#
# This demonstration script creates several combobox widgets.
#
# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
if defined?($combo_demo) && $combo_demo
$combo_demo.destroy
$combo_demo = nil
end
$combo_demo = TkToplevel.new {|w|
title("Combobox Demonstration")
iconname("combo")
p... | Ruby |
#!/usr/bin/env ruby
#
# tcolor --
# simple color editor which supports RGB, HSB and CYM color space
#
# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
# last update: Thu Jun 18 06:32:35 JST 1998
#
require "tk"
# use TkVariable instance for the variable which is changed by Tk interpreter
$colorSpace = TkVa... | Ruby |
# spin.rb --
#
# This demonstration script creates several spinbox widgets.
#
# based on Tcl/Tk8.4.4 widget demos
if defined?($spin_demo) && $spin_demo
$spin_demo.destroy
$spin_demo = nil
end
$spin_demo = TkToplevel.new {|w|
title("Spinbox Demonstration")
iconname("spin")
positionWindow(w)
}
base_frame = T... | Ruby |
# mclist.rb --
#
# This demonstration script creates a toplevel window containing a Ttk
# tree widget configured as a multi-column listbox.
#
# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
if defined?($mclist_demo) && $mclist_demo
$mclist_demo.destroy
$mclist_demo = nil
end
$mclist_demo = TkTopleve... | Ruby |
# search.rb
#
# This demonstration script creates a collection of widgets that
# allow you to load a file into a text widget, then perform searches
# on that file.
#
# Text Search widget demo (called by 'widget')
#
# textLoadFile --
# This method below loads a file into a text widget, discarding
# the previous content... | Ruby |
#!/usr/bin/env ruby
# widget --
# This script demonstrates the various widgets provided by Tk,
# along with many of the features of the Tk toolkit. This file
# only contains code to generate the main window for the
# application, which invokes individual demonstrations. The
# code for the actual demonstrations is co... | Ruby |
#
# a dialog box with a local grab (called by 'widget')
#
class TkDialog_Demo1 < TkDialog
###############
private
###############
def title
"Dialog with local grab"
end
def message
'This is a modal dialog box. It uses Tk\'s "grab" command to create a "local grab" on the dialog box. The grab preve... | Ruby |
# paned2.rb --
#
# This demonstration script creates a toplevel window containing
# a paned window that separates two windows vertically.
#
# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
if defined?($paned2_demo) && $paned2_demo
$paned2_demo.destroy
$paned2_demo = nil
end
$paned2_demo = TkToplevel.... | Ruby |
# cscroll.rb
#
# This demonstration script creates a simple canvas that can be
# scrolled in two dimensions.
#
# simple scrollable canvas widget demo (called by 'widget')
#
# toplevel widget
if defined?($cscroll_demo) && $cscroll_demo
$cscroll_demo.destroy
$cscroll_demo = nil
end
# demo toplevel widget
$cscroll_d... | Ruby |
# style.rb
#
# This demonstration script creates a text widget that illustrates the
# various display styles that may be set for tags.
#
# text (display styles) widget demo (called by 'widget')
#
# toplevel widget
if defined?($style_demo) && $style_demo
$style_demo.destroy
$style_demo = nil
end
# demo toplevel wi... | Ruby |
# radio2.rb
#
# This demonstration script creates a toplevel window containing
# several radiobutton widgets.
#
# radiobutton widget demo (called by 'widget')
#
# toplevel widget
if defined?($radio2_demo) && $radio2_demo
$radio2_demo.destroy
$radio2_demo = nil
end
# demo toplevel widget
$radio2_demo = TkToplevel.... | Ruby |
# ttkprogress.rb --
#
# This demonstration script creates several progress bar widgets.
#
# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
if defined?($ttkprogress_demo) && $ttkprogress_demo
$ttkprogress_demo.destroy
$ttkprogress_demo = nil
end
$ttkprogress_demo = TkToplevel.new {|w|
title("Pr... | 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_COUN... | Ruby |
# menubutton.rb
#
# This demonstration script creates a window with a bunch of menus
# and cascaded menus using menubuttons.
require "tkcanvas"
def optionMenu(menubutton, varName, firstValue, *rest)
varName.value = firstValue
configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
'relief'=>'raised','bo... | Ruby |
# ttknote.rb --
#
# This demonstration script creates a toplevel window containing a Ttk
# notebook widget.
#
# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp"
if defined?($ttknote_demo) && $ttknote_demo
$ttknote_demo.destroy
$ttknote_demo = nil
end
$ttknote_demo = TkToplevel.new {|w|
title("Ttk No... | Ruby |
# tree.rb --
#
# This demonstration script creates a toplevel window containing a Ttk
# tree widget.
#
# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
if defined?($tree_demo) && $tree_demo
$tree_demo.destroy
$tree_demo = nil
end
$tree_demo = TkToplevel.new {|w|
title("Directory Browser")
iconname(... | Ruby |
#
# Ruby/Tk Goldverg demo (called by 'widget')
#
# Based on Tcl/Tk8.5a2 widget demos.
# The following is the original comment of TkGoldberg.tcl.
#
#>>##+#################################################################
#>>#
#>># TkGoldberg.tcl
#>># by Keith Vetter, March 13, 2003
#>>#
#>># "Man will always find a diffi... | Ruby |
# labelframe.rb
#
# This demonstration script creates a toplevel window containing
# several labelframe widgets.
#
# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
if defined?($labelframe_demo) && $labelframe_demo
$labelframe_demo.destroy
$labelframe_demo = nil
end
$labelframe_demo = TkToplevel.... | Ruby |
# ruler.rb
#
# This demonstration script creates a canvas widget that displays a ruler
# with tab stops that can be set, moved, and deleted.
#
# ruler widget demo (called by 'widget')
#
# rulerMkTab --
# This method creates a new triangular polygon in a canvas to
# represent a tab stop.
#
# Arguments:
# c - ... | Ruby |
#
# menus widget demo (called by 'widget')
#
# toplevel widget
if defined?($menu84_demo) && $menu84_demo
$menu84_demo.destroy
$menu84_demo = nil
end
# demo toplevel widget
$menu84_demo = TkToplevel.new {|w|
title("File Selection Dialogs")
iconname("menu84")
positionWindow(w)
}
base_frame = TkFrame.new($men... | Ruby |
%# floor2.rb
#
# This demonstration script creates a canvas widet that displays the
# floorplan for DEC's Western Research Laboratory.
#
# floorDisplay widget demo (called by 'widget')
#
# floorDisplay2 --
# Recreate the floorplan display in the canvas given by "w". The
# floor given by "active" is displayed on top w... | Ruby |
#
# menus widget demo (called by 'widget')
#
# toplevel widget
if defined?($menu_demo) && $menu_demo
$menu_demo.destroy
$menu_demo = nil
end
# demo toplevel widget
$menu_demo = TkToplevel.new {|w|
title("File Selection Dialogs")
iconname("menu")
positionWindow(w)
}
base_frame = TkFrame.new($menu_demo).pack... | 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 |
#!/usr/bin/env ruby
# This script is a sample of MultiTkIp class
require "multi-tk"
# create slave interpreters
trusted_slave = MultiTkIp.new_slave
safe_slave1 = MultiTkIp.new_safeTk
safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none, 'expand'=>false)
#safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none)
#safe_slave... | 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 displ... | 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 |
#!/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 no ... | 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 '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
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
# 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 |
#
# menubar sample 3 : vertical layout menubar; use frame and menubuttons
#
require 'tk'
radio_var = TkVariable.new('y')
menu_spec = [
[['&File', true], # when underline option is ture, '&' index is the position
{:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
'---',
['Check_A', T... | 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
end
... | 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(nil, '... | 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
#
# 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
# 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 squ... | 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_COUN... | 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 |
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 |
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 |
#!/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'
begin
# try to use Img extension
require 'tkextlib/tkimg'
rescue Exception
# cannot use Img extention --> ignore
end
############################
# scrolled_canvas
class TkScrolledCanvas < TkCanvas
include TkComposite
def initialize_composite(keys={})
@h_scr = TkScroll... | 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 |
#!/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
require "parsedate"
require "base64"
include ParseDate
class Mail
def Mail.new(f)
if !f.kind_of?(IO)
f = open(f, "r")
me = super(f)
f.close
else
me = super
end
return me
end
def initialize(f)
@header = {}
@body = []
while line = f.gets()
... | Ruby |
#
# menubar sample 2 : use 'menu' option of root/toplevel widget
#
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
#
# 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 char... | 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 |
#
# tktextframe.rb : a sample of TkComposite
#
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
module Tk::ScrollbarComposite
include TkComposite
def component_construct_keys
# If a component requires options for construction,
# return an Array of option-keys.
[]
... | 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
#
# sample script of TkOptionDB
#
# If 'LANG' environment variable's value is started by 'ja',
# then read Japanese resource data and display Japanese button text.
# In other case, read English resource data and display English text.
#
require "tk"
if __FILE__ == $0 || !TkCore::INTERP.safe?
i... | Ruby |
#!/usr/bin/env ruby
require 'tk'
class Clock
def initialize(clock24 = true)
@clock = (clock24)? 24: 12
@size = 200
@cdot_size = 5
@cdot_color = 'black'
@hour_hand_color = 'black'
@minute_hand_color = 'gray25'
@second_hand_color = 'gray50'
@mark_font = 'Helvetica -14'
... | Ruby |
#!/usr/bin/env ruby
require 'remote-tk'
puts <<EOM
This sample controls the other Tk interpreter (Ruby/Tk, Tcl/Tk, and so on)
which running on the other process. For this purpose, Ruby/Tk uses Tcl/Tk's
'send' command. Availability of the command depends on your GUI environment.
If this script doesn't work, please chec... | 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, :r... | Ruby |
#
# Tk::RbWidget::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::RbWidget::ScrollFrame#vscroll & hscroll.
# ... | Ruby |
#!/usr/bin/env ruby
#
# countdown timer
# usage: cd_timer min [, min ... ]
# ( e.g. cd_timer 0.5 1 3 5 10 )
#
require 'tk'
if ARGV.empty?
$stderr.puts 'Error:: No time arguments for counting down'
exit(1)
end
width = 10
TkButton.new(:text=>'exit',
:command=>proc{exit}).pack(:side=>:... | 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/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/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 "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
# TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fi... | Ruby |
#
# Tk::RbWidget::Editable_Listbox 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 modificat... | Ruby |
#!/usr/bin/env ruby
# This script generates a counter with start and stop buttons.
require "tk"
$label = TkLabel.new {
text '0.00'
relief 'raised'
width 10
pack('side'=>'bottom', 'fill'=>'both')
}
TkButton.new {
text 'Start'
command proc {
if $stopped
$stopped = FALSE
tick
end
}
pa... | 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 |
#
# 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
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*'
pac... | 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 set_c... | Ruby |
#
# tktext.rb - load tk/text.rb
#
require 'tk/text'
| Ruby |
#
# tkafter.rb - load tk/after.rb
#
require 'tk/timer'
| Ruby |
#
# tkpalette.rb - load tk/palette.rb
#
require 'tk/palette'
| Ruby |
#
# tkmenubar.rb - load tk/menubar.rb
#
require 'tk/menubar'
| Ruby |
#
# tkextlib/itk/incr_tk.rb
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tk/menuspec'
require 'tkextlib/itcl.rb'
# call setup script
require 'tkextlib/itk.rb'
#TkPackage.require('Itk', '3.2')
TkPackage.require('Itk')
module Tk
module Itk
include Tk
e... | Ruby |
#
# setup.rb -- setup script before calling TkPackage.require()
#
# If you need some setup operations (for example, add a library path
# to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup
# operations in this file.
#
# ... | Ruby |
#
# [incr Widgets] support
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'
require 'tkextlib/itcl'
require 'tkextlib/itk'
# call setup script for general 'tkextlib' libraries
#require 'tkextlib/setup.rb'
# call setup script
#require 'tkextlib/iwidgets/setup.rb'
# load all... | Ruby |
#
# ::vu::spinbox widget
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
# a standard spinbox (<= 8.3)
# This is the same as the 8.4 core spinbox widget.
#
require 'tk'
if (Tk::TK_MAJOR_VERSION < 8 ||
(Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4))
# call setup script -... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.