code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/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
# # tktextframe.rb : a sample of TkComposite # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' class TkTextFrame < TkText include TkComposite def initialize_composite(keys={}) keys = _symbolkey2str(keys) # create scrollbars @v_scroll = TkScrollbar.new(@frame, 'or...
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?...
Ruby
# # tkcombobox.rb : TkAutoScrollbox & TkCombobox # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' class TkAutoScrollbox < TkListbox include TkComposite @@up_bmp = TkBitmapImage.new(:data=><<EOD) #define up_arrow_width 9 #define up_arrow_height 9 static unsigned char up_arro...
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 # 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/bin/env ruby # # irbtkw.rb : IRB console with Ruby/Tk # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # release = '2008/03/08' require 'tk' begin require 'tktextio' rescue LoadError require File.join(File.dirname(File.expand_path(__FILE__)), 'tktextio.rb') end require 'irb'...
Ruby
#!/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
# # tkmultilistbox.rb : multiple listbox widget # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # require 'tk' class TkMultiListbox < TkListbox include TkComposite # lbox_height : height of listboxes (pixel) # title_info : array [ [<title_string>,<init_width>], ... ] # keys :...
Ruby
#!/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
#!/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
# # Demo: Layout # def demoLayout(t) t.configure(:showroot=>false, :showrootbutton=>true, :showbuttons=>true, :showlines=>true, :itemheight=>0, :selectmode=>:browse) if $HasColumnCreate t.column_create(:text=>'Layout') else t.column_configure(0, :text=>'Layout') end t.element_create('...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/treectrl' $ScriptDir = File.dirname(File.expand_path(__FILE__)) $HasColumnCreate = Tk::TreeCtrl::HasColumnCreateCommand $Version_1_1_OrLater = (TkPackage.vcompare(Tk::TreeCtrl.package_version, '1.1') >= 0) #if Hash.instance_methods.include?(:key) if TkCore::WITH_R...
Ruby
# # Demo: Outlook Express folder list # def demoOutlookFolders(t) init_pics('outlook-*') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>true, :showroot=>true, :showrootbutton=>false, :showbuttons=>true) if...
Ruby
# # Demo: MailWasher # def demoMailWasher(t) init_pics('*checked') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:showroot=>false, :showrootbutton=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse, :xscrolli...
Ruby
# # Demo: Bitmaps # def demoBitmaps(t) #if $Version_1_1_OrLater if @has_bgimg t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items', :showheader=>false, :backgroundimage=>@images['sky']) else t.c...
Ruby
# # Demo: Help contents # def demoHelpContents(t) height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('help-*') if $Version_1_1_OrLater t.column_create(:te...
Ruby
def demoExplorerAux(t, dir_proc, file_proc) base_dir = File.dirname(File.dirname(@ScriptDir)) clicks = Tk::Clock.clicks globDirs = Dir.glob(File.join(base_dir, '*')).find_all{|file| FileTest.directory?(file) } clickGlobDirs = Tk::Clock.clicks - clicks clicks = Tk::Clock.clicks list = globDirs.sort ...
Ruby
# def random_N @RandomN[0] || 500 end # # Demo: random N items # def demoRandom(t) init_pics('folder-*', 'small-*') height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:extended, :showroot=>true, :showrootbutton=>true, :showbuttons=>tr...
Ruby
# # Demo: iMovie # def demoIMovie(t) t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :selectmode=>:browse, :orient=>:horizontal, :wrap=>:window, :showheader=>false, :background=>'#dcdcdc') if $HasColumnCreate t.column_create end init_pics('imovie-*') ...
Ruby
# # Demo: Outlook Express newsgroup messages # def demoOutlookNewsgroup(t) init_pics('outlook-*') height = t.font.metrics(:linespace) height = 18 if height < 18 t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false, :showroot=>false, :showrootbutton=>false, :showbuttons=>true)...
Ruby
def demoInternetOptions (t) @Option = TkVarAccess.new_hash('::Option') height = t.font.metrics(:linespace) + 2 height = 18 if height < 18 t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false, :itemheight=>height, :selectmode=>:browse) init_pics('internet-*') if $HasColumnCr...
Ruby
#!/usr/bin/env ruby # # This script implements the "ss" application. "ss" implements # a presentation slide-show based on HTML slides. # require 'tk' require 'tkextlib/tkHTML' file = ARGV[0] class TkHTML_File_Viewer include TkComm # These are images to use with the actual image specified in a # "<img>" markup ca...
Ruby
#!/usr/bin/env ruby # # This script implements the "hv" application. Type "hv FILE" to # view FILE as HTML. # # This application is used for testing the HTML widget. It can # also server as an example of how to use the HTML widget. # require 'tk' require 'tkextlib/tkHTML' root = TkRoot.new(:title=>'HTML File Viewer...
Ruby
#!/usr/bin/env ruby # # viewIcons.rb # # -- Display icons from icon library. # # -- Copy the clicked icon data (command string of creating # a TkPhotoImage instance) to the clipboard. # require 'tk' require 'tkextlib/ICONS' class ViewIcons ##################################### private ######...
Ruby
#!/usr/bin/env ruby # # Tk::Img demo # # -- This script is based on demo.tcl of Tcl/Tk's 'Img' extention. # Image data in this script is those of demo.tcl. # Please read 'license_terms_of_Img_extension' file. # require 'tk' require 'tkextlib/tkimg' # # Make the Image format available. # class TkImg...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' ds = Tk::Iwidgets::Dialogshell.new(:modality=>:none) ds.add('OK', :text=>'OK', :command=>proc{puts 'OK'; ds.deactivate}) ds.add('Cancel', :text=>'Cancel', :command=>proc{puts 'Cancel'; ds.deactivate}) ds.default('OK') TkButton.new(:text=>'ACTIVATE', :padx=...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} # # Non-modal example # nmfsd = Tk::Iwidgets::Fileselectiondialog.new(:title=>'Non-Modal') nmfsd.buttonconfigure('OK', :command=>proc{ puts "You selected #{nmfsd.get}" nmfsd....
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' djl = Tk::Iwidgets::Disjointlistbox.new.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10) djl.set_lhs(*[0,2,4,5]) djl.set_rhs(3,6) djl.insert_lhs(1,7,8) djl.insert_rhs(9) p djl.get_lhs p djl.get_rhs Tk....
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') sh = Tk::Iwidgets::Scrolledhtml.new(:fontname=>'helvetica', :linkcommand=>proc{|href| sh.import_link(href) ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Canvasprintdialog.new.activate Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') slb = Tk::Iwidgets::Scrolledlistbox.new(:selectmode=>:single, :vscrollmode=>:static, :hscrollmode=>:dynamic, ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') Tk::Iwidgets::Spinint.new(:labeltext=>'Temperature', :labelpos=>:w, :width=>5, :fixed=>true, :range=>[32, 212]).pack(:pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Thread.new{ trap('INT') {puts 'catch SIGINT'} sleep 5 trap('INT', 'DEFAULT') } Tk::Iwidgets::Watch.new(:state=>:disabled, :showampm=>:no, :width=>155, :height=>155){|w| w.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>tru...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' sc = Tk::Iwidgets::Scrolledcanvas.new sc.create(TkcRectangle, 100, 100, 400, 400, :fill=>'red') TkcRectangle.new(sc, 300, 300, 600, 600, :fill=>'green') TkcRectangle.new(sc, [[200, 200], [500, 500]], :fill=>'blue') sc.pack(:expand=>true, :fill=>:both, :pad...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # sample 1 p bb1 = Tk::Iwidgets::Buttonbox.new p bb1.add('Yes', :text=>'Yes', :command=>proc{puts 'Yes'}) p bb1.add('No', :text=>'No', :command=>proc{puts 'No'}) p bb1.add('Maybe', :text=>'Maybe', :command=>proc{puts 'Maybe'}) bb1.default('Yes') bb...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Calendar.new(:command=>proc{|arg| puts(arg.date)}, :weekendbackground=>'mistyrose', :weekdaybackground=>'ghostwhite', :outline=>'black', :startday=>'wednesday',...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' sh = Tk::Iwidgets::Shell.new(:modality=>:application, :padx=>20, :pady=>20, :title=>'Shell') TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7, :command=>proc{puts sh.activate}).pack(:padx=>10, :pady=>10) TkLabe...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, :side=>:top, :padx=>10, :pady=>0) # Add two pages to the tabnotebook, # labelled "Page One" a...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, :side=>:left, :padx=>10, :pady=>10) # Add two pages to the tabnotebook, # labelled "Page O...
Ruby
#!/usr/bin/env ruby ######################################################### # # set $KCODE to 'utf' for a utf8 charecter # ######################################################### $KCODE='utf' require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Entryfield.new(:co...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Fileselectionbox.new.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Spindate.new.pack(:padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Spintime.new.pack(:padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, :side=>:top, :padx=>10, :pady=>0) # Add two pages to the tabnotebook, # labelled "Page One...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Thread.new{Tk.mainloop} d = Tk::Iwidgets::Dialog.new(:modality=>:application) d.buttonconfigure('OK', :command=>proc{puts 'OK'; d.deactivate true}) d.buttonconfigure('Apply', :command=>proc{puts 'Apply'}) d.buttonconfigure('Cancel', :command=>proc{puts 'Ca...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} # # Non-modal example # nmfsd = Tk::Iwidgets::Extfileselectiondialog.new(:title=>'Non-Modal') nmfsd.buttonconfigure('OK', :command=>proc{ puts "You selected #{nmfsd.get}" nmf...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} st = Tk::Iwidgets::Scrolledtext.new.pack st.insert('end', "Now is the time for all good men\n") st.insert('end', "to come to the aid of their country") fd = Tk::Iwidgets::Finddialog.new(:textwidget=>st) fd.center(st) fd.a...
Ruby
#!/usr/bin/env ruby ######################################################### # # set Tk.encoding = 'utf-8' for a utf8 charecter # ######################################################### require 'tk' require 'tkextlib/iwidgets' Tk.encoding = 'utf-8' TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Ent...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' lf = Tk::Iwidgets::Labeledframe.new(:labeltext=>'Entry Frame', :labelpos=>:n) lf.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10) cs = lf.child_site Tk::Iwidgets::Entryfield.new(cs, :labeltext=>'Name:').pack(:side=>:top, :fill=>:x) Tk::Iwidgets::Spi...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180, :labeltext=>'scrolledframe') cs = sf.child_site TkButton.new(cs, :text=>'Hello').pack(:pady=>10) TkButton.new(cs, :text=>'World').pack(:pady=>10) TkButton....
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} dir = '/usr/local/ActiveTcl/demos/IWidgets/html/' href = [ 'hyperhelp.n', 'buttonbox.n', 'calendar.n' ] hh = Tk::Iwidgets::Hyperhelp.new(:topics=>href, :helpdir=>dir) hh.show_topic('hyperhelp.n') hh.activate mainloop.jo...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Extbutton.new(:text=>'Bitmap example', :bitmap=>'info', :background=>'bisque', :activeforeground=>'red', :bitmapforeground=>'blue', :defaultring=>true, :com...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, :labeltext=>'Messages', :labelpos=>:n, :height=>120, :width=>550, :savedir=>'/tmp', :textbackgr...
Ruby
#!/usr/bin/env ruby ######################################################### # # use Tk::UTF8_String() for a utf8 charecter # ######################################################### require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') ef = Tk::Iwidgets::Entryfield.new(:command=>proc{...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' class Spinner_demo < TkWindow Months = %w(January February March April May June July August September October November December) def block_input(c) false end def spin_month(step) index = Months.index(@spinner.get) + step index = 11 if i...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} TkButton.new(:text=>'QUIT', :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10) Tk::Iwidgets::Selectiondialog.new.activate mainloop.join
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' lw = Tk::Iwidgets::Labeledwidget.new(:labeltext=>'Canvas Widget', :labelpos=>:s) lw.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10) cw = TkCanvas.new(lw.child_site, :relief=>:raised, :width=>200, :height=>200, ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' om = Tk::Iwidgets::Optionmenu.new(:labelmargin=>5, :labelpos=>:w, :labeltext=>"Operating System :") om.insert('end', 'Unix', 'VMS', 'Linux', 'OS/2', 'Windows NT', 'DOS') om.sort_ascending om.select('Linux') om.pack(:padx=...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' tf = Tk::Iwidgets::Timefield.new(:command=>proc{puts(tf.get)}) tf.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' rb = Tk::Iwidgets::Radiobox.new(:labeltext=>'Fonts') rb.add('times', :text=>'Times') rb.add('helvetica', :text=>'Helvetica') rb.add('courier', :text=>'Courier') rb.add('symbol', :text=>'Symbol') rb.select('courier') rb.pack(:expand=>true, :fill=>:bo...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb| pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) TkTimer.new(500, 20, proc{fb.step}).start(2500) } Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' TkOption.add('*textBackground', 'white') sb = Tk::Iwidgets::Selectionbox.new.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) sb.insert_items('end', *['Hello', 'Out There', 'World']) TkLabel.new(sb.child_si...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none, :labeltext=>'Password File') st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) st.import('/etc/passwd') Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' helpvar = TkVariable.new viewmode = TkVariable.new menu_spec = [ [:menubutton, 'file', { :text=>'File', :menu=>[ [:options, {:tearoff=>false}], [:command, 'new', { :label=>'New', :helpstr=>'Open new document', ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' ########################################## # icon images editcopy22 = TkPhotoImage.new(:data=><<'EOD') R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxa XMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy 7Pzu5PTm3NTKvIR+fJyGfHxu...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Dateentry.new.pack Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300) pw.add('top') pw.add('middle', :margin=>10) pw.add('bottom', :margin=>10, :minimum=>10) pw.pack(:fill=>:both, :expand=>true) pw.child_site_list.each{|pane| TkButton.new(pane, :text=>pane.path...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mw = Tk::Iwidgets::Mainwindow.new mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0, :padx=>8, :pady=>2, :menu=>[ [:options, {:tearoff=>false}], [:command, 'new', { :lab...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create the tabnotebook widget and pack it. nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, :side=>:left, :padx=>10, :pady=>10) # Add two pages to the tabnotebook, # labelled "Page One"...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Canvasprintbox.new(:orient=>:landscape, :stretch=>1) \ .pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic, :labeltext=>'Messages', :labelpos=>:n, :height=>120, :width=>550, :savedir=>'/tmp', :textbackgr...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} TkOption.add('*textBackground', 'white') pd = Tk::Iwidgets::Promptdialog.new(:modality=>:global, :title=>'Password', :labeltext=>'Password:', :show=>'*') pd.hide('Apply') if TkComm.bo...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # Create a listbox with two items (one and two) l = TkListbox.new(:selectmode=>:single, :exportselection=>false).pack l.insert('end', 'one') l.insert('end', 'two') l.selection_set(0) # Define a proc that knows how to select an item # from a list given an in...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Timeentry.new.pack Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300) top = pw.add middle = pw.add(:margin=>10) bottom = pw.add(:margin=>10, :minimum=>10) pw.pack(:fill=>:both, :expand=>true) pw.child_site_list.each{|pane| TkButton.new(pane, :text=>pane.path, :...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' helpvar = TkVariable.new viewmode = TkVariable.new mb = Tk::Iwidgets::Menubar.new mb.menubuttons = [ [:menubutton, 'file', { :text=>'File', :menu=>[ [:command, 'new', {:label=>'New'}], [:command, 'close', {:label=>'Close'}], ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Pushbutton.new(:text=>'Hello', :command=>proc{puts 'Hello World'}, :defaultring=>true).pack(:padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' mainloop = Thread.new{Tk.mainloop} # # Standard question message dialog used for confirmation. # md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog', :text=>'Are you sure ? ', ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' cb = Tk::Iwidgets::Checkbox.new cb.add('bold', :text=>'Bold') cb.add('italic', :text=>'Italic') cb.add('underline', :text=>'Underline') cb.select('underline') cb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' # # Non-editable Dropdown Combobox # cb1 = Tk::Iwidgets::Combobox.new(:labeltext=>'Month:', :selectioncommand=>proc{ puts(cb1.get_curselection) }, ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' df = Tk::Iwidgets::Datefield.new(:command=>proc{puts(df.get)}) df.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' Tk::Iwidgets::Extfileselectionbox.new.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) Tk.mainloop
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/iwidgets' def get_files(file) dir = (file.empty?)? ENV['HOME'] : TkComm._fromUTF8(file) Dir.chdir(dir) rescue return '' Dir['*'].sort.collect{|f| [TkComm._toUTF8(File.join(dir, f)), TkComm._toUTF8(f)] } end Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{...
Ruby
#!/usr/bin/env ruby ## ## basic.rb ## ## This demo shows the basic use of the table widget ## ## ( based on 'basic.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' ary = TkVariable.new_hash rows = 8 cols = 8 # fill table variable ((-(rows))..rows).each{|x| ((-(cols))....
Ruby
#!/usr/bin/env ruby ## ## debug.rb ## ## This demo uses most features of the table widget ## ## ( based on 'debug.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table ary = TkVariable.new_hash rows = 25 cols = 20 # fill table variable ((-(rows))..rows).eac...
Ruby
#!/usr/bin/env ruby ## ## spreadsheet.rb ## ## This demos shows how you can simulate a 3D table ## and has other basic features to begin a basic spreadsheet ## ## ( based on 'spreadsheet.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' rows = 10 cols = 10 cur_var = TkVari...
Ruby
#!/usr/bin/env ruby ## ## buttons.rb ## ## demonstrates the simulation of a button array ## ## ( based on 'buttons.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table tab = TkVariable.new_hash rows = 20 cols = 20 table = Tk::TkTable.new(:rows=>rows + 1, :...
Ruby
#!/usr/bin/env ruby ## ## valid.rb ## ## This demos shows the use of the validation mechanism of the table ## and uses the table's cache (no -command or -variable) ## ## ( based on 'valid.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' rows = 10 cols = 10 def colorize(n...
Ruby
#!/usr/bin/env ruby ## ## command.rb ## ## This demo shows the use of the table widget's -command options ## ## ( based on 'command.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' # create the table data = TkVariable.new_hash rows = 10 cols = 10 # fill table variable ((-...
Ruby
#!/usr/bin/env ruby ## ## maxsize.rb ## ## This demo uses a really big table. The big startup time is in ## filling the table's Tcl array var. ## ## ( based on 'maxsize.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tktable' ary = TkVariable.new_hash rows = 40000 cols = 10 # ...
Ruby
#!/usr/bin/env ruby ## ## dynarows.rb ## ## This demos shows the use of the validation mechanism of the table ## and uses the table's cache (no -command or -variable) with a cute ## dynamic row routine. ## ## ( based on 'dynarows.tcl' included source archive of tktable extension ) ## require 'tk' require 'tkextlib/tkt...
Ruby
#!/usr/bin/ruby require 'tk' require 'tkextlib/tcllib/plotchart' TkCanvas.new(:background=>'white', :width=>400, :height=>200){|c| pack(:fill=>:both) Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0], [0.0, 100.0, 20.0]){ [ [0.0, 32.0], [10.0, 50.0], [25.0, 60.0],...
Ruby
#!/usr/bin/ruby require 'tk' require 'tkextlib/tcllib/plotchart' ############################### c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200) c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200) c3 = TkCanvas.new(:background=>'white', :width=>400, :height=>200) Tk.pack(c1,c2,c3, :...
Ruby
#!/usr/bin/ruby require 'tk' require 'tkextlib/tcllib/plotchart' ############################### # Set up a strip chart ############################### Tk::Tcllib::Plotchart::Stripchart.new([0.0, 100.0, 10.0], [0.0, 100.0, 20.0], :backgrou...
Ruby
#!/usr/bin/ruby require 'tk' require 'tkextlib/tcllib/datefield' require 'parsedate' Tk.root.title('Datefield example') my_date1 = TkVariable.new my_date2 = TkVariable.new my_date1.trace('w'){ begin t = Time.local(*(ParseDate.parsedate(my_date1.value))) my_date2.value = t.strftime('%A') rescue # ign...
Ruby
#!/usr/bin/ruby require 'tk' require 'tkextlib/tcllib/plotchart' ############################### c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200) c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200) Tk.pack(c1,c2, :fill=>:both, :side=>:top) ############################### # Set up a ...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/dial' ####################################### v_volume = TkVariable.new v_speed = TkVariable.new v_dir = TkVariable.new v_rot = TkVariable.new v_linked = TkVariable.new v_needle = TkVariable.new volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to...
Ruby
#!/usr/bin/env ruby require 'tk' require 'tkextlib/vu/charts' #---USAGE info = "...the heart of a Realtime Oscilloscope, where the PCIs joystick port gives 4 digtal inputs and 4 analog 8 bit values with an resolution of ~1 millisecond (!!!) running Realtime Linux. <p> creates DEMO.ps <B1-Motion> see what happens" put...
Ruby