在FXWizard上的面板之间切换

时间:2015-06-25 05:22:52

标签: ruby shoes wxruby fxruby

我正在尝试设置一个只有3个步骤的安装向导。但是,我坚持在面板之间移动。我知道setCurrentPanel可用于更改当前面板,但是当我尝试将其从0移动到1时,它会引发IndexOutOfBound。我一直在互联网上,但无法在任何地方找到FXWizard的例子,只有文档。如果有人能指出我正确的方向,那就太好了。

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 个答案:

没有答案