1# -*- coding: utf-8 -*- 2# 3# ttkprogress.rb -- 4# 5# This demonstration script creates several progress bar widgets. 6# 7# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp" 8 9if defined?($ttkprogress_demo) && $ttkprogress_demo 10 $ttkprogress_demo.destroy 11 $ttkprogress_demo = nil 12end 13 14$ttkprogress_demo = TkToplevel.new {|w| 15 title("Progress Bar Demonstration") 16 iconname("ttkprogress") 17 positionWindow(w) 18} 19 20base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true) 21 22Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, 23 :text=><<EOL).pack(:side=>:top, :fill=>:x) 24���������������������������������������������������������\ 25���������������"determinate"���������������������������������������\ 26���������������������������������������������������������������������������������������������������������\ 27������������������������������������������\ 28���������������"indeterminate"���������������������������������������\ 29������������������������������������(busy)������������������\ 30������������������������������������������������������������������������������\ 31������������������������������������������\ 32������������������������������������������������������������������������������������\ 33���������������������������������������ON/OFF��������������������������������������� 34EOL 35 36## See Code / Dismiss buttons 37Ttk::Frame.new(base_frame) {|frame| 38 sep = Ttk::Separator.new(frame) 39 Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2) 40 TkGrid('x', 41 Ttk::Button.new(frame, :text=>'コード参照', 42 :image=>$image['view'], :compound=>:left, 43 :command=>proc{showCode 'ttkprogress'}), 44 Ttk::Button.new(frame, :text=>'閉じる', 45 :image=>$image['delete'], :compound=>:left, 46 :command=>proc{ 47 $ttkprogress_demo.destroy 48 $ttkprogress_demo = nil 49 }), 50 :padx=>4, :pady=>4) 51 grid_columnconfigure(0, :weight=>1) 52 pack(:side=>:bottom, :fill=>:x) 53} 54 55frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true) 56 57p1 = Ttk::Progressbar.new(frame, :mode=>:determinate) 58p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate) 59 60start = Ttk::Button.new(frame, :text=>'Start Progress', 61 :command=>proc{ p1.start; p2.start }) 62stop = Ttk::Button.new(frame, :text=>'Stop Progress', 63 :command=>proc{ p1.stop; p2.stop }) 64 65Tk.grid(p1, '-', :pady=>5, :padx=>10) 66Tk.grid(p2, '-', :pady=>5, :padx=>10) 67Tk.grid(start, stop, :padx=>10, :pady=>5) 68start.grid_configure(:sticky=>'e') 69stop.grid_configure(:sticky=>'w') 70frame.grid_columnconfigure(:all, :weight=>1) 71 72