code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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 b...
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/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' ####################################### 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=>:g...
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 it...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' file = File.join(File.dirname(File.expand_path(__FILE__)), 'images', 'buckskin.gif') bgTexture = TkPhotoImage.new(:file=>file) TkOption.add('*Graph.Tile', bgTexture) TkOption.add('*Label.Tile', bgTexture) TkOption.add('*Frame.Tile', bgTexture) ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' length = 250000 graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points") graph.xaxis_configure(:loose=>false, :title=>'X Axis Label') graph.yaxis_configure(:title=>'Y Axis Label') graph.legend_configure(:activerelief=>:sunken, :background=>'') Tk::BL...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' length = 250000 graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points") graph.xaxis_configure(:loose=>false, :title=>'X Axis Label') graph.yaxis_configure(:title=>'Y Axis Label') graph.legend_configure(:activerelief=>:sunken, :background=>'') Tk::BL...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' require 'date' dir = File.join(File.dirname(File.expand_path(__FILE__)), 'images') file = File.join(dir, 'chalk.gif') active = File.join(dir, 'rain.gif') texture1 = TkPhotoImage.new(:file=>file) texture2 = TkPhotoImage.new(:file=>active) TkOption.add('*Tile',...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' graph = Tk::BLT::Graph.new.pack plot = graph.element_create plot.configure(:linewidth=>0, :label=>'foo', :data=>[[1.0, 3.4], [1.1, 2.8], [1.2, 3.1], [1.4, 2.9]].flatten) Tk.mainloop
Ruby
$stipples = {} unless $stipples $stipples['bdiagonal1'] = Tk::BLT::Bitmap.new(<<EOD) #define bdiagonal1_width 8 #define bdiagonal1_height 8 static unsigned char bdiagonal1_bits[] = { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11}; EOD $stipples['bdiagonal2'] = Tk::BLT::Bitmap.new(<<EOD) #define bdiagonal2_width 8...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' file = File.join(File.dirname(File.expand_path(__FILE__)), 'images', 'qv100.t.gif') if File.exist?(file) src = TkPhotoImage.new(:file=>file) else fail RuntimeError, 'no image file' end width = src.width height = src.height TkOption.add('*L...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' graph = Tk::BLT::Graph.new.pack plot = Tk::BLT::PlotComponent::Element.new(graph, :linewidth=>0, :label=>'foo') plot.data([[1.0, 3.4], [1.1, 2.8], [1.2, 3.1], [1.4, 2.9]].flatten) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' Tk::TCL_PRECISION.value = 15 [ ['*Graph.Width', '10i'], ['*Graph.leftMargin', '.75i'], ['*Graph.Height', '6i'], ['*Graph.plotBackground', 'black'], ['*LineMarker.color', 'white'], ['*LineMarker.Dashes', 5], ['*TextMarker.foreground', 'white'...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' # Example of a pareto chart. # # The pareto chart mixes line and bar elements in the same graph. # Each processing operating is represented by a bar element. The # total accumulated defects is displayed with a single line element. b = Tk::BLT::Barchart.new(:tit...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' load File.join(File.dirname(File.expand_path(__FILE__)), 'scripts', 'stipples.rb') TkOption.add('*graph.x.Title', 'X Axis Label') TkOption.add('*graph.y.Title', 'Y Axis Label') TkOption.add('*graph.title', 'A Simple Barchart') TkOption.add('*grap...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' file = File.join(File.dirname(File.expand_path(__FILE__)), 'images', 'sample.gif') if File.exist?(file) src = TkPhotoImage.new(:file=>file) else fail RuntimeError, 'no image file' end width = src.width height = src.height TkOption.add('*La...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/blt' length = 250000 graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points") graph.xaxis_configure(:loose=>false, :title=>'X Axis Label') graph.yaxis_configure(:title=>'Y Axis Label') graph.legend_configure(:activerelief=>:sunken, :background=>'') Tk::BL...
Ruby
# # basic demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoBasic @@var = TkVariable.new_hash @@after = nil @@count = 0 def self.create(nb) frame = nb.insert('end', 'dem...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/bwidget' module DemoVar @_wfont = nil @notebook = nil @mainframe = nil @status = TkVariable.new @prgtext = TkVariable.new @prgindic = TkVariable.new @font = nil @font_name = nil @toolbar1 = TkVariable.new(true) @toolbar2 = TkVariab...
Ruby
# # templdlg demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoTree @@count = 0 @@dblclick = false @@top = nil def self.create(nb) frame = nb.insert('end', 'demoTree', :te...
Ruby
# # manager demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoManager @@progress = TkVariable.new(false) @@status = TkVariable.new('Compute in progress...') @@homogeneous...
Ruby
# # select demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoSelect @@var = TkVariable.new_hash def self.create(nb) frame = nb.insert('end', 'demoSelect', :text=>'Spin & Combo...
Ruby
# # templdlg demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoDialog @@tmpl = TkVariable.new_hash @@msg = TkVariable.new_hash @@msgdlg = nil @@progmsg = TkVari...
Ruby
# # dnd demo --- called from demo.rb # unless Object.const_defined?('DemoVar') fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " end module DemoDnD def self.create(nb) frame = nb.insert('end', 'demoDnD', :text=>'Drag and Drop') titf1 = Tk::BWidget::TitleFrame...
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
# msgbox2.rb # # This demonstration script creates message boxes of various type # # message boxes widget demo (called by 'widget') # # toplevel widget if defined?($msgbox2_demo) && $msgbox2_demo $msgbox2_demo.destroy $msgbox2_demo = nil end # demo toplevel widget $msgbox2_demo = TkToplevel.new {|w| title("Mes...
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 #...
Ruby
# # animated wave demo (called by 'widget') # # based on Tcl/Tk8.5a2 widget demos # destroy toplevel widget for this demo script if defined?($aniwave_demo) && $aniwave_demo $aniwave_demo.destroy $aniwave_demo = nil end # create toplevel widget $aniwave_demo = TkToplevel.new {|w| title("Animated Wave Demonstrat...
Ruby
# colors.rb # # This demonstration script creates a listbox widget that displays # many of the colors from the X color database. You can click on # a color to change the application's palette. # # listbox widget demo 'colors' (called by 'widget') # # toplevel widget if defined?($colors_demo) && $colors_demo $colors...
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
# 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
# # 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($me...
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
#!/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
# filebox.rb # # This demonstration script prompts the user to select a file.# # widget demo prompts the user to select a file (called by 'widget') # # toplevel widget if defined?($filebox_demo) && $filebox_demo $filebox_demo.destroy $filebox_demo = nil end # demo toplevel widget $filebox_demo = TkToplevel.new {...
Ruby
# entry2.rb # # This demonstration script is the same as the entry1.tcl script # except that it creates scrollbars for the entries. # # entry (with scrollbars) widget demo (called by 'widget') # # toplevel widget if defined?($entry2_demo) && $entry2_demo $entry2_demo.destroy $entry2_demo = nil end # demo topleve...
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
%# 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
# 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| ti...
Ruby
# # a dialog box with a global grab (called by 'widget') # class TkDialog_Demo2 < TkDialog ############### private ############### def title "Dialog with global grab" end def message "This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you inv...
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
# 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
# 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 w...
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
#!/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 @btn_APPLY.state(:disabled) @btn_CAN...
Ruby
# # entry (no scrollbars) widget demo (called by 'widget') # # toplevel widget if defined?($entry1_demo) && $entry1_demo $entry1_demo.destroy $entry1_demo = nil end # demo toplevel widget $entry1_demo = TkToplevel.new {|w| title("Entry Demonstration (no scrollbars)") iconname("entry1") positionWindow(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
# check.rb # # This demonstration script creates a toplevel window containing # several checkbuttons. # # checkbutton widget demo (called by 'widget') # # toplevel widget if defined?($check_demo) && $check_demo $check_demo.destroy $check_demo = nil end # demo toplevel widget $check_demo = TkToplevel.new {|w| t...
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 top...
Ruby
# twind.rb # # This demonstration script creates a text widget with a bunch of # embedded windows. # # text (embedded windows) widget demo (called by 'widget') # # toplevel widget if defined?($twind_demo) && $twind_demo $twind_demo.destroy $twind_demo = nil end # demo toplevel widget $twind_demo = TkToplevel.new...
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
#!/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
# 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 = TkTopleve...
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 wi...
Ruby
# sayings.rb # # This demonstration script creates a listbox that can be scrolled # both horizontally and vertically. It displays a collection of # well-known sayings. # # listbox widget demo 'sayings' (called by 'widget') # # toplevel widget if defined?($sayings_demo) && $sayings_demo $sayings_demo.destroy $say...
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 = TkToplev...
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
# radio.rb # # This demonstration script creates a toplevel window containing # several radiobutton widgets. # # radiobutton widget demo (called by 'widget') # # toplevel widget if defined?($radio_demo) && $radio_demo $radio_demo.destroy $radio_demo = nil end # demo toplevel widget $radio_demo = TkToplevel.new {...
Ruby
# # text (embedded windows) widget demo 2 (called by 'widget') # # delete toplevel widget if defined?($twind2_demo) && $twind2_demo $twind2_demo.destroy $twind2_demo = nil end # demo toplevel widget $twind2_demo = TkToplevel.new {|w| title("Text Demonstration - Embedded Windows 2") iconname("Embedded Windows...
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
# # 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
# radio3.rb # # This demonstration script creates a toplevel window containing # several radiobutton widgets. # # radiobutton widget demo (called by 'widget') # # toplevel widget if defined?($radio3_demo) && $radio3_demo $radio3_demo.destroy $radio3_demo = nil end # demo toplevel widget $radio3_demo = TkToplevel...
Ruby
# icon.rb # # This demonstration script creates a toplevel window containing # buttons that display bitmaps instead of text. # # iconic button widget demo (called by 'widget') # # toplevel widget if defined?($icon_demo) && $icon_demo $icon_demo.destroy $icon_demo = nil end # demo toplevel widget $icon_demo = TkT...
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| tit...
Ruby
# vscale.rb # # This demonstration script shows an example with a vertical scale. require "tkcanvas" if defined?($vscale_demo) && $vscale_demo $vscale_demo.destroy $vscale_demo = nil end $vscale_demo = TkToplevel.new {|w| title("Vertical Scale Demonstration") iconname("vscale") } positionWindow($vscale_demo)...
Ruby
# Based on the widget demo of Tcl/Tk8.5.2 # The following is the original copyright text. #---------------------------------------------------------------------------- # Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net> # # Calculate a Knight's tour of a chessboard. # # This uses Warnsdorff's rule to calc...
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| ...
Ruby
# arrow.rb # # This demonstration script creates a canvas widget that displays a # large line with an arrowhead whose shape can be edited interactively. # # arrowhead widget demo (called by 'widget') # # arrowSetup -- # This method regenerates all the text and graphics in the canvas # window. It's called when the can...
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_...
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 $clrpi...
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
# msgbox.rb # # This demonstration script creates message boxes of various type # # message boxes widget demo (called by 'widget') # # toplevel widget if defined?($msgbox_demo) && $msgbox_demo $msgbox_demo.destroy $msgbox_demo = nil end # demo toplevel widget $msgbox_demo = TkToplevel.new {|w| title("Message B...
Ruby
# floor.rb # # This demonstration script creates a canvas widet that displays the # floorplan for DEC's Western Research Laboratory. # # floorDisplay widget demo (called by 'widget') # # floorDisplay -- # Recreate the floorplan display in the canvas given by "w". The # floor given by "active" is displayed on top with...
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
# 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
# unicodeout.rb -- # # This demonstration script shows how you can produce output (in label # widgets) using many different alphabets. # # based on Tcl/Tk8.4.4 widget demos if defined?($unicodeout_demo) && $unicodeout_demo $unicodeout_demo.destroy $unicodeout_demo = nil end $unicodeout_demo = TkToplevel.new {|w|...
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 = TkToplev...
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
# 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
# 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 = ...
Ruby
# toolbar.rb -- # # This demonstration script creates a toolbar that can be torn off. # # based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" if defined?($toolbar_demo) && $toolbar_demo $toolbar_demo.destroy $toolbar_demo = nil end $toolbar_demo = TkToplevel.new {|w| title("Ttk Menu Buttons") iconna...
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
# # form widget demo (called by 'widget') # # toplevel widget if defined?($form_demo) && $form_demo $form_demo.destroy $form_demo = nil end # demo toplevel widget $form_demo = TkToplevel.new {|w| title("Form Demonstration") iconname("form") positionWindow(w) } base_frame = TkFrame.new($form_demo).pack(:fi...
Ruby
# # This demonstration illustrates how Tcl/Tk can be used to construct # simulations of physical systems. # (called by 'widget') # # based on Tcl/Tk8.5a2 widget demos # destroy toplevel widget for this demo script if defined?($pendulum_demo) && $pendulum_demo $pendulum_demo.destroy $pendulum_demo = nil end # cre...
Ruby
#!/usr/bin/env ruby require 'tk' #unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK # require 'tkencoding' #end TkButton.new(nil, 'text'=>"Hello Ruby world!", 'font'=>TkFont.new('k14'), 'command'=>proc{print "Hello Ruby world!\n"; exit} ).pack Tk.mainloop
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
# 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
# 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") iconn...
Ruby
# plot.rb # # This demonstration script creates a canvas widget showing a 2-D # plot with data points that can be dragged with the mouse. # # 2-D plot widget demo (called by 'widget') # # toplevel widget if defined?($plot_demo) && $plot_demo $plot_demo.destroy $plot_demo = nil end # demo toplevel widget $plot_de...
Ruby
# ctext.rb # # This demonstration script creates a canvas widget with a text # item that can be edited and reconfigured in various ways. # # Canvas Text widget demo (called by 'widget') # # toplevel widget if defined?($ctext_demo) && $ctext_demo $ctext_demo.destroy $ctext_demo = nil end # demo toplevel widget $c...
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") ...
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
#!/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
# 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("P...
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).pac...
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
# 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....
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 N...
Ruby