MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question about GUIkit and creating Tabs

I found a solution to my problem. One way to do it is to use the
InvokeMethod command. Unfortunately, it is poorly documented, so I had
to turn to java documentation.

Now, InvokeMethod is used as InvokeMethod[{"widget Name", "method that
can be used on the widget"},values for the method]

Use "MethodNames"/.GUIInformation[ref,"widget Name"] ,where ref is the
object you want (as below (ref=GuiRun[...]), to get the available
methods for your widget and go to the java documentation centre
for tabs,
to see how it is used. Explicitly,

InvokeMethod[{"group", "insertTab"}, "Tab name", , Widget["Button",
{"text"}, Name -> "Button name"]], , index]

If anyone has a better way please tell me. The part of the code I will
use in my project is shown below.
I hope this might be of help in general.

(* ------------------------------------------- *)

ref = GUIRun[count`index = {1}; count`num = 1; count`tab = 2;
   Widget["Panel", {WidgetGroup[{

        "Button", {"label" -> "add tab",
         BindEvent["action", Script[addbutton[]]]}],

        "Button", {"label" -> "kill tab",
         BindEvent["action", Script[killbutton[]]]}],

        "TextField", {"text" -> "2",
          Script[count`tab =
            ToExpression[PropertyValue[{"tabnum", "text"}]]]]},
        WidgetLayout -> {"Stretching" -> {Maximize, None}},
        Name -> "tabnum"]}, WidgetLayout -> Row],

     WidgetGroup[{Widget["Button", {"text" -> 1},
        Name -> "Button 1"]},
      WidgetLayout -> {"Grouping" -> {Tabs, Top, {"Tab 1"}}},
      Name -> "group"],

      addbutton[] := (InvokeMethod[{"group", "insertTab"},
         "Tab " <> ToString[1 + count`num], ,
         Widget["Button", {"text" -> ToString[1 + count`num]},
          Name -> "Button " <> ToString[1 + count`num]], , count`num];
         AppendTo[count`index, 1 + count`num]; count`num++;)],

      killbutton[] := (InvokeMethod[{"group", "removeTabAt"},
         count`tab]; count`index = Delete[count`index, count`tab];)]

     }, Name -> "panel"]];

  • Prev by Date: Re: Epilog with 3 dimensional graphics primitives
  • Next by Date: Reading excel data
  • Previous by thread: Question about GUIkit and creating Tabs
  • Next by thread: Can't start Mathematica 5