How to display a fprintf on designer panel (R2018b)?
4 次查看(过去 30 天)
显示 更早的评论
I currently using MATLAB's App Designer tool and I'm trying to manipuate a label into a squished paragraph, like "word wrap", but that is only avaliable for 2021b. I currently on 2018b, there is no way for me to up to 2021b. Is there another way, if not I'll use two labels or three labels for a description.
0 个评论
采纳的回答
Walter Roberson
2023-7-13
The return value from fprintf is the number of bytes that have been written by fprintf(). fprintf() is strictly for sending data to a display or a file. If you want to get back the results of formatting text, use sprintf or compose . You can pass the results of sprintf() directly as the label text for uilabel even in your version (but your version does not support automatic word wrap.)
Implementing word wrap yourself in your version is a little bit of a nuisance, but possible.
To implement word wrap, create a uicontrol style text or edit or push or listbox or dropbox with a traditional axes as parent (in order words, child of a figure() rather than a uifigure(), and set its Position as the desired size. Then use textwrap to wrap the text inside the confines of that uicontrol, getting out wrapped text; you can then send the wrapped text to the uilabel()
This process uses a temporary traditional figure to hold the uicontrol to wrap against. There is no reliable way to prevent the temporary traditional figure from displaying, but in practice if you set the newly created traditional figure visibility off immediately after creation, then the user probably will not see it displayed. You can create a single temporary traditional figure, set it invisible, create a single uicontrol inside of it, and then as you need to word-wrap various items, set the Position of the uicontrol as needed, wraptext() against it, and leave the figure active (and invisible) until you are finished doing everything you might want to word-wrap.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!