MathGroup Archive 2007

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

Search the Archive

Re: Question about GUIkit and creating Tabs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83718] Re: Question about GUIkit and creating Tabs
  • From: psycho_dad <s.nesseris at gmail.com>
  • Date: Thu, 29 Nov 2007 06:17:28 -0500 (EST)
  • References: <fijfmu$h5u$1@smc.vnet.net>

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
eg http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTabbedPane.html
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.
Cheers,
psycho_dad

(* ------------------------------------------- *)
Needs["GUIKit`"]

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

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

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

       Widget[
        "TextField", {"text" -> "2",
         BindEvent["action",
          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"],

     Script[
      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++;)],

     Script[
      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