I need to change property of window when button gets pressed. There are pretty enough examples on Wolfram's website, but all they bind predefined function "Print[]" and I have no problems with binding Print function. But I can't bind something different.

I need call my own function and methods of Widgets.

This is a window whose property I want to change:

widget4 = Widget["TextPanel", {
"preferredSize" -> 
Widget["Dimension", {"width" -> 800, "height" -> 660}],
"contentType" -> "text/html",
"editable" -> False, "path" -> html1path}, Name -> "MainOutput"] 


This is my button:

html2path="some text which I want to change";
butto = Widget["Button", {
"Text" -> "Update",
Script[    {SetPropertyValue[{"MainOutput", "path"}, html2path] , 
  Print["fdfdf"], ref@InvokeMethod[{"Frame", "getX"}], functio[] } ]]

I launch it all together so:

ref = GUIRun[ Widget["Frame", {widget4, butto}, Name -> "Frame" ]];

As result out of all my tries only function Print["fdfdf"] was called. enter image description here

I got stuck with it.
Thanks in advance.

  • $\begingroup$ GUIKit has not been maintained for a long time and suffers from many bugs. You might like to try David Bailey's super widget package as an alternative. But bear in mind I say this having not seriously used either of them. $\endgroup$ Commented Nov 28, 2013 at 20:32
  • $\begingroup$ sadly, it seems it is not so new as well as GUIKit $\endgroup$
    – Tebe
    Commented Nov 28, 2013 at 20:37
  • 1
    $\begingroup$ Are you working in a version higher than 5? If so, I'd suggest dropping GUIkit and work with the dynamic controls introduced in version 6 and later. $\endgroup$ Commented Nov 28, 2013 at 22:08
  • $\begingroup$ I'm working in 9th Version. it's sad. Application would look better using GUIkit. It can render CSS. Until now I got this minus.com/ldan2YzBYKV5N . I'd not like to leave it. $\endgroup$
    – Tebe
    Commented Nov 28, 2013 at 22:23

1 Answer 1


After trying to solve it for a day. I came to the point that looking for source code is necessary.

The most interesting files I found here: /home/sh/po/mathematica_installed/AddOns/Packages/GUIKit/GUI/AuthorTools

(i.e. you need check this path "/AddOns/Packages/GUIKit/GUI/AuthorTools" in the folder where Mathematica is installed to)

These files have pretty good examples of Mathematica's GUIKit usage:


They prove that GUIKit can work good.

The problem was that for changing GUI's elements Script which handle's button's pressing MUST be executed in the Java ATW Thread.

So now I have such working code:

ref = GUIRun[ 
Widget["Panel", {
 Widget["Button", {
  "text" -> "Run",
    SetPropertyValue[{"button", "enabled"}, False, 
     InvokeThread -> "Dispatch"];

    SetPropertyValue[{"label", "text"}, 
     "New Text! Huuuraaaaaaaaaaa!!!!!!!!", 
     InvokeThread -> "Dispatch"];

    SetPropertyValue[{"button", "enabled"}, True, 
     InvokeThread -> "Dispatch"];
   InvokeThread -> "New"]
  }, Name -> "button"],
Widget["Label", {
  "text" -> "Press Button to see changes      "
  }, Name -> "label"]
}]  ]

It's explained here also.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.