[R] MenuRead() Question

Keith Chamberlain Keith.Chamberlain at colorado.edu
Sun Mar 26 20:48:36 CEST 2006


Dear Gabor & Philipe,

Thank you for clarifying regular expressions, and how tk menus are
demarcated in menus.txt. Regular expressions are beginning to make sense for
me, and the menu is now being added properly to the tk window.

regexpr("^[$]Tk[.].+/", menu)...
If I understand better, the expression is matching "$Tk." but since "$" and
"." have special meanings in regular expressions, they need to be in
brackets so that they are interpreted literally.

Rgds,
KeithC.

-----Original Message-----
From: Philippe Grosjean [mailto:phgrosjean at sciviews.org] 
Sent: Sunday, March 26, 2006 9:49 AM
To: Keith Chamberlain
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] MenuRead() Question

Hi Keith,

If you want to define a Tk menu using MenuRead() and a text file to 
define your menu, you have to start it with "Tk.". That way, MenuRead() 
recognizes that it is a Tk menu. So, rewrite your menu definition file as:

 > <menu.txt - in RHOME>
 > $Tk.KSesnMain
 > |$MenuTest
 > ||Objects        ~~ ls()
 > ||-
 > ||Path	   ~~ search()

Note also that KSesnMain must point to a valid Tk window previously 
constructed.
Best,

Philippe Grosjean


Keith Chamberlain wrote:
> Dear List-mates,
> 
> I think the difficulty I'm having is localized to the MenuType() call made
> from within MenuRead(). I'm not used to seeing text operations such as "^"
> or "[]", so am having trouble understanding what's going on.
> 
> I'm interested in understanding the regular expression:
> regexpr("^[$]Tk[.].+/", menu), and why it my menus.txt file is not
returning
> at that point. 
> 
> ?regex explains that the "^" symbol excludes the text enclosed in brackets
> what is in the character string in following brackets, so a bunch of
> matching on string vectors going on that I don't understand well enough
yet.
> Do I need to install PCRE-6.6 for this to start working?
> 
> Rgds,
> KeithC.
> 
> 
> 
> -----Original Message-----
> From: Keith Chamberlain [mailto:chamberk at colorado.edu] 
> Sent: Saturday, March 25, 2006 4:26 PM
> To: 'r-help at stat.math.ethz.ch'
> Cc: 'Philippe Grosjean'
> Subject: MenuRead() Question
> 
> Dear List-mates,
> 
> I'm trying to read a tk window menu from a file using {svWidgets} and
> 'menus.txt' but am receiving Warnings without seeing the desired
> consequences of the call.
> 
> library(svWidgets)
> tkWinAdd("KSesnMain",title="kLab Session Manager for R", pos="+0+0")
> MenuRead(file="menus.txt")
> 
> Warning messages:
> 1: Unrecognized menu type for $KSesnMain/MenuTest in: MenuType(menu) 
> 2: Unrecognized menu type for $KSesnMain/MenuTest in: MenuType(menu) 
> 3: Unrecognized menu type for $KSesnMain/MenuTest in: MenuType(menu) 
> 4: Unrecognized menu type for $KSesnMain/MenuTest in: MenuType(menu)
> 
> <menu.txt - in RHOME>
> $KSesnMain
> |$MenuTest
> ||Objects  ~~ ls()
> ||-
> ||Path	   ~~ search()
> 
> Please Advise,
> KeithC.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list