Tag Info

Hot answers tagged

9

It turned out that the MathematicaClosingDialog.nb is a nice example for a graphical user interface that solely uses the FrontEnd MathKernel. On the downside, one has to deal with low-level code. First I made a copy of the original MathematicaClosingDialog.nb, renamed it as MathematicaClosingDialog_Default.nb, and then imported it into a notebook: nb = ...


7

If you want full flexibility you should try EventHandler and graphics primitives. If you can decipher the following example you will get the idea: color = Black; positions = Position[DiskMatrix[5], 1]; disks = {color, Disk[#, 0.4]} & /@ positions; eventHandler[item : {c_, obj_: Disk[p_, _]}] := {c, EventHandler[obj, "MouseClicked" :> (disks = ...


7

Here's a walkaround: Manipulate[ x, Row @ List @ EventHandler[ Checkbox[Dynamic[x]], {"MouseDown" :> (x = True), "MouseUp" :> (x = False)}] ]


7

it is not etirely clear for what you need that, but I think the best way to store data within a Notebook so that it is available in the next session is the TaggingRules option. This is how you could store data for a there: CurrentValue[EvaluationNotebook[],{TaggingRules,"dataset-name"}] = data; And this is how you can read it: data = ...


6

I guess all the important information can be found in the tutorial, specifically in the subsection Access to the Java Object Layer There, you see that you can easily extract the class that is used for widgets << GUIKit` ref = GUIRun[Widget["Label", {"text" -> "Stay afloat!"}]] First[ref] (* « JavaObject[com.wolfram.guikit.swing.GUIKitJFrame]» ...


6

TabView[KnotData[#, "BraidWordNotation"] -> Labeled[Graphics[KnotData[#, "BraidDiagramData"]], Style[KnotData[#, "AlexanderBriggsNotation"], Large], {{Right, Bottom}}] & /@ Take[KnotData[All], {2, 6}], ControlPlacement -> Left, Alignment -> Center]


5

Step 1 As a very quick example of how one might start, with the limitation of only one "type" available: convert[Grid[m_?MatrixQ, ___]] := m[[All, All, 1]] Defer[convert]@Grid[ConstantArray[RadioButton[], {4, 7}], Spacings -> {0.2, 0}] Which outputs: You then make a selection: And evaluate it (the output), yielding: {{False, False, False, ...


4

My approach to this task would be to create new Input Cells within the notebook, that have the same structure as newly typed in symbol definition. createNewSymbol[] := Module[{importFileName = SystemDialogInput["FileOpen", ".txt"]}, With[{importedData = If[StringQ@importFileName, Import[importFileName, "Table"]], symName = ...


4

Something, that more or less does what you asked for, can be achieved by creating a hidden InitializationCell using a DynamicWrapper DynamicWrapper["xxx", If[foo == 23, MessageDialog["You guessed it!"], MessageDialog["You've guessed the right variable name, but not the right value yet."]]]


4

Ok, I read it again and again and I think I know what you are after. Here's quick fix/adjustment to make this thing a valid controller: SetAttributes[customColorSetter, HoldFirst] customColorSetter[var_] := ( If[! MatchQ[var, _RGBColor], var = Black]; Delete[ FrontEndResource["RGBColorValueSelector"][[1, 1]], {{1, 1}} ] /. ...


3

My comment in Manipulate form: func = {x^2 + x y + y^2}; Manipulate[ D[func, variable], {variable, {x, y}} ] The control that Manipulate uses is the SetterBar[Dynamic[variable], {x, y}] of my comment.


3

Rough approach: Tooltip resources are stored in FileNameJoin[{ $InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", "ToolTip.tr"}] In order to not mess with installation directory you can copy this file to $UserBaseDirectory/SystemFiles... and replace labels you want. For example: @@resource ToolTipCut Cut (replace this line ...


3

Edit I've updated my answer entirely since the updated question First Issue As detailed in the documentation for Initialization, this expression is not evaluated until after the content of the DynamicModule has been evaluated and not until "the construct is first displayed". This requires that any Initialization variable must be wrapped in Dynamic to be ...


3

Not sure about general concept but maybe you can use this minimal example and extend/adjust to your needs: Grid[{{ ListPicker[ Dynamic[selectList, (selectList = #; re = Select[selectList, #[[3]] === "Yes" &]) &], dataImport] , Dynamic @ If[TrueQ[re === {}], "", {"Include ...


3

Your problem is the Set. Set means you're assigning something to a variable (=), x2 Sin[x2] is not a variable. Try Equal[] instead, this is equivalent to ==. Vars = {{(x1) Cos[x2], Sin[x2], 0, (x3) (Sin[x2])}, {(Cos[x2]) (Sin[x4]), (x3) Cos[x4], 1, x1}}; Const = {{1, 0, 0, 1}, {0, 1, 1, 2}}; MapThread[Equal, {Vars, Const}, 2] yields the output: {{x1 ...


3

One can use $Pre to check if an input expression defines the correct variable and is doing so using the correct value. SetAttributes[check, HoldAll] check[new_Set] := (Print["You guessed it!"]; new) /; HoldForm@new == HoldForm@Set[foo, 23] check[new_Set] := (Print[ "You've guessed the right variable name, but not the right value yet."]; new) /; ...


2

Not sure if it is what you are after: action[dog_] := Print@StringForm["take dog no.`` for a walk", dog]; RadioButtonBar[Dynamic[dog, (dog = #; action[dog]) &], {1, 2, 3}]


2

I can confirm that this occurs (using the above code and clicking "panel format…") using Mathematica v.10.0.0 on OS X 10.9.4 (64-bit). I can't provide any further help on the MWE for this, as I'm still learning to use MMA as a coding language, rather than a fancy CAS. I've uploaded a copy of the OS X crash log here. EDIT: As Mr. Wizard observed, this ...


2

AFAIK there is no ready to use functionality for this in Mathematica available at this time. I see two possibilities to still get what you want: either use NETLink or JLink to write a GUI containing a treeview supplied by either .NET or e.g. Swing. That will mean your GUI will have to live in an extra window, will need some deeper understanding of the ...


2

If it were a venn diagram, clicked would be a subset of dragged (at least in the mind of whoever implemented this). You can reproduce what (I think) you want by adding a null event for "clicked": EventHandler[ Framed[1], {"MouseClicked" :> Null, "MouseDragged" :> (Print@RandomReal[])}] ---EDIT--- Or, for that matter, as per your comment, it is ...


2

Implementation 1 This should produce the desired GUI. askUser[matrix_] := DialogInput[ Column[{ Grid[{ToString@#1, InputField[Dynamic[#1], FieldSize -> Tiny], ToString@#2, InputField[Dynamic[#2], FieldSize -> Tiny]} & @@@ matrix, Alignment -> Left], Row[{CancelButton[], DefaultButton[DialogReturn[matrix]]}] }]] ...


2

After István Zachar's points, I was investigating Input definitions to learn more. It seams that 2 years later WRI changed approach from SelectionMove based to more automatic BoxReferenceFind. usage So what we only have to do is to set BoxID option for fields of interest and find those references when we want, with: MathLink`CallFrontEnd[ ...


2

Quick fix is to use Pane[#, ImageMargins -> {{0, 10}, {5, 5}}] & on tabs contents. Not convenient but working. Probably also OS dependent solution... To not copy this I'm using a function which can be used directly on TabView: tabViewFix1 = Function[tabView, MapAt[ Pane[#, ImageMargins -> {{0, 10}, {5, 5}}] &, ...


2

Here are some relevant stack exchange posts: Showing "updating..." message while Manipulate is re-evaluating Show Progressbar after pressing a button Evaluation indicator for a notebook Igor


2

As Arnoud Buzing has mentioned, when manually entering an RGBColor, in the code completion we find a user interface for finding the color components. This user interface is the same as that turns up when we click on a displayed RGBColor expression. I was wondering if this new interface could be used with Dynamic as well. Kuba showed that when we replace one ...


1

This is based on Kuba's deleted answer. I agree with his observation that "clearer [the] code the easier to fix". So here is Kuba's code made clearer. DynamicModule[{pl, tbl, n = 1, x = 45 °, calculation = False, procedure}, Dynamic[MouseAppearance[ Column[{ If[calculation, ProgressIndicator[Appearance -> "Percolate"], ...


1

You can achieve almost the same thing by saving coordinates. Place an image in Mathematica, click on it, and choose the "coordinates tool" form the little popup menu. Click on as many points as you want (say the upper left and lower right of a bounding box, if that's what you want). When done, choose "copy coordinates". Then paste them into a list.


1

As Fred has suggested, Initialization is the way to go, and here is a minimal example: DynamicModule[{answer, answers = Range@10, order}, Column[{ "Pick 1:", Dynamic[RadioButtonBar[Dynamic@answer, answers[[order]]], TrackedSymbols :> {order}] }] , Initialization :> ( order = RandomSample@Range@Length@answers; ), ...


1

My solution uses SetterBar with the items framed. {SetterBar[Dynamic[x], {"Play" -> Framed[Rotate["\[FilledUpTriangle]", -\[Pi]/2]], "Stop" -> Framed@"\[FilledSquare]"}, BaseStyle -> {FontSize -> 20}], Dynamic@Switch[x, "Play", Style["Play", Green], "Stop", Style["Stop", Red]]} It is pretty close. I'm certain you can tweak the font ...


1

Turned out it was easy to replicate the buttons from Play: $playView=ToExpression@GraphicsBox[ TagBox[{ {GrayLevel[0.9], RectangleBox[{5, -158}, {29, -135}]}, {GrayLevel[0.3], PolygonBox[NCache[{{13, -153}, {13, -140}, {21, Rational[-293, 2]}, {13, -153}}, {{13, -153}, {13, -140}, {21, -146.5}, {13, -153}}]]}, ...



Only top voted, non community-wiki answers of a minimum length are eligible