Hello,
I was having problems with my GUI freezing if you clicked off of it when
it was running or if it was processing a large file. After researching
the forum, I found a thread that dealt with the problem by adding a
timer and Thread.pass to the App. This solved the problem of the GUI
freezing or hanging.
However, it has caused the program to run very slowly. What use to take
only a few seconds now takes a few minutes. People will be processing
large text files with this program so speed is important.
Thanks in advance for any help.
Joe
Ruby code:
begin
require ‘rubygems’
rescue LoadError
end
require ‘rubyscript2exe’
require ‘wx’
include Wx
require ‘Bogus_Frame.rb’
require ‘bogus_conts.rb’
include Process
RUBYSCRIPT2EXE.lib = [“Bogus_GUI.xrc”]
RUBYSCRIPT2EXE.lib = [‘Bogus_Frame.rb’]
RUBYSCRIPT2EXE.lib = [‘bogus_conts.rb’]
class BogusFrame < BogusBase
include Bogus_code
def initialize
@ext_def_source = “.txt”
@ext_def_result = “.txt”
super
evt_button(source_button) {|event| source(event)}
evt_button(result_button) {|event| result(event)}
evt_button(start_button) {|event| main}
end#def initialize
def source(event)
source_path = file_selector(
“Select the file to load”,
“”, “”,
@ext_def_source,
“CSV (.csv)|.csv|Plain text
(.txt)|.txt|All files (.)|.”,
CHANGE_DIR,
self
)
if source_path == nil
return nil
else
@source_textbox.clear
@source_textbox.append_text(source_path)
end
@ext_def_source = source_path[/[^.]*$/]
end#end def source
def result(event)
result_path = file_selector(
“Select the file to load”,
“”, “”,
@ext_def_result,
“CSV (.csv)|.csv|Plain text
(.txt)|.txt|All files (.)|.”,
CHANGE_DIR,
self
)
if result_path == nil
return nil
end
# it is just a sample, would use SplitPath in real program
@ext_def_result = result_path[/[^.]*$/]
@result_textbox.clear
@result_textbox.append_text(result_path)
end#end def source
end#end Class
class BogusApp < App
def on_init()
t = Wx::Timer.new(self, 55)
evt_timer(55) { Thread.pass }
t.start(1)
BogusFrame.new.show
end
end
BogusApp.new.main_loop()