Changing between panels on FXWizard

46 views Asked by At

I'm trying to set up an installation wizard, which has just 3 steps. However, I'm stuck with moving between panels. I understand that setCurrentPanel can be used to change the present panel, but when I just try to move it from 0 to 1, it raises an IndexOutOfBound. I've been all over the Internet, but can't find an example of FXWizard anywhere, only documentation. It would be great if someone could point me in the right direction.

class InstallationWizard < FXWizard

    def initialize(app)
        super(app, "Install Sync", nil, :width => 500, :height => 500)

        if self.currentPanel == 0
            hFrame1 = FXHorizontalFrame.new(self.getContainer())
            servLabel = FXLabel.new(hFrame1, "Server IP:")
            servTextField = FXTextField.new(hFrame1, 10)
            servButton = FXButton.new(hFrame1, "Connect!")

            servButton.connect(SEL_COMMAND) do
                serv = servTextField.text
                servTextField.text = nil
                getApp().reg().writeStringEntry("USER_DATA", "server", serv)

                message = FXMessageBox.information(self, MBOX_OK, "Sync", "Server: #{serv} on #{Mac.addr}")
            end
        elsif self.currentPanel == 1
            hFrame1 = FXHorizontalFrame.new(self.getContainer())
            usrLabel = FXLabel.new(hFrame1, "Username:")
            usrTextField = FXTextField.new(hFrame1, 4)

            pwdLabel = FXLabel.new(hFrame1, "Password:")
            pwdTextField = FXTextField.new(hFrame1, 4)
            pwdTextField.textStyle = FXTextField::TEXTFIELD_PASSWD
            pwdTextField.tipText = "Enter your password!"

            vFrame1 = FXVerticalFrame.new(self.getContainer())

            hFrame3 = FXHorizontalFrame.new(vFrame1)
            loginButton = FXButton.new(hFrame3, "Login!")

            loginButton.connect(SEL_COMMAND) do
                username = usrTextField.text
                password = pwdTextField.text
                usrTextField.text = nil
                pwdTextField.text = nil
                getApp().reg().writeStringEntry("USER_DATA", "username", username)
                getApp().reg().writeStringEntry("USER_DATA", "password", password)

                message = FXMessageBox.information(self, MBOX_OK, "Sync", "Username: #{username}, Password: #{password}")
            end
        elsif self.currentPanel == 2
            hFrame2 = FXHorizontalFrame.new(self.getContainer())
            showButton = FXButton.new(hFrame2, "Show!")
            showButton.connect(SEL_COMMAND) do
                puts getApp().reg().readStringEntry("USER_SELECTION", "home")
                puts getApp().reg().readStringEntry("USER_DATA", "username")
                puts getApp().reg().readStringEntry("USER_DATA", "password")
                puts getApp().reg().readStringEntry("USER_DATA", "server")
            end
        end

        self.advanceButton.connect(SEL_COMMAND) do 
            self.currentPanel = self.currentPanel + 1
        end

        self.cancelButton.connect(SEL_COMMAND) do 
            getApp().exit(0)
        end

        self.finishButton.connect(SEL_COMMAND) do 
            getApp().exit(0)
        end
    end

    def create
        super
        show(PLACEMENT_SCREEN)
    end

end
0

There are 0 answers