如何向Matlab gui添加进度条控件?
是否有现成的进度条uicontrol可以添加到Matlab gui中, uicontrol 还是 ActiveX 组件?
[编辑] 我知道等待栏功能,我的意思是一个可以实现到设计的 GUI 中的组件,而不仅仅是弹出窗口。比如状态栏中的电池状态。
Is there a ready made progress bar uicontrol that can be added to Matlab gui,
either uicontrol or ActiveX component?
[edit] I know about the waitbar function, I meant a component that can be implemented into the designed GUI and not just pop out of the window. Something like battery status in status bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Waitbar 及其变体显示一个带有状态栏的弹出窗口。在大多数应用程序中,这是可以的,并且使用起来非常简单。
如果您想在现有的 GUI 窗口中集成进度条,您有多种选择:
所有这些选择都适用于所有 Matlab 平台。
Waitbar and its variants display a popup window with a status bar. In most applications this is ok and very simple to use.
If you want to integrate a progress-bar within an existing GUI window, you have several choices:
All of these choices work on all Matlab platforms.
是的,有。 waitbar 函数正是您所需要的。其中的示例很容易理解,您可以立即开始。它应该可以在所有 3 个平台(Windows/OS X/Linux)上正常工作。
Yes, there is. The waitbar function is what you need. The examples there are easy to follow and you can get started right away. It should work fine on all 3 platforms (Windows/OS X/Linux).
根据这个 MatLab Newgroup 评论调整我的代码,我能够将以下:
创建如下,其中
parent
是您要将其添加到的父面板:更新进度栏如下所示:
这是一个使用
figure 的完整工作示例
:Adapting my code from this MatLab Newgroup comment, I was able to put together the following:
Creation is as follows, where
parent
is the parent panel that you want to add it to:and updating the progress bar is as simple as this:
Here's a full working example using a
figure
:另一个简单的解决方案是使用两个嵌套的 uipanels,如下所示:
用法:
another simple solution is to use two nested uipanels like this:
Usage:
对于仍然感兴趣的人,这是我使用类的解决方案:
声明一个实例,如下所示:
pb = Progressbar(gcf, [1 1], [0 20]);
它可以与相对或实际一起使用数字,即
pb.pvalue = 10;
和pb.percent = .5;
在我的示例中执行相同的操作。我的版本在进度条中间有一个文本对象,显示当前百分比。
我的最新版本可以在此处获取。
For anyone still interested, here's my solution using a class:
Declare an instance like so:
pb = progressbar(gcf, [1 1], [0 20]);
It can be used with relative or actual numbers, i.e.
pb.pvalue = 10;
andpb.percent = .5;
do the same thing in my example.My version features a text object in the middle of the progress bar that displays the current percentage.
My latest version is available here.
Matlab 内置了“等待栏”...您还可以从 Matlab 站点获取这些工具:
http://www.mathworks.com/matlabcentral/fileexchange/26773-progress-bar&watching=26773
http://www.mathworks.com/matlabcentral/fileexchange/3607-progressbar
Matlab has inbuilt 'waitbar'... you may also any of these tools from matlab site:
http://www.mathworks.com/matlabcentral/fileexchange/26773-progress-bar&watching=26773
http://www.mathworks.com/matlabcentral/fileexchange/3607-progressbar
还有另一种方法...抱歉,如果有人提到但我错过了。您可以构建一个动态添加条形轴的图形。它工作得非常好,并且很容易适应自定义应用程序。弹出窗口总是会迷路或挡道。
There is another way... Sorry if it was mentioned and I missed it. You can build a figure dynamicly adding the axes for a bar.. It works very nicely and easly adaptable for custom applications. Pop ups were always getting lost or in the way.