[fxruby-users] How do you enable a button for any option change in UI?

dave L dglnz at yahoo.com
Mon Mar 22 16:54:42 EDT 2010

Hi Paul,

you need to have this sort of thing.

have 2 buttons
1 enabled 1 not & when you click on the enabled button you disable it and enable the other.

there could be better ways but this I hope shows you how in a simple fashion.

def init
  @button1.enabled = false
@button1.enabled = true
@button2.enabled = false

@button2.enabled = true
@button1.enabled = false

if you want send via private email what you have and I can try to help you or do something to get you going.

in regards to writing to file try this...

this always OVER WRITES the data file. a+ appends onto the end of the file - all in the Rdocs for ruby 1.X.x

out = File.new('config.dat',"w+")

out.write "this is put to the config file\n"

out.write "this is another line in the config file\n"
out.write "this is a 3rd line"
out.write "Is this a 4th line?"


now what you should see if something like this (if i have it right - thinking off the cuff here :)

this is put to the config file
this is another line in the config file
this is a 3rd lineIs this a 4th line?

The '\n' is the newline character you need to put in to have a newline appear in the disk file.


--- On Tue, 23/3/10, Paul Carvalho <tester.paul at gmail.com> wrote:

> From: Paul Carvalho <tester.paul at gmail.com>
> Subject: [fxruby-users] How do you enable a button for any option change in UI?
> To: fxruby-users at rubyforge.org
> Received: Tuesday, 23 March, 2010, 7:58 AM
> I have an app that has 2 basic purposes:
> (1) configure options, (2) generate report.  Imagine a
> simple layout - for example, the standard FXRuby
> "button.rb" script.  In addition to the elements
> on that app, I have another button called "Save
> configuration".
> What I want to do is this: the 'save config' button
> is disabled by default when you start the app.  If the user
> makes *any* change to any of the options, I want the
> 'save config' button to automatically enable.
> Of course, that's my first problem.  Once I've
> figured out that part, I'll need to figure out how to
> read & write the options to a separate file.  Any help
> someone can provide me with this problem would be greatly
> appreciated.  Again, feel free to use the button.rb script
> as a working example, because that's what I'm using
> to try and figure this out.
> Thanks.  Paul.
> #yiv1224944298 #avg_ls_inline_popup
> {padding:0px
> 0px;margin-left:0px;margin-top:0px;width:240px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:13px;}
> -----Inline Attachment Follows-----
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users


More information about the fxruby-users mailing list