Guest User

Untitled

a guest
Jan 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. (* ::Package:: *)
  2. ClearAll["test`*", "test`*`*"]
  3.  
  4.  
  5. BeginPackage["test`"];
  6.  
  7. testgui::usage="testing gui with package";
  8.  
  9. Begin["`Private`"];
  10.  
  11. guicolor = ColorData[3];
  12. topcolor = Red;
  13. topcoloractive = ColorData["GrayTones"][0.4];
  14. guitextcolor = White;
  15. guifont = FontFamily -> "Helvetica Neue";
  16. buttoncolor = guicolor[5];
  17.  
  18. view1 = DynamicModule[{var1 = 1}, Column[{Button["var1 =10", var1 = 10], Dynamic@var1}], InheritScope -> True];
  19. view2 = DynamicModule[{var1 = 1}, Column[{Button["var1 =20", var1 = 20], Dynamic@var1}], InheritScope -> True];
  20.  
  21. testgui := Framed@DynamicModule[{stream, viewbutton, view = 1, toprow, mainview, var1 = 1},
  22. Column[{Dynamic@toprow,
  23. Dynamic@mainview[view]
  24. }],
  25.  
  26. Initialization :> (
  27. mainview = <|1 -> view1, 2 -> view2|>;
  28.  
  29. viewbutton[text_, viewnumber_] := Button[Style[text, guitextcolor, guifont,
  30. FontWeight -> Dynamic[If[view == viewnumber, Bold]]],
  31. Dynamic[view = viewnumber], Background -> Dynamic[If[view == viewnumber, topcoloractive, topcolor]],
  32. FrameMargins -> Medium, ContentPadding -> True, Method -> "Queued", Appearance -> None, ImageSize -> 100];
  33.  
  34. toprow = Grid[{{Dynamic@viewbutton["View 1", 1], Dynamic@viewbutton["View 2", 2]}}, Spacings -> {0, Automatic}];
  35. )
  36. ]
  37.  
  38.  
  39. End[];
  40.  
  41. EndPackage[ ];
  42.  
  43. packagepath = NotebookDirectory[] <> "test.wl"
  44. Get[packagepath]
  45. testgui
Add Comment
Please, Sign In to add comment