frame files in a toplevel file 
Author Message
 frame files in a toplevel file

I have a bunch of files named something like frame1.tcl, frame2.tcl, and so
on. These files contain:

frame .f1
pack .f1
#create various controls like f1.myButton...

I have a testFunctions.tcl file that includes the following in a proc
openTestWindow {} {...

set title "My Tests"
toplevel .t -bd 10
wm title .t $title

#the above code seems fine

source ./framedir/frame1.tcl
source ./framedir/frame2.tcl

frame .t.f1
pack .t.f1
frame .t.f2
pack .t.f2

Instead of putting my frames into my toplevel window, my frames end up in
the window where the File->Open button is. I think it's just getting the
buttons in the frame directly from the source command (which I think I
need to access the frame files in another directory)

I can get this to work if I make this one huge file, and code each control
t.f1.b1, but I just can't believe I have to make the code that brittle.

Any thoughts would be greatly appreciated.

Thanks,
Randy



Mon, 16 Jul 2007 03:06:52 GMT  
 frame files in a toplevel file

Quote:

> I have a bunch of files named something like frame1.tcl, frame2.tcl, and so
> on. These files contain:

> frame .f1
> pack .f1
> #create various controls like f1.myButton...

> I have a testFunctions.tcl file that includes the following in a proc
> openTestWindow {} {...

> set title "My Tests"
> toplevel .t -bd 10
> wm title .t $title

> #the above code seems fine

> source ./framedir/frame1.tcl
> source ./framedir/frame2.tcl

> frame .t.f1
> pack .t.f1
> frame .t.f2
> pack .t.f2

> Instead of putting my frames into my toplevel window, my frames end up in
> the window where the File->Open button is. I think it's just getting the
> buttons in the frame directly from the source command (which I think I
> need to access the frame files in another directory)

> I can get this to work if I make this one huge file, and code each control
> t.f1.b1, but I just can't believe I have to make the code that brittle.

no the source command doesn;t have anything to do woth the frame,
you are explicitly calling frame .f1 which says a frame f1 is created
as a chilkd of the "." toplevel (which is the initial default top
level). you need the .t.f1 if you want it as a parent of t. to avoid
hard coding instead of having your code in global scope of your sub file
put it in a proc that takes the parent frame as an argument

proc build {parent} {
   frame $parent.f1
    ... an so on

Quote:
}

the if you say
        build ""
it gets put in the default top level, but
        build .t
will put it in your new top level.

Bruce



Mon, 16 Jul 2007 03:29:50 GMT  
 frame files in a toplevel file

Quote:

> I can get this to work if I make this one huge file, and code each
control
> t.f1.b1, but I just can't believe I have to make the code that

brittle.

I'm not positive that I understand your question exactly.  But if
you're asking about a strategy for building GUIs components into
toplevels or other locations, I can suggest a style.

For each block of GUI stuff that you want to build, put all the
construction commands into a proc which accepts an argument for the
parent widget.  For example,

  proc build_frame1 { w } {
      button $w.b1 ...
      button $w.b2 ...
      grid $w.b1 $w.b2 ...
  }

Then you can call this from your main program:

  source frame1.tcl
  toplevel .myTop
  build_frame1 .myTop

Or you can build frame1 into any other toplevel or frame.  Just one
caution.  This style doesn't mix perfectly with the default toplevel
"." because you can't name a button widget "..button1".

Bob
--

Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Mon, 16 Jul 2007 03:34:01 GMT  
 frame files in a toplevel file
Many, many thanks! That was exactly what I needed.

Randy



Mon, 16 Jul 2007 04:14:28 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How do I pack things in a frame in a toplevel frame

2. Frame in Toplevel

3. container frame w/toplevel problems (win98)

4. toplevel & embedded frame geometry

5. Creating toplevel window frame with titlebar only

6. toplevel with window frame only

7. -visual option for frame and toplevel widgets

8. Importing flat text files from a main frame

9. VW: helpauth (frame-to-help-file) - illustrations?

10. an image file of my visible frame

11. Frame-maker mif files

12. How to load frame from another file?

 

 
Powered by phpBB® Forum Software