I have an interesting problem. I have a dialog which refuses to go away
once it has finished it’s associated code.
Here is the code:
class DBPopulateDialog < Wx::Dialog
def initialize(parent, id, title, pos, size, style, name)
super(parent, id, title, pos, size, style, name)
sizer = Wx::BoxSizer.new(Wx::VERTICAL)
@server = Wx::TextCtrl.new(self, -1, "Server",
Wx::DEFAULT_POSITION,
Wx::DEFAULT_SIZE)
@username = Wx::TextCtrl.new(self, -1, “Username”,
Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE)
@password = Wx::TextCtrl.new(self, -1, “Password”,
Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TE_PASSWORD)
@tree_base = Wx::TextCtrl.new(self, -1, “LDAP Tree Base”,
Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE)
sizer.add(@server, 1, Wx::EXPAND|Wx::ALL, 5)
sizer.add(@username, 1, Wx::EXPAND|Wx::ALL, 5)
sizer.add(@password, 1, Wx::EXPAND|Wx::ALL, 5)
sizer.add(@tree_base, 1, Wx::EXPAND|Wx::ALL, 5)
button_sizer = create_button_sizer(Wx::OK|Wx::CANCEL)
sizer.add(button_sizer, 0, Wx::EXPAND|Wx::ALL, 5)
# Okay Button Event!!!!
evt_button(self.get_affirmative_id()) { |event| on_okay() }
set_sizer(sizer)
show()
end # initialize
# Collect computer records from Directory and add to database
def on_okay()
ldap = Net::LDAP.new :host => @server.get_value, :port => 389,
:auth
=> { :method => :simple, :username => @username.get_value, :password =>
@password.get_value }
filter = Net::LDAP::Filter.eq("objectcategory",
“CN=Computer,CN=Schema,CN=Configuration,#{@tree_base.get_value}”)
# We don't want to return a result set as it could be pretty huge
and
we don’t need it.
# We are treating the container name as the group name here.
ldap.search(:base => @tree_base.get_value, :filter => filter,
:return_result => false) do |record|
computer_name = record.cn.to_s
begin
os = record.operatingsystem
rescue
os = ‘’
end
lab = record.dn.split(’,’)[1].split(’=’)[1]
# Check db for lab and add it if it isn't already there
unless Lab.find :name => lab
lab = Lab.new(:name => lab)
lab.save
lab = lab.name
end
# Save machine record
machine = Computer.new(:name => computer_name, :os => os,
:location
=> lab)
machine.save
end
log_file = File.open(“log.txt”, “a”); log_file.puts “\n\nFinished
populate next instruction is close\n\n”; log_file.close
self.close()
end # on_okay
end # DBPopulateDialog class
After filling out the proper information and clicking on okay the data
is
populated however when it finishes the dialog hangs around. Furthermore
it
won’t close when you click on Cancel or the Window close widget (the X
in my
case). The log line executes just fine, the dialog just refuses to
close.
-Glen
–
“Hey brother Christian with your high and mighty errand, Your actions
speak
so loud, I can’t hear a word you’re saying.”
-Greg Graffin (Bad Religion)