From: Joel VanderWerf Date: 2006-05-27T02:18:03+09:00 Subject: Re: FXRuby - Howto remember some default settings as specified by the user ? Nuralanur@aol.com wrote: > Dear all, > > in an FXRuby GUI, I want to give the user many choices and I am searching for > a way to let FXRuby remember these upon the next start of the GUI > application. This is what I use with FXRuby (but it's not dependent on FXRuby or even on GUI): http://redshift.sourceforge.net/preferences/ A simple example (in terms of a hypothetical GUI lib): require 'preferences' PREFS = Preferences.new("/tmp/prefs") class Window attr_accessor :x, :y def initialize PREFS.register_pref_key self, "my app/window" PREFS.register_pref_var self, :x, :y => "default_y" end def run @x = 7 # emulate user's interaction end end Window.new.run PREFS.save An example is in examples/foursplit-prefs.rb. It remembers the positions of two four-splitters. It includes an optional method to make a reasonable cross-platform guess of where preference files should be (e.g. APPDATA on win32). The storage format is YAML, of course. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407