A WorkLife FrameWork Blog
 

 

About A WorkLife FrameWork | Purchase

Creating a new Stylesheet: an exercise in refinement

Posted on: Tuesday, October 2, 2007 at 03:09 AM UT  Notebook Version

Many things are going into the next version of A WorkLife FrameWork, and I will write about them soon. In fact I have been busy with them and so haven't written to this blog for a while because of that.

Today a question was asked on MathGroup about how to create and save one's own stylesheet.  At first I answered the question in a pretty complex way.  But then I learned some more and posted an update.  Then after that, and after dinner, I sat down to write a function that would do the job automatically.   I decided that it would be easy to do this: to write a function that would create a new StyleSheet for you to reuse as needed based on modifications to style definitions that you have made to a particular notebook.  

It wasn't quite a simple as I first thought though, and I will perhaps have to modify it somewhat before releasing it into A WorkLife FrameWork.  Here is the code that I wrote...

Well, hang on a moment.  I really need to make a marketing announcement first...

If you are reading this you are most likely on the website for A WorkLife FrameWork.  Perhaps you have come here from MathGroup.  Whatever circuitous route has brought you here, you really should take a moment to download a trial copy of A WorkLife FrameWork.  It's a great product and will help you with all sorts of things. It extends Mathematica in all sorts of useful directions—and the simple function that follows is one of a huge number of such extensions.

Give it a go.  Please. And if you find it useful, it is quite inexpensive and is like getting several thousand hours of my consulting time  for about a single hour's cost.

Ok, so that's not enough to get you interested?  Then take a look at the screencasts to get a better sense of a small bit of A WorkLife FrameWork's scope and usefulness.

OK, I'm done with my marketing spiel.  Now on to the code—hot off the press with the ink still drying.

Here, first is the code (jump past it for continued discussion; also, you can download a Mathematica notebook with this blog post in it—including the code—by using the "Notebook" link at the end  of the post):

BE3400283395_1.gif

BE3400283395_2.gif

BE3400283395_3.gif

It turns out that this was trickier to do than I first thought.  The problem is not processing the notebook's private Stylesheet.  Rather the problem is figuring out how to get the NotebookObject for that Stylesheet notebook.   It's there, but the Mathematica function Notebooks[] doesn't show Stylesheet notebooks.  This is by design.  So one needs a trick to figure it out. And embedded in this code is a trick that I figured out.  

Now this piece of code seems to work fine (well, you should add a check to make sure that the notebook nb is open).

But, I started to write this blog posting and, as I was writing it I realized that I could do this in a much simpler way.  So between the previous two paragraphs I rewrote the code and came up with what follows.  But I decided to leave the previous bit of code above in this blog posting because it shows something that is pedagogically interesting—at least I think so, and I learned something...

So here is the revised version of the code (which also needs a check for whether the notebook, nb, is actually open. (That's easy to do, but the way I do it is to use a function, NotebookOpenQ, that is inA WorkLife FrameWork, but I want to make this posting independent of that.  One way to do it is to evaluate NotebookInformation[nb] and if it doesn't return $Failed then nb is open...)

The function FE`InstallDialog`InstallDialogFunc is not documented in Mathematica, but it does the job that is required.
  
Normally one would try to use

FrontEndExecute[FrontEndToken["Install"]]

which is documented.  However this doesn' t work.  This is because, although the Install FrontEndToken is documented, it actually is not implemented in Mathematica.  I checked this out with the developers at Wolfram Research and they say that it is a documentation oversight that it is included in the documentation (though I personally think that it should just be implemented) and that the internal function FE`InstallDialog`InstallDialogFunc is what can be used instead.   Of course this makes the code slightly fragile as this function, or its name, may change in future versions of Mathematica.   But for now the function does work ...

Here's the revised code:

BE3400283395_4.gif

BE3400283395_5.gif

BE3400283395_6.gif

BE3400283395_7.gif

Now, that really is a bit simpler.  I will sit on it a bit, add a bit of functionality, and then add it to the StyleSheetsPalette for A WorkLife FrameWork for easy use.

Perhaps I should have thought a bit more before coding the first version, but I learned something from the process...

So, I hope that you find this useful.

BE3400283395_8.gif Now, go download the fully functional trial version of A WorkLife FrameWork. It's worth spending some time with...

Permalink | Notebook Version | Comments | Send Comment...

Recent Posts

Blogged From
A
WorkLife FrameWork

RSS Feed

8/4, 2009; 8:53 PM:
Documenting Screencast
11/19, 2008; 11:28 AM:
Mathematica 7 and A WorkLife FrameWork 3.0
11/17, 2008; 3:51 PM:
A Notebook Tagging Tutorial
4/18, 2008; 3:41 PM:
The Mathematica Documentation Center
3/2, 2008; 4:01 PM:
Security Tools
12/10, 2007; 12:26 AM:
December Discount
10/1, 2007; 11:09 PM:
Creating a new Stylesheet: an exercise in refinement
7/28, 2007; 3:04 PM:
Where is WorkLife Going? And why was version 2.0 ready when Mathematica 6 was released?
7/17, 2007; 10:28 PM:
A Practical Matter: Restarting WorkLife
7/10, 2007; 11:12 PM:
Almost nothing to do with A WorkLife FrameWork, but time will tell...
6/28, 2007; 1:01 PM:
A WorkLife FrameWork: It is Many Applications...
6/19, 2007; 10:59 AM:
A New Screencast: Getting Started
6/15, 2007; 10:33 AM:
Notebook History comment...
6/10, 2007; 10:07 PM:
Nonlinear Work Habits and Tagging
6/10, 2007; 6:29 PM:
A Palette for Standard Packages
6/9, 2007; 11:19 AM:
A discussion
6/3, 2007; 10:03 PM:
A MathGroup Posting
5/28, 2007; 9:33 PM:
A WorkLife FrameWork is now compatible with version 6 of Mathematica
5/22, 2007; 9:36 PM:
Email Analysis Tools
5/22, 2007; 9:27 AM:
The Palettes Menu
5/20, 2007; 11:14 PM:
Soon, very soon...
5/3, 2007; 11:09 AM:
Mathematica 6 Released: A WorkLife FrameWork 2.0 to follow very soon...
3/21, 2007; 1:50 PM:
A WorkLife FrameWork mention on MacinTouch
2/22, 2007; 1:40 PM:
More screencasts...
2/19, 2007; 12:42 AM:
New Screencasts
12/30, 2006; 7:51 PM:
Organizational Choices
11/26, 2006; 10:54 PM:
Updated Version of A WorkLife FrameWork.
11/10, 2006; 12:30 AM:
A quote and a testimonial...
11/6, 2006; 2:09 PM:
Version 1.1 on its way
10/31, 2006; 3:32 PM:
Another blog mention of A WorkLife FrameWork
10/23, 2006; 10:54 AM:
Finding A Diary or Notebook
10/10, 2006; 9:45 PM:
At the Wolfram Technology Conference
10/8, 2006; 11:35 AM:
The Wolfram Technology Conference
9/27, 2006; 10:51 AM:
Menu Items on Custom Palettes
9/21, 2006; 10:50 AM:
A Tip: Multiple disks or partitions
9/20, 2006; 3:57 PM:
A bit of Blogosphere notice
9/18, 2006; 9:24 PM:
Opening a set of files
9/14, 2006; 11:25 PM:
An Email Trick--slightly advanced
9/14, 2006; 11:08 PM:
The most current version...
9/11, 2006; 1:00 PM:
Finally Released!

Archive


Links
Mathematica
Mathematica Google Group
Scientific Arts
WorkLife

All material on this website Copyright © 2005-2009, Scientific Arts, LLC.