简体   繁体   English

将Matlab GUI转换为指南GUI

[英]Converting Matlab GUI into a guide GUI

I have inherited a pile of Matlab scripts that manually build a GUI using calls to uicontrol, uimenu, etc. Over the years we have needed to remove and add elements to the GUI and since all the positions are specified manually in the scripts, the layout hasn't really changed to accommodate the missing elements so it is really starting to look like a pile of trash. 我继承了一堆Matlab脚本,使用对uicontrol,uimenu等的调用手动构建GUI。多年来,我们需要删除元素并将元素添加到GUI中,因为所有位置都是在脚本中手动指定的,所以布局并没有真正改变以适应缺失的元素,所以它真的开始看起来像一堆垃圾。

Is there a way to automatically convert my matlab scripted gui into something I can use with guide? 有没有办法自动将我的matlab脚本gui转换为我可以使用指南的东西? I would rather not have to start over... 我宁愿不必重新开始......

GUIs generated with GUIDE are not much better than manually scripted ones (if not worse in my opinion in terms of maintainability). 使用GUIDE生成的GUI并不比手动编写的GUI好(在我看来,在可维护性方面不会更差)。

The sad truth is that there are no builtin layout managers in MATLAB (there are user-contributed ones on FEX like border layout , gridbag layout and others). 可悲的事实是,MATLAB中没有内置布局管理器(FEX上有用户贡献的布局管理器,如边框布局网格布局等)。 If you are refactoring the code, please consider using some sort of GUI layout manager. 如果要重构代码,请考虑使用某种GUI布局管理器。

To answer your question, afaik there is no automatic tool for such a conversion. 为了回答你的问题,afaik没有自动工具进行这样的转换。


To be exact, MATLAB has some undocumented layout managers: uiflowcontainer and uigridcontainer . 确切地说,MATLAB有一些未记录的布局管理器: uiflowcontaineruigridcontainer See this article by Yair Altman 请参阅Yair Altman 撰写的这篇文章

Well, there is no automatic conversion utility but you dont need to create everything from scratch with GUIDE. 好吧,没有自动转换实用程序,但您不需要使用GUIDE从头开始创建所有内容。

Execute your GUI so that it shows up and save the figure window as a fig file. 执行GUI,使其显示并将图形窗口保存为图形文件。 This file then can be edited with guide. 然后可以使用指南编辑该文件。 However this needs manual adjustments in your code. 但是,这需要在代码中手动调整。 Especially if you need access to handles and I am also not sure about the callback functions. 特别是如果你需要访问句柄,我也不确定回调函数。

However, as Amro already pointed out, GUIDE is not a perfect solution. 然而,正如Amro已经指出的那样,GUIDE并不是一个完美的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM