Re: A good menu tutorial?




Bruce Hartweg wrote:
Robert Hicks wrote:
suchenwi wrote:
Robert Hicks schrieb:

That does what I want it to do, so thanks for that suggestion. What do
those cascade names become assuming the foreach brings back directory
names of dir1, dir2, dir3. Do they become: .m.mLessons.dir1
.m.mLessons.dir2 and .m.mLessons.dir3
Hmm..
Tcl/Tk is very simple. But some reading man pages (in this case, menu)
still helps.

As my (maybe too brief) explanation showed, to add a cascade you'd best
specify a new menu. How to call this is up to you - just make sure its
name doesn't start with an uppercase letter (that's why I put a "m" in
front).

You can call [glob] separately for subdirectories (-type d) and files
(-type f). I'd suggest first to do the directories, create a cascade
for each,

.m.whatever.m$dir create cascade -label $subdir -menu [menu
.m.whatever.m$dir.m$subdir]

and recurse into them (call the same procedure for each again). Then do
the files, adding a simple command to the current menu.

general approach is dead on, but be *very* careful using externally
generated names (like filenames) directly as component of widget names,
if they contain a . you will blow up as the . is the widget seperator.
so I would either keep a simple 1-up counter to make the menu widget
name itself (keeping the displayed label the actual directory) or else
use string map to map any "." to "_" or something (and mayber spaces
too which don't necessarily break you but can cause headaches occasionally.

Bruce

Yes, I am not sure what I want to do here. The file format is going to
be a set one. I may create a simple ini file with something like
title=blah as the key/value then a user would just have to drop in the
file and update the ini file and I only have to parse that. Come to
think of it that is what i will do. It saves me from having to do
globbing and such to get directory and file names. I can use the
key/value to get the file name and title of the lesson and I can use
the section to denote the directory it resides in. I could even build a
wizard in the app to help create the ini section itself.

Hmmm, I will try that.

Robert

.



Relevant Pages

  • Re: A good menu tutorial?
    ... Tcl/Tk is very simple. ... But some reading man pages ... As my explanation showed, to add a cascade you'd best ... is the widget seperator. ...
    (comp.lang.tcl)
  • Re: deleting a cascade entry
    ... Menu widget. ... None of them are mentioned in the (ActiveState) Menu man ... and removing them? ...  $ME is the cascade menu entry. ...
    (comp.lang.perl.tk)
  • Re: deleting a cascade entry
    ... Menu widget. ... None of them are mentioned in the (ActiveState) Menu man ... includes 'cascade'. ... and removing them? ...
    (comp.lang.perl.tk)
  • Re: deleting a cascade entry
    ... I've been using the cascade, command, and separator methods of the ... Menu widget. ... None of them are mentioned in the (ActiveState) Menu man ... Until I try to delete an entry, ...
    (comp.lang.perl.tk)
  • deleting a cascade entry
    ... I'm running ActiveState build 813 on XP/Home. ... I've been using the cascade, command, and separator methods of the ... Menu widget. ...
    (comp.lang.perl.tk)