MATLAB gui 创建者 GUIDE 是否像我想象的那么糟糕?还有其他选择吗?

发布于 12-08 14:23 字数 1431 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

把梦留给海2024-12-15 14:23:49

.fig 文件是二进制文件,因此我不敢编辑它。

Fig 文件是一个 MAT 文件,其中包含 gui 元素列表以及您在 GUIDE 中设置的属性。

如何设置面板的可见性?

为元素分配一个标签,您可以使用 handles.mytag 访问它,例如 set(handles.mypanel, 'visible', 'off')

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

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

代替使用 GUIDE,我见过使用以下命令创建 gui 的示例
“uicontrol”功能。这种方法对我来说似乎很乏味,因为我
必须手动编码每个的位置、大小和默认值
按钮。也许这是最好的方法,但它让我感到害怕。

如果您不手动定位元素而是使用布局管理器,那么直接使用uicontrol也不错。您可以在此处此处。如果您希望 GUI 能够很好地调整大小,那么布局管理器是唯一的方法。

有人对这个问题有建议吗?谁能指出
我哪里出错了或者为什么我遇到这样的困难?

专业的 GUI 编程并不容易,在我看来甚至是最困难的部分。

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

因此,我对 MATLAB 的 GUI 看似笨重感到不满意
工具,我对自己不满意,因为缺乏克服的能力
这个障碍。

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

我见过一些在 MATLAB 中创建的精美 GUI,并尝试过这样做
我自己并远远落后,我对它们的存在感到困惑。

这些 GUI 是利用 MATLAB GUI 特定细节的黑客攻击,例如视觉分隔符是白色 uicontrol 上的长“__________”黑色文本,该控件只有两个像素高,或者使用 html 工具提示中的不同颜色。

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

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

是的,在你的情况下保持它非常简单,只是功能,不要考虑花哨的东西!

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

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?

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

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).

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!

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.

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?

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

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.

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.

Yes, GUIDE is not the best solution but is probably the best technique to quickly create an 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.

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.

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

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!

指尖凝香2024-12-15 14:23:49

截至 2015 年 6 月,GUIDE 比您想象的还要糟糕。配置 GUI 的效率非常低,而且 bug 非常多。绝对不是专业级别的。 GUIDE,我怎么鄙视你呢?让我列举一下方法:

1) 创建 GUI 时的输入错误不会被标记。由于潜伏着这个未通知的错误,您可能会工作几个小时。当您点击“保存”时,GUIDE 将不会保存您的工作。因此,GUIDE 违反了任何软件包的首要指令:您不应丢失用户的工作或数据。我不敢相信 Mathworks 居然发布了这么糟糕的东西。

2)帮派复制是不确定的。假设您有一个计算早餐效果的程序。您可以将小时、分钟、碳水化合物的数量作为可编辑框。您有作为静态文本的标签。午餐和晚餐你想要同样的东西。选择全部。 Ctrl-C。将光标指向其他位置,然后按 Ctrl-V。什么也没发生。不,等等,大约30秒后,粘贴出现了。但如果你已经在做别的事情了,那么……试着弄清楚到底发生了什么。

3)即使是帮派行动也是不确定的/奇怪的/超自然的/着魔的。假设您想上下移动午餐的那一行?强调。使用箭头键移动它。成功!但是等等!大约五秒钟后,文本和编辑框开始移回原始位置!无需干预!它着魔了!

我使用 GUIDE 创建了一个相当复杂的 GUI。比应有的或可能的更多的心痛和麻烦。如果有运行 JAVA/Python/Julia 的免费软件替代品,我不会启动另一个需要 GUI 的 MATLAB 项目。节省你的面团!

GUIDE is, as of June 2015, worse than you think. Highly inefficient for configuring a GUI, it is buggy as hell. Definitely not professional grade. GUIDE, how do I despise thee? Let me enumerate the ways:

1) Entry errors while creating a GUI are not flagged. With this unannounced error lurking, you can work for hours. When you hit "SAVE", GUIDE will not save your work. Thus, GUIDE violates the prime directive of any software package: thou shalt not lose user's work or data. I can't believe Mathworks actually released something this bad.

2) Gang copying is iffy. Let's say you have a program that calculates the effect of breakfast. You have hour, minutes, amount of carbs as editable boxes. You have labels as static text. You want the same thing for lunch and dinner. Select all. Ctrl-C. Point the cursor somewhere else, and hit Ctrl-V. Nothing happens. No, wait, about 30 seconds later, the paste appears. But if you are already doing something else, well... Try figuring out what the hell happened.

3) Even a gang move is iffy/strange/supernatural/possessed. Say you want to move that row with lunch up and down? Highlight. Use arrow keys to move it. Success! But wait! After about five seconds, the text and editboxes start to move back to the original position! Without intervention! It's possessed!

I've used GUIDE to create a fairly complex GUI. Way more heartache and hassle than it should - or could - be. Given freeware alternatives that run JAVA/Python/Julia, I'd not start another MATLAB project that needed a GUI. Save your dough!

夏雨凉2024-12-15 14:23:49

就我个人而言,我发现 GUIDE 对于快速简单的 GUI 和学习如何创建 GUI 来说足够好,但现在我通常更喜欢以编程方式创建 GUI。这可以更好地控制内容。对我来说,关键是使用 UI 元素的 UserData 属性来存储任何有用的数据,包括您要更新的 UI 对象的句柄。

但如果您想要一些聪明的东西,那么您将不得不求助于基于 Java 或 .NET 的东西。

此外,重要的是要记住 MATLAB 最擅长什么,而 GUI 并不是强项。如果您使用 GUI 创建效果更好的编程语言,那么您将不得不在其他方面做出妥协,例如处理数组和矩阵数据的易用性。

编辑GUI 布局@Mikhail 链接的工具箱 看起来非常有用。

Personally, I find GUIDE good enough for quick simple GUIs and to learn how to create GUIs, but now I generally prefer to create the GUIs programmatically. This allows for much better control of the content. For me, the crux is to use the UserData properties of the UI elements to store any useful data, including handles to the UI objects you will want to update.

But if you want something clever, then you will have to resort to something Java- or .NET-based.

Also, it's important to remember what MATLAB is best at, and GUIs are not the strong-suit. If you use a programming language where the GUI creation is better, then you will have to compromise on something else, such as the ease of working with array and matrix data.

EDIT: The GUI Layout Toolbox linked to by @Mikhail looks extremely useful.

平生欢2024-12-15 14:23:49

我一直在 MATLAB 中进行 GUI 编程。

据我所知,GUIDE 使 GUI 编程变得非常方便。正如您所说,您实际上不必费心编写任何按钮等,只需排列按钮并填充 m 文件即可。在按钮中,您可以通过将属性“Visible”设置为“on”或“off”来处理可见性。

我尝试了两种方法:手动编写 gui 和使用 GUIDE 编写。
我的印象是你真的必须投入其中。一旦你了解了句柄的概念(这是 matlab guis 的主要内容),你就明白了。

首先尝试编写一个简单的 GUI,不要从您的项目开始。了解句柄和检查器在 MATLAB 中的工作方式以及如何设置值的属性。找出可以在 GUI 中存储数据的位置以及如何在其他窗口中检索数据(在窗口之间传递句柄)。

我想就是这样吧!在 MATLAB 中进行 GUI 编程可能很难开始,但是一旦您弄清楚了我上面提到的事情,它就会变得非常简单。

I've been programming guis in MATLAB.

From what I've seen GUIDE makes programming guis quite convenient. As you said you actually don't have to bother about programming any buttons etc., it's just arranging the buttons and filling the m-files. Within buttons you can handle visibility by setting the property 'Visible' to 'on' or 'off'.

I tried both approaches: Manually writing the gui and writing it using GUIDE.
I had the impression that you really just have to get into it. Once you got the concept of handles (that's the main thing with matlab guis) you've got it.

Try to program a simple gui first, don't start with your project. Get a hold of how handles and the inspector work in MATLAB and how you can set properties of values. Figure out where you can store data within the GUI and how to retrieve it in other windows (pass handles between windows).

I guess that's about it! Programming guis in MATLAB can be hard to begin, but it's pretty straight forward once you figured out the things I mentioned above.

暗藏城府2024-12-15 14:23:49

与以编程方式创建的 GUI 相比,GUIDE 生成的 GUI 的主要问题是文件不是文本。因此,您无法使用版本控制。有一个解决方法 - 您可以使用 export 函数仅创建 .m 文件。当然,您将无法将其切换回 fig 并进行可视化编辑。
就我个人而言,我总是更喜欢在没有 GUIDE 的情况下编写 GUI。

The main problem with GUIDE generated GUIs, opposed to programmatically created ones is the fact that the file is not a text. Thus, you cannot use a version control. There is a workaround - you can use the export function to create only .m file. Of course, you will not be able to switch it back to fig and edit it visually.
Personally, I always prefer to write GUIs without GUIDE.

这个俗人2024-12-15 14:23:49

我来晚了,但想加 0.02 美元。正如您提到的,GUI 设计不是 MatLab 的强项。然而,它可以做很多事情。如果您有任何具体问题,我很乐意回答。另外,要意识到它是基于 java swing 库构建的,因此您可以实际利用这些功能。但是,这些功能没有记录在案。有一本名为 Undocumented Secrets of MatLab 的书,对底层的 swing 组件进行了相当不错的讨论。

MatLab GUI 有一些怪癖,但如果您能克服这些怪癖,那么您就会喜欢它。此外,正如前面提到的,更困难的障碍之一是句柄的概念。一旦你掌握了这个概念,你就已经成功了 90%。

I’m coming in late to this conversation, but wanted to add my $0.02. As you mentioned GUI design is not MatLab’s strong suit. However, a lot can be done with it. If you have any specific questions I’d be happy to answer them. Also, realize that it is built on the java swing library so you can actually utilize those features. However, these features are not documented. There is a book title Undocumented Secrets of MatLab that provides a pretty decent discussion of the underlying swing components.

There are quirks to MatLab GUI, but if you can get over those then you’ll enjoy it. Also, as previously mentioned one of the more difficult hurdles is the concept of handles. Once you grasp that concept you will be 90% of the way there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文