main_loop()
click to toggle source
# File lib/makeconf/gui.rb, line 107 def main_loop eval "#{@page[0]}(true)" Tk.mainloop() end
Object
# File lib/makeconf/gui.rb, line 3 def initialize(project) require 'tk' @project = project @page = [ 'intro_page', 'license_page', # TODO:'install_prefix_page', 'build_page', 'outro_page', ] @pageIndex = 0 @mainTitle = TkVariable.new @mainMessage = TkVariable.new @root = TkRoot.new() { title "Installation" } @mainTitleWidget = TkLabel.new(@root) { pack('side' => 'top') } @mainTitleWidget.configure('textvariable', @mainTitle) @mainFrame = TkFrame.new(@root) { height 600 width 600 background 'white' borderwidth 5 relief 'groove' padx 10 pady 10 pack('side' => 'top') } @mainLabel = TkLabel.new(@mainFrame) { background 'white' } @mainLabel.configure('textvariable', @mainMessage) @mainText = TkText.new(@mainFrame) { background 'white' } @cancelButton = TkButton.new(@root) { text "Cancel" command proc { exit 1 } pack('side' => 'left') } @nextButton = TkButton.new(@root) { text "Next" pack('side' => 'right') } @nextButton.configure('command', method(:next_page)) #nextButton.configure('command', proc { mainMessage.set_value 'You click it' }) @nextButtonEnable = true @backButton = TkButton.new(@root) { text "Back" command proc { prev_page } state 'disabled' pack('side' => 'right') } @backButton.configure('command', method(:prev_page)) @backButtonEnable = true update_buttons end
# File lib/makeconf/gui.rb, line 151 def build_page(display) if display @nextButtonEnable = false update_buttons @mainTitle.set_value 'Checking Configuration' @mainText.delete(1.0, 'end') @mainText.place('relx'=>0.0, 'rely' => 0.0) Thread.new { @mainText.insert('end', "Configuring.. ") Makeconf.configure_project(@project) @mainText.insert('end', "done\n") make = Platform.is_windows? ? 'nmake' : 'make' @mainText.insert('end', "Building.. ") system "#{make}" @mainText.insert('end', "done\n") @mainText.insert('end', "Installing.. ") system "#{make} install" @mainText.insert('end', "done\n") @mainText.insert('end', "\nAll tasks completed.") @nextButtonEnable = true update_buttons } else TkPlace.forget(@mainText) @mainText.delete(1.0, 'end') end end
# File lib/makeconf/gui.rb, line 139 def install_prefix_page(display) if display @mainTitle.set_value 'Installation Path' @mainText.insert('end', "choose an installation path") @mainText.place('relx'=>0.0, 'rely' => 0.0) Tk.getOpenFile else TkPlace.forget(@mainText) @mainText.delete(1.0, 'end') end end
# File lib/makeconf/gui.rb, line 112 def intro_page(display) if display @mainTitle.set_value 'Welcome' @mainLabel.place('relx'=>0.0, 'rely' => 0.0) @mainMessage.set_value "This will install #{@project.id} on your computer" else TkPlace.forget(@mainLabel) end end
# File lib/makeconf/gui.rb, line 122 def license_page(display) if @project.license_file.nil? license = 'No license information' else license = File.read(@project.license_file) end if display @mainTitle.set_value 'License Agreement' @mainText.insert('end', license) @mainText.place('relx'=>0.0, 'rely' => 0.0) else TkPlace.forget(@mainText) @mainText.delete(1.0, 'end') end end
# File lib/makeconf/gui.rb, line 107 def main_loop eval "#{@page[0]}(true)" Tk.mainloop() end
# File lib/makeconf/gui.rb, line 75 def next_page eval "#{@page[@pageIndex]}(false)" @pageIndex = @pageIndex + 1 eval "#{@page[@pageIndex]}(true)" update_buttons end
Generated with the Darkfish Rdoc Generator 2.