Tcl command to Update/Synchronize window fields

Moderator: GiD Team

Post Reply
theokart
Posts: 11
Joined: Mon Mar 14, 2016 11:38 am

Tcl command to Update/Synchronize window fields

Post by theokart »

Hello,

Is there any tcl command to update the window data, like i am pressing the "update changes" button or pressing "accept" on problem data ?
In some cases i want to change some field values through tcl script and update it automatically without the need of user to press update/accept or to save changes when trying to close the window (a pop up window appears if you have unsaved changes).

Thanks in advance
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Tcl command to Update/Synchronize window fields

Post by escolano »

You are talking about the 'classic' materials, problemdata, intervaldata, conditions window
The "update changes" or "accept" button use the temporary values of the window widgets (entries, etc.) and set the internal effective values for the material, etc.
How are you changing values with scripting? which commands are you using?
It in not usual that you are changing the window widget values, but the true internal values, then if do you have the window opened to update it must simply close and open again, and it will be filled with the effective values.

These windows are not unique, e.g. it could be more than one problemdata window if your are defining 'books' in your .prb, each book will have its windows.
We are trying to offer in dev_kit.tcl a standard and centralized command to open/close/update/check_exists/toggle a known window
GidUtils::OpenWindow
GidUtils::CloseWindow
GidUtils::UpdateWindow
GidUtils::ExistsWindow
GidUtils::ToggleWindow

unfortunately nowadays the classic window= MATERIAL, PROBLEM_DATA, INTERVAL_DATA, CONDITION are not considered by these procs, we will try to consider them...
by now you can use directly other commands like
GidOpenProblemData { {Book "Default"} }
GidOpenIntervals { {Book "Default"} }
GidOpenMaterials { {Book "Default"} {Material ""} }
GidOpenConditions { {Book "Default"} }

and to close them
DWCloseWindow GD_PD_1
DWCloseWindow GD_INT_1
DWCloseWindow GD_CND_1
DWCloseWindow GD_MAT_1
(GD_PD_1 is in case of do not have books, or be the window of the first book, for other books could be GD_PD_2, GD_PD_3,...)

and to check is a window exists (is opened) must find in our scripts code how to know the Tk window widger name,
I recommend you to wait until we handle these windows in GidUtils::OpenWindow, etc. and then if do you change some internal problemdata can refresh the window if was opened with something like
GidUtils::UpdateWindow PROBLEM_DATA
theokart
Posts: 11
Joined: Mon Mar 14, 2016 11:38 am

Re: Tcl command to Update/Synchronize window fields

Post by theokart »

Yes i was refering on classic problem type, using the DWLocalSetValue procedure, invoked in the INIT event of problem data field.
I was trying to pop up a new window which recommends some values and asks user if it ok to apply recommended changes.
I also tried to use DWLocalSetValue (in order for user to visualize the change ) and GiD_AccessValue set gendata field_name value ( in order to literally apply changes on original values) at the same time but it keeps asking to save changes after closing the problem data window (if not pressed accept but pressed OK in the pop up window) which is kind of tricky.

But it is ok for me, i can find alternative ways to recommend values when window is closed.
However it would be helpful to include old/classic data/windows in the procedures you mentioned.

Thank you very much for your reply.
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Tcl command to Update/Synchronize window fields

Post by escolano »

In your case, where you are modifying the local values of the window widgets, to apply your changes could call the same Tcl proc that is doing the Accept button:

Code: Select all

DWProblemAccept GD_PD_1
DWIntervalAccept GD_INT_1
DWModifyMat GD_MAT_1
(the 1 in case of first book)

then the window won't ask to be saved again when closing
Post Reply