Dynamically updating using calls to a FXDialogBox class

View: New views
1 Messages — Rating Filter:   Alert me  

Dynamically updating using calls to a FXDialogBox class

by Eric Hutton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pulling my hair out here, and I've read many questions and answers related to this topic in the past, and have read the book.. but something just isn't clicking.

I'm importing some large text files into a SQL database, and I had set this up under my program using a call to a  Data_Import class I had setup prior to looking at setting up a GUI.  Now I'm trying to graft the GUI on top of my program, and I want to try and create a dialog box that will periodically update to notify the user where in the import process the program is.

my code layout is looking like this:

class Main_Window < FXMainWindow
    ....
    def import_customs_data  # called from a menu item
        @customs_file = ""
        find_customs_file = Get_Customs_File.new(self)  # this is a call to a class based on an FXFileDialog - works beautifully
        if find_customs_file.execute != 0
            @customs_file = find_customs_file.filename
        end
        if @customs_file != ""
            import_customs_file = Customs_Data_Import.new(self)
            import_customs_file.create
            import_customs_file.show(PLACEMENT_SCREEN)
            import_customs_file.import_customs_data(@customs_file)
           
        end
    end
    ...
end

class Data_Import <FXDialogBox   # I have a master class for data import, because and I want one dialog template for various data imports
    def initialize(owner)
        super(owner, "Importing Records", :width => 300, :height =>200)
        add_message_window
        add_terminating_button
    end
    def add_message_window
        @message_window = FXMatrix.new(self, 2, :opts => LMATRIX_BY_COLUMNS|LAYOUT_FILL)
    end

    def add_terminating_button
        buttons = FXHorizontalFrame.new(self,
            :opts => LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM)
        FXButton.new(buttons, "Cancel",
            :target => self,
            :selector => FXDialogBox::ID_CANCEL,
            :opts => BUTTON_NORMAL|LAYOUT_LEFT)
    end
end


class Customs_Data_Import < Data_Import
   
    def import_customs_data(customs_file_name)
        FXLabel.new(@message_window, "Reading customs records from file.")
        FXLabel.new(@message_window, Time.now.strftime("%H:%M:%S"))
        @message_window.create
        @message_window.repaint
        print "working"
        customs_data = File.readlines(customs_file_name)
        print customs_data.length, " customs records read from file. ==> ",
            Time.now.strftime("%H:%M:%S"), "\n"
        print "\n"
        print "Loading customs records into database. ==> ", Time.now.strftime("%H:%M:%S"), "\n"
        customs_data.each do |customs_entries|
        ...
end   


All that shows up now is the parent dialog window with the title "Importing Records", no buttons show up, nor the message window I'm trying to create... I kept the print statements in my code to see that the code is at least running through the calls to create and .update or .recalc or .repaint (tried them all) the message window, but my intention is to move those all over into the dialog window, by either appending them to the next row in the matrix window, or overwriting old windows or something... first I have to get ANY message showing up though. 

Once I get messages showing up, what I would also like to do is get some sort of spinner showing up beside the current message, showing that the program is working... so that would definitely require a dynamic update where you overwrite a message, rather than just appending a new line.

Any thoughts or suggestions are appreciated!

Eric Hutton

_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users