MATLAB gui创建者GUIDE是否像我想的那样糟糕?有其他选择吗? [英] Is the MATLAB gui creator GUIDE as awful as I think? Is there an alternative?

查看:101
本文介绍了MATLAB gui创建者GUIDE是否像我想的那样糟糕?有其他选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在MATLAB中编写一个GUI,但遇到了很大的困难.这是有关我的程序的一些背景知识:我想创建一个向导来引导用户完成图像分析过程.该向导将提示用户输入,然后一旦按下标有下一步"的按钮,则执行图像处理操作,依此类推.通过阅读MATLAB帮助,我相信有两种创建gui的方法:1.用代码行编写gui. 2.使用GUIDE.

I've been trying to put together a gui in MATLAB and have had great difficulty. Here is a little background about my program: I want to create a wizard to step users through an image analysis process. The wizard will cue users for their input and then perform an image processing action once a button labeled "Next" has been pressed, and so on. From reading the MATLAB help I believe there are two approaches to gui creation: 1. write a gui with lines of code. 2. use GUIDE.

我认为GUIDE的学习曲线最浅.最初,这个过程很简单.我可以拖放按钮和文本框并轻松进行排列.我的计划是安排一系列带有按钮和文本等的面板,这些面板将在按下下一步"按钮时顺序显示.就在这里,我陷入了困境.

I figured GUIDE would have the shallowest learning curve. At first the process was straight-forward. I could drag and drop buttons and text boxes and arrange them easily. My plan was to arrange a series of panels, with the buttons and text and etc., that would sequentially become visible as the "Next" button was pressed. And it was here I became stumped.

一旦我使用GUIDE保存了面板,MATLAB就会创建一个.m文件和.fig文件.读完.m文件后,我发现它为我编写回调代码留出了余地,但除此之外就没有其他地方了. .fig文件是二进制文件,因此我不敢编辑它.我不知道如何控制对象,例如如何设置面板的可见性?此外,我必须分别创建向导的每个面板.我希望可以将.m文件手动组合到一个Wizard.m包装文件中,但是我认为这不是正确的方法(至少对我来说是这样,因为我看不到该怎么做).

Once I save a panel with GUIDE, MATLAB creates a .m file and a .fig file. Reading through the .m file I see it has left room for me to write code for the callbacks, but little else. The .fig file is binary and therefore I dare not bother edit it. I am left wondering how I can control the objects, e.g. How to set the visibility of a panel? Furthermore, I had to create each panel of the wizard separately. I was hoping that I could manually combine the .m files into a wizard.m wrapper file, but I do not think this is the right approach (at least for me, because I cannot see how to do it).

代替使用GUIDE,我已经看到了使用"uicontrol"功能创建GUI的示例.这种方法对我来说似乎很乏味,因为我必须手动编码每个按钮的位置和大小以及默认值.也许这是最好的方法,但是它吓倒了我.

In lieu of using GUIDE I've seen examples where guis are created using the "uicontrol" function. This approach seems tedious to me, because I would have to manually code the position and size and defaults of each button. Perhaps this is the best approach, but it intimidates me.

结果,我对MATLAB看起来笨拙的gui工具不满意,而对自己却不满意,无法克服这一障碍.

As a result I am unhappy with MATLAB for its seemingly clunky gui tools and I am unhappy with myself for lacking the chops to overcome this hurdle.

我看过一些在MATLAB中创建的精美gui,我自己尝试了一下,但很快我就被它们的存在所困扰.谁使他们成为了MATLAB的特殊用户(我不是),或者我遗漏了一些显而易见的东西,并且可能会有所帮助.我现在在质疑gui是否值得付出努力.我看不到自己探索像QT之类的东西,因为将MATLAB代码嵌入到其他语言(例如python)中还存在额外的挑战.

I've seen some fancy guis created in MATLAB and having attempted this myself and falling way short I am baffled by their existence. Either whoever made them were exceptional MATLAB users (I am not), or I am missing something obvious and could use some help seeing. I am now questioning whether a gui is worth the effort. I do not see myself exploring something like QT, because of the additional challenge of embedding MATLAB code into other languages such as python.

有人在这个问题上有建议吗?谁能指出我出了问题的地方或为什么我遇到这样的困难?

Does anyone have advice on this subject? Can anyone please point out where I am going wrong or why I am having such difficulty?

推荐答案

.fig文件是二进制文件,因此我不愿意对其进行编辑.

The .fig file is binary and therefore I dare not bother edit it.

FIG文件是一个MAT文件,其中包含具有您在GUIDE中设置的属性的gui元素列表.

FIG file is a MAT file containing list of gui elements with properties you set in GUIDE.

如何设置面板的可见性?

How to set the visibility of a panel?

为元素分配标签,您可以像set(handles.mypanel, 'visible', 'off')

Assign a Tag to the element, you can access it using handles.mytag like set(handles.mypanel, 'visible', 'off')

此外,我必须创建 向导的每个面板分别显示.我希望我能 手动将.m文件合并到一个Wizard.m包装文件中,但是我确实 不认为这是正确的方法(至少对我来说,因为我 无法看到该怎么做.

Furthermore, I had to create each panel of the wizard separately. I was hoping that I could manually combine the .m files into a wizard.m wrapper file, but I do not think this is the right approach (at least for me, because I cannot see how to do it).

您不能将这些自动生成的m文件合并为一个,为什么仍要这样做?为每个向导页面保留一个.fig和.m文件!

You can not combine these automatically generated m-files into one, why would you want to anyway? Keep a .fig and .m file for each wizard page!

代替使用GUIDE,我已经看到了使用GUI创建GUI的示例. "uicontrol"功能.这种方法对我来说似乎很乏味,因为我 将不得不手动编码每个的位置和大小以及默认值 按钮.也许这是最好的方法,但是它吓倒了我.

In lieu of using GUIDE I've seen examples where guis are created using the "uicontrol" function. This approach seems tedious to me, because I would have to manually code the position and size and defaults of each button. Perhaps this is the best approach, but it intimidates me.

如果您不手动定位元素而是使用布局管理器,则直接使用uicontrol也不错.您可以在此处

Using uicontrol directly is not bad if you do not position elements manually but use a layout manager. You can see some here and here. If you want you GUI to be nicely resizable then layout manager is the only way to do it.

有人在这个问题上有建议吗?任何人都可以指出 我哪里做错了,或者为什么我遇到这样的困难?

Does anyone have advice on this subject? Can anyone please point out where I am going wrong or why I am having such difficulty?

专业的GUI编程并不容易,IMO甚至是最困难的部分.

Professional GUI programming is not easy, IMO is even the most difficult part at all.

除了MATLAB GUI,我还经常使用Java Swing和.NET WPF,IMO MATLAB GUI更加容易,您可以用10%(学习)的精力完成90%的工作.当然,您仍然需要时间来习惯它.

Besides MATLAB GUI I have used both Java Swing and .NET WPF a lot, IMO MATLAB GUI is much easier, you can do 90% with 10% (learning) effort Sure, you still need time to become accustomed to it.

因此,我对MATLAB看起来笨拙的gui感到不满意 工具,我对自己感到不满意,因为缺少排骨要克服 这个障碍.

As a result I am unhappy with MATLAB for its seemingly clunky gui tools and I am unhappy with myself for lacking the chops to overcome this hurdle.

是的,GUIDE不是最佳解决方案,但它可能是快速创建GUI的最佳技术.

Yes, GUIDE is not the best solution but is probably the best technique to quickly create an GUI.

我已经看到了一些在MATLAB中创建的精美gui并尝试过 我自己,并很快就被他们的存在迷住了.

I've seen some fancy guis created in MATLAB and having attempted this myself and falling way short I am baffled by their existence.

这些GUI是利用MATLAB GUI特定细节的黑客,例如视觉分隔符是白色uicontrol上的长'__________'黑色文本,通过使用html,其工具提示中的像素高度只有两个像素或不同颜色.

These GUI's are hacks exploiting MATLAB GUI particular details like visual separator being a long '__________' black text on a white uicontrol which is only two pixel high or different colors in tooltip by using html.

毕竟,您可以在MATLAB GUI中使用Java Swing(因为它实际上是从Swing派生的)

And after all you can use Java Swing in a MATLAB GUI (because it is actually derived from Swing)

我现在正在质疑gui是否值得付出努力.

I am now questioning whether a gui is worth the effort.

是的,在您的情况下,请使其保持简单,仅考虑功能性,不要考虑花哨的东西!

Yes, in your case keep it very simple, just the functionality, do not think about fancy stuff!

这篇关于MATLAB gui创建者GUIDE是否像我想的那样糟糕?有其他选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆