Matlab GUI's managebuttons - user-interface

I have to maintain a large MATLAB GUI, containing quite a few callback functions, each of which gets called at many points. At some point, I decided to rename one of the callbacks; in order not to have to go through GUIDE to manually modify each of the UI that calls it, I used the excellent gencode program to "unwrap" the .fig file, s/old_name/new_name/g, and recreate the .fig.
This seems to work well, except for one thing: when clicking on a button in a button group, I got a message telling me that the function manageButtons is unknown. After a bit of googling, I find that manageButtons is a nested function in childAddedCbk, which, I assume, is called by GUIDE as the GUI is created. Now, trying to move just manageButtons outside to its own, in-the-path file doesn't work either: the hgroup passed to it is an invalid handle object.
So... does anyone has a workaround for that? Any of the following will be appreciated:
changing all the callbacks in a GUI in a semi-automatic way, or
making the manageButtons get a valid handle, or
having gencode not break all that.
Thanks,
Antony

You can export the FIG + M file to single .m file. You will lose the ability to edit this with guide, but you will be able to do a simple regular expression replace on the resulting .m file.
In order to do so - use on the menu of GUIDE -> File -> Export.

Related

How to read from the internal clipboard of a Telerik Kendo Diagram?

I have a system that allows users to create multiple diagrams. I want to be able to copy a part of one diagram, close it, run another and paste in what I have copied. The problem is that the diagram.copy() and diagram.paste() functions use an internal clipboard which is lost when I close the original diagram, so there's nothing to paste when I open the other one.
I'm very new to Telerik, so I don't really know how to approach this. I tried digging through the documentation, but I couldn't see any way to interact with the internal clipboard other than the two functions.
Preferably I'd like to be able to read the internal clipboard, copy it to a global variable and then read the variable back when opening the destination diagram.
Or maybe there's a way to read the selected shapes into a variable without using the copy() function?
Reading the source code, I've found it's stored in the variable diagram._clipboard . You can run this sample and inspect: https://dojo.telerik.com/onunEkib
However, as an undocumented feature, this can change and break when upgrading your Kendo version. Plus, as this is the diagram's internal data, it can be invalid for the target diagram.
What I'd do is a custom copy button that gets the current selection through the select method.

QTP/UFT - Collapse All Functions

I have in my one qfl file about 14 functions that I call to my action. But generally when I open the solution file ever morning and navigate to the function file, all the functions are expanded again.
Then I need to click on every single function to collapse it - I do this because it helps navigate through the file quicker because there is now only one line of code for each function to scroll through instead of scrolling through every line inside the function ONLY to go past it.
Yes, I am aware that this doesn't even take a minute to do, but I am trying to be efficient and as a programmer in general, I'm just lazy and don't want to repeat this everyday.
I cannot seem to find a solution anywhere for this.
Is it possible to create a button or shortcut key that can do this?
If I have posted this in the wrong place, please advise where to post it. :)

Matlab GUI Attempt to reference field of non-structure array

I have a GUI menu on Matlab with 4 buttons (menu.fig). Then I have 4 .fig file that I want to open when I click on the buttons. Here it's all ok, when I open a .fig from menu and insert value to do a plot I get this error:
???? Attempt to reference field of non-structure array.
If I try to open 1.fig directly, everything works perfectly.
I read that the problem is with eval(), but I can't solve it.
I changed the variable names on each .fig file
One 1.fig:
function pbutton1_Callback(hObject, eventdata, handles)
A1=get(handles.edtSAmp,'String');
f1=get(handles.edtSFreq, 'String');
fi1=get(handles.edtSFase, 'String');
t1=get(handles.popTipo, 'Value');
A1=str2double(A1);
f1=str2double(f1);
fi=str2double(fi1);
SinalSinusoidal(A1,f1,fi,t1);
I got the error on the that 1st line.
I guess this is something MATLAB GUI not handled well. I know it used to work, but when you tweaking your UI or UI related code a bit and accidentally you modified some area MATLAB told you not to touch, this kind of issue begin to happen.
The workaournd is to start the GUI from M editor by clicking run
I know it works, but originally, when I directly lauch it , it works too. so, this is not the end of it, people are just not getting to the end of it.
The problem is with probably with handles1. It's not a structure array like you expect it to be. In GUI's created with GUIDE, this variable is usually called handles, if you have both handles and handles1 make sure handles1 contains handles to the objects in the figure. If you're using handles1 only, make sure you're initializing it properly.

Matlab GUI gives error, but m file okaz

I`m absolutely new in Matlab, so I think it is a dumb question, but I would be really grateful for any help.
I had made a GUI with some slider. When I compile the m file everything works fine, there are no exceptions and the program do what it have to, but when I click on the fig file directly and try to move one of the sliders I got the following error:
??? Undefined function or method 'diference_GUI' for input arguments of type 'char'.
Error in ==>#(hObject,eventdata)diference_GUI('slider1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I had found some forum, blog article in this topic, but I want able to solve. Try-Catch not good, because if I do it, I dont get any error message, but the program still don`t do what it need.
Thank you for your help, Karoly
Your question isn't quite clear, but I'm assuming that you've made a GUI called difference_GUI using GUIDE in MATLAB.
When you do this, you'll get two files, difference_GUI.m and difference_GUI.fig. At that point, you should basically leave difference_GUI.fig alone, without opening or modifying it. Start the GUI by typing difference_GUI, which will run the .m file, which uses the information in the .fig file to lay out the GUI.
If you need to modify the layout of a GUI that you've created in GUIDE, you can open the project again in GUIDE and make minor modifications to it, such as repositioning a slider - but if you need to make major changes to it, I personally find it easier to copy the algorithmic portion out of the .m file, create an entirely new project, relaid out, from scratch, and then paste the algorithmic portion back in to the new .m file.

Changing multiple .fig files in Matlab systematically

I want to browse a directory where many Matlab GUI's (.fig files and their related .m files) are stored and change them systematically. For each, I want to search for a certain popup menu and, if it exists, delete some specific options.
I usually use get() and set() or similar functions to fiddle with GUI's, but these functions require handles, and I don't know how to get handles when not running the GUI, and also I wouldn't know how to save the changes.
If I open a .fig as text it is unintelligible.
I'm considering opening each at a time in guide (Matlab's GUI development environment) and changing it manually, but really would like to avoid it. I'm talking about tens of files, and my action might have to change in the future.
Maybe there would be a way to control guide from the command line? Or another solution?
You can load the .fig files using hgload or openfig. Both these functions return the figure's handle.
Once you have the figure's handle you can use findobj to get the popup menu's handle. Then set and get as normal to change the menu's options, and then save the modified figure using hgsave.
For example:
f = hgload('file.fig');
menuH = findobj(f, 'Type', 'popup');
set(menuH, 'String', new_options);
hgsave(f, 'file.fig');
gcf() immediately after open() gets the handles and can be done programatically for many figures.

Resources