matlab - 如何操作按钮位置属性?
问题描述
我正在努力调整按钮位置。不应该那么难,但不知何故我无法弄清楚。任何想法在哪里添加正确的代码?
button = 'Continue';
while strcmpi(button, 'Continue')
promptMessage = sprintf('Are the results ok?,\nor should the script be stopped?');
titleBarCaption = 'Continue?';
button.Position = [100 100 50 20]; %this line seems to the issue
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
解决方案
这是一个在提示中按 continue 时随机将 auibutton
放入 a的示例。这里被命名并且独立于 char 向量。由于问题中的详细信息有限,我不确定您是否尝试更改提示中按钮的位置。uifigure
questdlg
uibutton
Test_Button
button
questdlg
UI_Figure = uifigure;
UI_Figure.Position = [0 0 500 500];
Test_Button = uibutton('Parent',UI_Figure);
Figure_Width = UI_Figure.Position(3);
Figure_Height = UI_Figure.Position(4);
button = 'Continue';
while strcmpi(button, 'Continue')
promptMessage = sprintf('Are the results ok?,\nor should the script be stopped?');
titleBarCaption = 'Continue?';
Test_Button.Position = [round(rand(1)*Figure_Width) round(rand(1)*Figure_Height) 50 20];
%this line seems to the issue
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
推荐阅读
- css - Vue.js 多条路由之间的动态过渡
- gis - 有什么方法可以方便地使用 GeoJSON 和 Geomesa?
- c - Linux内核中需要始终为真条件的三元运算符是什么?
- c++ - clock_nanosleep 和 sleep_until 有什么区别?
- c - 如何以网络字节顺序从二进制文件中读取并在 c 中创建 struct sockaddr_in
- python - 从两个数据框创建新的数据框。一个df包含列索引,另一个df包含值
- javascript - Mongoose Schema 值未保存到 MongoDB
- c++ - 使用 Visual Studios 16.6 添加包含目录
- python - 来自元组列表的 Python 热图
- ios - Swift - 如何发出 cURL 请求?(Swift 5.2 / macOS Catalina)