Matlab App Designer Change Button Color
At your request, I made the RGB color extractor App and made the following improvements:
Keep standardization of decimal places.
Diversified color formats:
support hexadecimal code and HSV format.
Data output standardization:
Other usages can be found in the related articles of the previous GUI version:
matlab image RGB color extraction
matlab image RGB color extraction (second edition)
Series of articles catalog:
- MATLAB takes you to make your first APP designer program (electronic dictionary)
- Getting started with MATLAB App Designer (1)
- Getting started with MATLAB App Designer (two)
- Getting started with MATLAB App Designer (3)
- MATLAB App Designer Special: RGB Color Extractor
Introduction to actual combat special articles-RGB color extractor
table of Contents
-
-
-
- 16. How to remove the top border of UIAxes
- 17. How to generate an attribute returner when the button is pressed
- 18. How to judge the selection of radio buttons
-
-
16. How to remove the top border of UIAxes
When using UIAxes, even if XLabel, YLabel, and Title are deleted, there is still space reserved for Title above UIAxes:
For this we can adjust the reserved space of Title to a minimum to solve this problem. Specifically, you can adjust the following two properties:
It is recommended to modify the following TitleFontSizeMulitiplier property, which is the title scaling factor, so that only the Title is adjusted. Adjusting one of these two arbitrarily as shown in the figure below can eliminate the Title reserved space:
17. How to generate an attribute returner when the button is pressed
You only need to generate a new UIFigure and various controls through code in the callback function:
and call the local callback function when the button on the new UIFigure is pressed, change the global variables, and delete the new UIFigure:
This part of the code:
typeSetFig= uifigure ( ) ; typeSetFig.Name= 'settype' ; typeSetFig.Color= [ 0.949 0.949 0.949 ] ; typeSetFig.Position= [app.getcolorUIFigure. Position ( 1 ) , . . . app.getcolorUIFigure. Position ( 2 ) +app.getcolorUIFigure. Position ( 4 ) - 220 , . . . 180 190 ] ; btgroup= uibuttongroup (typeSetFig) ; btgroup.Position= [ 10 50 160 130 ] ; btgroup.Title= [ ] ; Button1= uiradiobutton (btgroup) ; Button1.Text= 'RGB (0-1)' ; Button1.Position= [ 10 100 140 20 ] ; Button1.FontName= 'Cambria' ; Button1.FontSize= 14 ; Button2= uiradiobutton (btgroup) ; Button2.Text= 'RGB (0-255)' ; Button2.Position= [ 10 70 140 20 ] ; Button2.FontName= 'Cambria' ; Button2.FontSize= 14 ; Button3= uiradiobutton (btgroup) ; Button3.Text= '#16:#XXXXXX' ; Button3.Position= [ 10 40 140 20 ] ; Button3.FontName= 'Cambria' ; Button3.FontSize= 14 ; Button4= uiradiobutton (btgroup) ; Button4.Text= 'HSV' ; Button4.Position= [ 10 10 140 20 ] ; Button4.FontName= 'Cambria' ; Button4.FontSize= 14 ; switch app.colorClass.type case 1 ,Button1.Value= true ; case 2 ,Button2.Value= true ; case 3 ,Button3.Value= true ; case 4 ,Button4.Value= true ; end ensureBt= uibutton (typeSetFig, 'push' ) ; set (ensureBt, 'ButtonPushedFcn' , @ensure ) ; ensureBt.BackgroundColor= [ 0.8 0.902 0.902 ] ; ensureBt.FontName= '宋体' ; ensureBt.FontSize= 18 ; ensureBt.Position= [ 10 10 75 30 ] ; ensureBt.Text= '确定' ; ensureBt= uibutton (typeSetFig, 'push' ) ; set (ensureBt, 'ButtonPushedFcn' , @cancel ) ; ensureBt.BackgroundColor= [ 0.8 0.902 0.902 ] ; ensureBt.FontName= '宋体' ; ensureBt.FontSize= 18 ; ensureBt.Position= [ 95 10 75 30 ] ; ensureBt.Text= '取消' ; function ensure ( ~ , ~ ) selectedBt=btgroup.SelectedObject.Text; switch selectedBt case Button1.Text,app.colorClass.type= 1 ; case Button2.Text,app.colorClass.type= 2 ; case Button3.Text,app.colorClass.type= 3 ; case Button4.Text,app.colorClass.type= 4 ; end if ~ isempty (app.colorClass.selectedColor) app.TextLabel.Text=app. colorStr (app.colorClass.selectedColor,app.colorClass.type) ; app. setColor ( ) ; end delete (typeSetFig) end function cancel ( ~ , ~ ) delete (typeSetFig) end
18. How to judge the selection of radio buttons
First, set the same callback function for the buttons of the radio button group, find the currently selected button through the SelectedObject of the button group and get its Text property:
then compare the text of the selected button with the text of each button:
RGB color extractor acquisition method:
Baidu network disk link: https://pan.baidu.com/s/1leb9tj2CWHlDXSFNn9rzUA
extraction code: rdac
CSDN download: [to be reviewed]
Matlab App Designer Change Button Color
Source: https://www.codetd.com/en/article/12832135
Posted by: mcdowellwhoustoll.blogspot.com
0 Response to "Matlab App Designer Change Button Color"
Post a Comment