Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7507 > unrolled thread
| Started by | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| First post | 2012-01-01 07:30 +0000 |
| Last post | 2012-01-01 07:30 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
What is the recommended way to set up definitions for or initialize a palette? Szabolcs Horvát <szhorvat@gmail.com> - 2012-01-01 07:30 +0000
| From | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| Date | 2012-01-01 07:30 +0000 |
| Subject | What is the recommended way to set up definitions for or initialize a palette? |
| Message-ID | <jdp22a$rpp$1@smc.vnet.net> |
Dear MathGroup,
Suppose we need to create a palette with several buttons.
These buttons do complex tasks and need to share some functions (i.e.
there's a set of custom functions that several of the buttons might
call). These functions may also depend on some standard packages.
Question: What is the best way to define these functions, so they can be
used by the palette?
I'd prefer to make the palette as self-contained as possible, and open
it from the Palettes menu (i.e. it is not convenient to have the palette
open as the side effect of loading a package).
Some things to point out:
* This must work even when the kernel
* I am not completely sure if it is necessary to use fully qualified
names (i.e. JLink`JavaNew instead of JavaNew) in the code if the
packages that are being used are not guaranteed to be loaded when
the palette is opened.
* I'm interested in both one-button and multi-button palette solutions.
-------------8<-------------
Here's a simplified example to show what I'm doing currently (this is
different code from what I have and is only for illustration). I'm sure
there's a lot of room for improvement!
button=Button["do it!",
Module[{},
(* one-time initialization *)
If[!ValueQ[myPalette`defined],
Needs["GraphUtilities`"];
myPalette`defined=True;
myPalette`doIt[] := Print["done!"];
];
(* button functionaliry *)
GraphUtilities`GraphPath[{1->2},1,2]; (* use package function *)
myPalette`doIt[];
]
]
CreatePalette[button]
--
Szabolcs Horv=E1t
Mma QA site proposal: http://area51.stackexchange.com/proposals/37304
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web