1

I want to write a small text-editor in Ruby for learning the basics. I want to show all the possible text-manipulation options in one single menu. Once the option is selected, the string typed in an Input box will be altered accordingly.

I am not following how to prepare this basic GUI.

5
  • 1
    What code have you written? How are we supposed to help if you don't show us what you've tried? Or, are we supposed to write it for you? Commented Apr 20, 2011 at 9:09
  • More info? Operating system & proposed GUI framework would help. Commented Apr 20, 2011 at 9:12
  • @the Tin Man: When the framework is uncertain, what code you expect? Commented Apr 20, 2011 at 9:49
  • @Mike: Windows 7. I tried Shoes, but documentation is very little. Commented Apr 20, 2011 at 9:50
  • "When the framework is uncertain, what code you expect?", then we'd expect you to say something like "I'd like recommendations for frameworks I can use in Ruby to develop the GUI." As is, your question doesn't state whether you've tried writing something and are stuck, or that you haven't written anything but have selected the framework and are learning the API, or whether you're in the framework selection process. Commented Apr 20, 2011 at 18:30

5 Answers 5

3

You can have a look at FXRuby. Here is a small tutorial to make a text editor using FXRuby.http://rubylearning.com/satishtalim/fxruby.html

Sign up to request clarification or add additional context in comments.

1 Comment

yes..wxRuby is also good..I have tried FXRuby and wxRuby also looks similar.
1

On Windows, your best bet is using JRuby and SWT. If you plan to switch to Mac OS X, you can think about MacRuby.

Comments

1

You can use visualruby, and you could write it in about an hour:

http://visualruby.net

You would build your window in the glade interface designer, then add a menu to your window with all your menu options. All of this can be done in the glade software so no code is required. Then you could give your menu options names that you reference later:

menuClear 
menuIndent
menuComment
menuQuit

etc.

You could have the editor itself be a textview named textview1.

Then your code could be:

class MyEditor

  def show
    load_glade(__FILE__)
    show_window()
  end


  def menuClear__clicked
    @builder["textview1"].buffer.text = ""
  end

  def menuIndent__clicked
    current_line = tab + current_line
  end

  def menuComment__clicked
    current_line = "#" + current_line
  end

  def menuQuit__clicked
    destroy_window
  end

end

MyEditor.new.show

I think its easier than any of the other toolkits, and its more robust because its GTK.

All of the above statement are explained on the website. Good luck.

Comments

0

Ruby got Tk builtin, or you can use ffi-tk, which is a bit closer to tcl/tk. ver is an example. tkdocs is quite comprehensive, and it's got a nice API imo. And the Text Widget is really powerful.

Comments

0

If you have previous Java/Swing experience you might want to look at JRuby and Monekybars.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.