Re: New GUI - oops again




Hi Bill

Thanks for the test and report.  There are many layout similarities between 
Mini and Touch. 

FileDialog is a process defined within tkemc itself.  I don't know how useful 
that will be to you because of the filenames and commands used in common by 
Fred P and I.  The bare Tk command is tk_getOpenFile.  It will work alone but 
better if you use some args that point to the directory and file type and 
such.

The fileDialog process used by tkemc is

-----
proc fileDialog {} {
    global programDirectory
    global programnamestring

    set types {
        {"All files" *}
        {"Text files" {.txt}}
        {"NC files" {.nc .ngc}}
    }
    set f [tk_getOpenFile -filetypes $types -initialdir $programDirectory]
    if {[string len $f] > 0} {
        set programDirectory [file dirname $f]
        set programnamestring $f
        emc_open $programnamestring
        loadProgramText
    }
}
-----

where the variable programDirectory is read from the ini file before this 
process is run using the command

set programDirectory [emc_ini "PROGRAM_PREFIX" "DISPLAY"].

Within fileDialog, programDirectory will be reset based on where the GUI user 
navigates by two activities

    set f   [tk_getOpenFile -filetypes $types -initialdir $programDirectory]

which assigns the retrun from tk_getOpenFile to a local variable "f" and

    if {[string len $f] > 0} {
        set programDirectory [file dirname $f]
        set programnamestring $f
    ...
    }

which tests the value of "f" and does stuff if it is greater than 0.

The capital letter in the name, programDirectory, suggests that this variable 
begins with a value from outside tkemc. 

The second variable critical to the operation of fileDialog is 
programnamestring.  The fact that is is all lowercase suggests that it is a 
locally created and manipulated variable.  It passes the full name of the 
part program selected here to tkemc's global namespace.  During the first 
read of tkemc by the shell, we define this variable like this. 

set programnamestring "none"

By giving it the value "none" the EMC can pick up on "no file selected" if 
the operator tries to run the interpreter without giving it a real filename.  
The load program into the interpreter is done with the line

        emc_open $programnamestring

because emc_open is an extension added to wish in the file emcsh.

(Knowing that some smarta$$ would name a file 'none' we use the fully 
qualified path name which at a minimum would be /none or C:\none) 

The last thing fileDialog does when it has gotten a filename is to load the 
text of that file into the text display at the bottom of tkemc's window.

Hope this helps

Ray



On Monday 07 April 2003 11:03 pm, you wrote:
> Hi Ray,
>
> Looked at the new GUI, pretty cool. I have finally started back working on
> my touchscreen GUI after a few months. I made a lot of changes in the last
> week or so, although I have been using it for quite a while. It works, but
> still needs a lot of work. I need to add an offsets menu and an editor
> after I get the following problem worked out. I have decided to scrap the
> file open dialog that I built and just use the tk_getOpenFile widget. For
> the life of me, I can't get that to work. I have just copied the code
> directly from your TkEMC (cut and paste) and whenever I try to run it I get
> an error
>
> invalid command name "tkFDialog"
>
> or
>
> cannot auto-load command "tkFDialog"
>
> Tried it on a TNG machine as well as a BDI 2.16 machine, same thing. The
> file dialog works fine from TkEMC as well as a test file I made using wish
> instead of emcsh, so Tk is on the system and seems to be working fine. Any
> ideas
>
> Bill
>
> > I seem to be having a bad day or two here.
> >
> > > mini-5-03.tgz.
> >
> > should read mini-4-03
> >
> > Thanks for pointing that out to me Robin.
> >
> > Ray




Date Index | Thread Index | Back to archive index | Back to Mailing List Page

Problems or questions? Contact