Question about using ruby and gtk to make an app

Discussion in 'Ruby' started by David Torres, Mar 25, 2007.

  1. David Torres

    David Torres Guest

    I have a question about using ruby and ruby-gtk2. I have a simple gui
    and am using SourceView as my text buffer and have added a menu to open
    and save files. My question is how in the world to I open a file and
    display it within my buffer?

    so far my open method is:

    callback_open = Proc.new {
    p "Open is called."
    dialog = FileChooserDialog.new("Open File",nil,
    FileChooser::ACTION_OPEN,nil,
    [Stock::CANCEL,Dialog::RESPONSE_CANCEL],
    [Stock::OPEN,Dialog::RESPONSE_ACCEPT])
    if dialog.run == Dialog::RESPONSE_ACCEPT
    @filename = #{dialog.filename}
    file = File.open(@filename)

    }

    after the file variable line I have tried different things to actually
    add the text to the buffer but none seem to work. I checked the API but
    I'm not sure if their is a TextBuffer method that I can use to read in
    the file line by line.

    Any help would be appreciated.

    David Torres

    --
    Posted via http://www.ruby-forum.com/.
    David Torres, Mar 25, 2007
    #1
    1. Advertising

  2. Chapter 2: GUI Toolkits for Ruby
    http://www.syngress.com/book_catalog/183_Ruby/sample.htm

    This is a long but good free sample chapter from the _Ruby Developer's Guide_.

    The section on "Using the Glade GUI Builder" (gtk) is nice, but I wish
    maybe for one or two more full examples of it. I think glade or
    glade-type tools can have a big impact by keeping the GUI and your
    application as interchangeable parts. It is also multi-platform.

    Author: Michael Neumann
    ISBN: 1928994644
    Syngress.com
    January 18, 2002
    New Price: $29.95 (The free sample chapter is a mini-book on GUI toolkits)
    Demetrius Gallitzin, Mar 26, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simple gtk+ app, seg fault

    , May 28, 2007, in forum: C Programming
    Replies:
    1
    Views:
    409
    Richard Heathfield
    May 28, 2007
  2. Replies:
    2
    Views:
    516
  3. Gergely Kontra
    Replies:
    2
    Views:
    248
    Joao Pedrosa
    Jun 18, 2004
  4. thomaswong
    Replies:
    0
    Views:
    88
    thomaswong
    Jun 8, 2007
  5. Alex Shulgin
    Replies:
    1
    Views:
    176
    thefed
    Nov 21, 2007
Loading...

Share This Page