Get_value problems and more, beginner

Hello! I have just got in to WxRuby and i already enjoy it alot. But i
have some problem. I am doing a very simple port-scanner, very basic
socket.

“TCPSocket.open(ipaddress.chop, port)” - Like that.

But now i want to do it graphical. So, my thought is the following. I
have three fields, structured like this.

Then a 4th field to the right, where the output should be. But… How can
i take the values from my three fields.

Where i enter IP
Start-port-range
End-port-range

Save them in variables, then do the portscan with them? I know that
“get_value” exists. But i don’t really know how to apply it.

So. Short and consist.
I have 3 fields where i ask for user input, i want to save the values in
these fields in variables, then i will scan the target, and the output
from the scan shall happen in the “large” field.

Is that possible? :confused:
/Alexander

Hi Alexander,

Alexander L. wrote:

So. Short and consist.
I have 3 fields where i ask for user input, i want to save the values in
these fields in variables, then i will scan the target, and the output
from the scan shall happen in the “large” field.

Is that possible? :confused:

So long as you store a reference to the created TextCtrl field in a
variable, you can get the value using ‘get_value’

The code below will display a text field and a button. When clicked,
the button uses the ‘get_value’ method to retrieve the contents of the
text field.


require ‘wx’

class MyFrame < Wx::Frame
def initialize
super(nil, :title => “Controls”)

text_field = Wx::TextCtrl.new(self)
button = Wx::Button.new(self, :label => "Show Value")
evt_button(button) {p "Value: #{text_field.get_value}"}

main_sizer = Wx::BoxSizer.new Wx::VERTICAL
main_sizer.add text_field
main_sizer.add button
set_sizer main_sizer

end
end

Wx::App.run do
MyFrame.new.show
end

Does that help you move forward?

regards,

Peter.