Dynamically changing widgets in FXRuby 
Author Message
 Dynamically changing widgets in FXRuby

I am attempting to learn FXRuby, and I'm running into a small problem,
and I'm not sure if what I'm trying to do is inappropriate in FOX, or
if it's an FXRuby thing, or if I'm just missing the big picture.

I am trying to create an application where the actual layout of the widgets
on the screen is not known at "initialize" time but rather is dynamically
updated based on the things that the user does:

If I call the "draw_display" method from within initialize, then the program
draws everything as it should be.  But if I select the File/Open menu, which
calls draw_display, it does not draw the FXTreeList on my screen.  Can someone
help me understand what I am failing to understand?

I would not have asked this question here, but I ransacked all of the examples
that I could with FXRuby, and none of them seem to do the precise thing I am
trying to do here, which makes me wonder if maybe I'm not supposed to be doing
this kind of thing in FOX...

Graciously,
Jacob

#--- snip here ---#
require 'fox'
include Fox
class MainWindow < FXMainWindow
  def draw_display

        (FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|
         LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|
         TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|
         TREELIST_EXTENDEDSELECT))



    1.upto(30) {|x|

    }
  end

  def initialize(app)
    super(app, "Main Window", nil, nil, DECOR_ALL, 0, 0, 900, 600)

    filemenu = FXMenuPane.new(self)
    FXMenuCommand.new(filemenu, "Open\tCtl-O").connect(SEL_COMMAND) {
      draw_display
    }
    menubar = FXMenubar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
    FXMenuTitle.new(menubar, "&File", nil, filemenu)


        LAYOUT_FILL_Y|SPLITTER_REVERSED|SPLITTER_TRACKING))

        FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,
        0,0,0,0, 0,0,0,0)
  end

  def create
    super
    show(PLACEMENT_SCREEN)
  end
end

if __FILE__ == $0
        $application = FXApp.new("Main", "FoxTest")
        $application.init(ARGV)
        MainWindow.new($application)
        $application.create
        $application.run
end
#--- snip here ---#
--

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.*-*-*.com/ - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Sun, 31 Jul 2005 07:14:56 GMT  
 Dynamically changing widgets in FXRuby

Quote:
> #--- snip here ---#
> require 'fox'
> include Fox
> class MainWindow < FXMainWindow
>   def draw_display

>         (FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|
>          LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|
>          TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|
>          TREELIST_EXTENDEDSELECT))


Quote:



>     1.upto(30) {|x|

>     }
>   end

Try that.  Fox widgets need to be explicitly 'created' when they are added after the
application.create call.  And beware calling your 'draw_display' from initialize now.  The widget
will be created in the first pass, then throw an error in the second pass (when it tries to create
it again).


Sun, 31 Jul 2005 09:14:31 GMT  
 Dynamically changing widgets in FXRuby

Quote:

> And beware calling your 'draw_display' from initialize now.  The widget
> will be created in the first pass, then throw an error in the second pass (when it tries to create
> it again).


in your 'draw_display' method and then call draw_display directly from
MainWindow#initialize, the sequence of events is:

  1. MainWindow#initialize instantiates (but does not
     create) a number of widgets, then calls draw_display.

  2. MainWindow#draw_display instantiates the tree list

     because you have not yet called FXApp#create.

-- Lyle



Mon, 01 Aug 2005 00:28:34 GMT  
 Dynamically changing widgets in FXRuby
Example at hand:
#--- snip here ---#
 require 'fox'
 include Fox
 class MainWindow < FXMainWindow
   def draw_display



     [snip]


Quote:

>when they are added after the application.create call.  And beware
>calling your 'draw_display' from initialize now.  The widget will be
>created in the first pass, then throw an error in the second pass (when
>it tries to create it again).

Yes!  Thank you so very much!  What I was missing was the 'create' method.
Now that I know that is the "magic" function which makes things appear on
the screen and see that there are indeed a couple of examples in FXRuby
that show how this works, but I overlooked them because I did not understand.

But thank you very much for helping me.  I now can do what I had hoped to
do in FXRuby, which is create a user interface on the fly based on input
files known only at runtime! =)

-Jacob
--

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Mon, 01 Aug 2005 01:45:14 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to Change Default Font Size for All Widgets Dynamically

2. FXRuby: Changing the options of FXTextField

3. FXRuby - changing cursor position

4. FXRuby: Tab control of widgets

5. FXRuby: switching visible widgets

6. Proposed Changes for FXRuby

7. FXRuby: Reacting on changing values of FXDataTarget

8. Change dynamically the desktop pattern ?

9. Could change JOIN in VIEW dynamically?

10. Dynamically change FontStyle and FontSize in Report

11. Dynamically changing File for a browse using SQL

12. CHanging Browse Labels Dynamically

 

 
Powered by phpBB® Forum Software