Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* ::Package:: *)
- ClearAll["test`*", "test`*`*"]
- BeginPackage["test`"];
- testgui::usage="testing gui with package";
- Begin["`Private`"];
- guicolor = ColorData[3];
- topcolor = Red;
- topcoloractive = ColorData["GrayTones"][0.4];
- guitextcolor = White;
- guifont = FontFamily -> "Helvetica Neue";
- buttoncolor = guicolor[5];
- view1 = DynamicModule[{var1 = 1}, Column[{Button["var1 =10", var1 = 10], Dynamic@var1}], InheritScope -> True];
- view2 = DynamicModule[{var1 = 1}, Column[{Button["var1 =20", var1 = 20], Dynamic@var1}], InheritScope -> True];
- testgui := Framed@DynamicModule[{stream, viewbutton, view = 1, toprow, mainview, var1 = 1},
- Column[{Dynamic@toprow,
- Dynamic@mainview[view]
- }],
- Initialization :> (
- mainview = <|1 -> view1, 2 -> view2|>;
- viewbutton[text_, viewnumber_] := Button[Style[text, guitextcolor, guifont,
- FontWeight -> Dynamic[If[view == viewnumber, Bold]]],
- Dynamic[view = viewnumber], Background -> Dynamic[If[view == viewnumber, topcoloractive, topcolor]],
- FrameMargins -> Medium, ContentPadding -> True, Method -> "Queued", Appearance -> None, ImageSize -> 100];
- toprow = Grid[{{Dynamic@viewbutton["View 1", 1], Dynamic@viewbutton["View 2", 2]}}, Spacings -> {0, Automatic}];
- )
- ]
- End[];
- EndPackage[ ];
- packagepath = NotebookDirectory[] <> "test.wl"
- Get[packagepath]
- testgui
Add Comment
Please, Sign In to add comment