GUI中Button Types and Button Group的介绍
网上的对GUI控件的介绍!
MATLAB GUI Tutorial - Button Types and Button Group
03 Nov 2007 Quan Quach 93 comments 25,002 views
Introduction
In this three-part Matlab GUI Tutorial, you will learn how to use the
different types of buttons available within Matlab GUIs. These button
types are: push button, radio button, check box, and toggle buttons. In addition, you will learn how to use the button panel to control a group of buttons.
This tutorial is written for those with little or no experience creating a Matlab GUI (Graphical User Interface). If you re new to creating GUIs in Matlab, you should visit this tutorial first. Basic knowledge of Matlab is recommended. Matlab version 2007a is used in writing this tutorial. Both earlier versions and new versions should be compatible as well (as long as it isan t too outdated). Let s get started! Part One: The Pushbutton
The push button is a very simple component. When the user clicks on a push button, it causes an action to occur. This action is dictated by the code that is programmed in the push button s callback function. In this part of the tutorial, we will program the push button to display some text when it is pressed.
1. First, we are going to create the visual aspect of the GUI. Open up Matlab. Go to the command window and type in guide.
网上的对GUI控件的介绍!
2. You should see the following screen appear. Choose the first option Blank
GUI (Default).
3.
on
4. Click on and add one Static Text component to the GUI figure. Next, click and add one Push button component onto the GUI figure. Double click the Static Text component to bring up the Property Inspector.
Change the String property so that there is nothing inside. Change the Tag property to display_staticText. Similarly, double click on the Pushbutton component and change the String property to Display Text! and change the Tag property to displayText_pushbutton.
网上的对GUI控件的介绍!
5.
Here
s what your figure should look like after you add the components and modify them.
6.
7. Save your GUI wherever you please with your desired filename. Now, we are going to write the code for the GUI. When you save your GUI,
Matlab automatically generates an .m file to go along with the figure that you just put together. The .m file is where we attach the appropriate code to the callback of each component. For the purposes of this tutorial, we are primarily concerned only with the callback functions. You don t have to worry about any of the other function types.
Open up the .m file that was automatically generated when you saved your GUI. In the Matlab editor, click on the icon, which will bring up a list of the functions
网上的对GUI控件的介绍!
within the .m file. Select displayText_pushbutton_Callback.
Add the following code to the function:
%display "Hello Wordl!" in the static text component when the
%pushbutton is pressed
set(handles.display_staticText,'String'
,'Hello World!');
8. Now that we ve completed both the visual and code aspects of the GUI, its
time to run the GUI to make sure it works before we move on. From the m-file editor, you can click on the icon to save and run the GUI. Alternatively, from the GUIDE
to launch the GUI. The GUI should appear once you editor, you can click on the
on the GUI. click the icon. Now try clicking on the button to make sure that Hello World! appears
And that s it. Those are the basics of using the Push button component. Now we re ready to move onto the Check box component.
Part Two: The Check Box
The Check Box component has two states, checked and unchecked. These
components are usually used to control options that can be turned on and off. In this part of the tutorial, we will add the functionality of making the display text become bold or unbolded.
网上的对GUI控件的介绍!
1. The first thing we need to do is to add a Check Box Component to the GUI
figure that we were just working with. So if you closed GUIDE, reopen it again. Once you have GUIDE opened again, Click on
the GUI figure. and add one Check Box component to
2.
Double click the Check Box component to bring up the Property Inspector. Change the String property to Bold. Change the Tag property to bold_checkbox.
3.
Here s what your figure should look like after you add the Check Box component and modify it.
4.
5. Add the following code to the bold_checkbox_Callback function: %checkboxStatus = 0, if the box is unchecked,
网上的对GUI控件的介绍!
6.
7.
8.
9.
10.
11.
12.
13.
end %checkboxStatus = 1, if the box is checked checkboxStatus = get(handles.bold_checkbox,'Value'); if(checkboxStatus
) %if box is checked, text is set to bold set(handles.display_staticText,'FontWeight' , 'bold'); else %if box is unchecked, text is set to normal set(handles.display_staticText,'FontWeight', 'normal');
Note: The bold_checkbox_Callback function triggers when the user activates the check box AND when the user deactivates the check box.
14. Now that we ve completed both the visual and code aspects of the GUI, its
time to run the GUI to make sure it works before we move on. Try checking and unchecking the Check Box component to make sure that the text “Hello World!” is being bolded and unbolded.
And that s it. Those are the basics of using the Check Box component. Now we re ready to move onto the Button Group, which is the most challenging part of this tutorial.
Part Three: Radio Buttons, Toggle Buttons, and Button Group Panel
Radio buttons and Toggle buttons are used ex …… 此处隐藏:13184字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [求职职场]加法运算定律的运用练习题
- [求职职场]大型石油化工工业过程节能新技术
- [求职职场]2015-2020年中国箱纸板行业分析与投资
- [求职职场]NADEX-IWC5A点焊机故障代码
- [求职职场]英语阅读 非常有用
- [求职职场]鲁卫疾控发〔2012〕2号(联合,印发山东
- [求职职场]2014年莆田公务员行测技巧:数字推理的
- [求职职场]基于最近发展区理论的高中数学课堂有效
- [求职职场]与贸易有关的知识产权协议
- [求职职场]【王风范】微演说·职场演说三
- [求职职场]新时代国珍健康大课堂
- [求职职场]群论期末考试复习题
- [求职职场]施工现场消防安全专项施工方案(范本)-
- [求职职场]初中物理光学知识点归纳完美版
- [求职职场]毕业设计总结与体会范文
- [求职职场]江南大学2018年上半年展示设计第1阶段
- [求职职场]景尚乡民兵参战支前保障方案
- [求职职场]【优质】2019年工会职工之家建设工作总
- [求职职场]数据库技术与应用—SQL Server 2008(第
- [求职职场]汽车变速箱构造与工作原理
- 首钢工业区工业遗产资源保护与再利用研
- 第4课 《大学》节选
- 2016程序文件——检验检测结果发布程序
- 2011年高考试题文言文阅读全解释__2011
- 化学是一门基础的自然科学
- 海外做市商制度的借鉴意义
- 外国建筑史复习资料(
- 七年级下思想品德期末综合测试(二)
- 思政课部2013年上学期教学工作总结
- 电大国际公法任务3 0004
- 《圆的认识》教学设计
- 中国轨道交通牵引变流器行业市场发展调
- 中泰证券#定期报告:坚守时代硬科技和
- 浅论企业财务管理与企业经营投资风险的
- 大功率半导体激光器光纤耦合技术调研报
- 中国传统家具的现状与发展探讨
- Broadcom数字电视芯片助海尔扩展高清电
- 新HSK4词汇练习 超全(五)
- 2013届高考数学单元考点复习12
- 雨霖铃精品课件




