Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – Oleksandr R. Nov 28 '13 at 20:32
sadly, it seems it is not so new as well as GUIKit – Копать_Шо_я_нашел Nov 28 '13 at 20:37
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. – Sjoerd C. de Vries Nov 28 '13 at 22:08
I'm working in 9th Version. it's sad. Application would look better using GUIkit. It can render CSS. Until now I got this . I'd not like to leave it. – Копать_Шо_я_нашел Nov 28 '13 at 22:23

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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