[fxruby-users] Getting fewer paints per second than I expected

Joel VanderWerf vjoel at path.berkeley.edu
Sun Nov 5 19:32:48 EST 2006


Joel VanderWerf wrote:
...
> That example didn't do any formatting, but there is a #field method that 
> lets you use various %-escapes to do formatting and also to line things 
> up using a FXMartix, perform validation, group radio buttons, add check 
> buttons, and so on. These are all connected (in both directions) to ruby 
> attrs using the observable mechanism.
...
> [1] http://raa.ruby-lang.org/project/observable/
> [2] http://raa.ruby-lang.org/project/foxtails/

Sourceforge seems to be down so just for the heck of it here is another 
example (going a bit OT) of fields with the matrix, validation, 
radio/check, and observable features.

The output of the program, after entering data as shown in the attached 
PNG, is as follows:

$ ruby ship-fields.rb
[#<Ship foo, sailboat, (1.0,2.0), enabled=false>, #<Ship bar, speedboat, 
(3.0,4.0), enabled=true>]

The full program is attached, but this is the heart of it:

matrix = FXMatrix.new(self, 8,
   MATRIX_BY_COLUMNS|FRAME_THICK|LAYOUT_FILL_X)

# The %| character separates fields into different cells of the matrix.
field(matrix,
   " %| name %| x %| y %| speedboat %| sailboat %| steamer %| enabled")
   # this just adds some header labels

ships = [Ship.new, Ship.new]
ships.each_with_index do |ship, i|
   f = field(matrix, "#{i} %| %s %| %6.2f %| %6.2f %| %r %| %r %| %r %| %v",
     # %r is radio, %v is check
     [ship, :name],
     [ship, :x],
     [ship, :y],
     [[ship, :kind], "speedboat"],
     [[ship, :kind], "sailboat"],
     [[ship, :kind], "steamer"],
     [ship, :enabled]
   )
   f.valid([ship, :x]) {|x| x >= 0 and x < 100}
   f.valid([ship, :y]) {|y| y >= 0 and y < 100}

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ship-fields.png
Type: image/png
Size: 5529 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20061105/075759e4/attachment.png 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ship-fields.rb
Url: http://rubyforge.org/pipermail/fxruby-users/attachments/20061105/075759e4/attachment.pl 


More information about the fxruby-users mailing list