Nextion is a robust graphical person interface (GUI) improvement platform for embedded techniques. It permits builders to simply create customized GUIs for his or her units with out the necessity for intensive coding. One of the crucial frequent GUI components is the button. Buttons can be utilized to set off actions, navigate between screens, and extra. On this article, we’ll present you how one can make a button right into a circle utilizing Nextion.
To make a button right into a circle, you will have to make use of the “circle” property. The “circle” property could be set to “true” or “false”. When the “circle” property is about to “true”, the button might be drawn as a circle. It’s also possible to specify the radius of the circle utilizing the “radius” property. The “radius” property is measured in pixels.
Furthermore, you possibly can customise the looks of the button by setting the “background coloration,” “textual content coloration,” and “font” properties. The “background coloration” property specifies the colour of the button’s background. The “textual content coloration” property specifies the colour of the button’s textual content. The “font” property specifies the font of the button’s textual content.
Altering the Button’s Form to Circle
To vary a button’s form to a circle, open the Nextion Editor and choose the button you wish to edit. Within the “Properties” panel, you will discover the “Form” property. Click on on the drop-down menu and choose “Circle”.
Alternatively, you should use the next code to alter the button’s form:
“`
btn.form = “circle”
“`
Customizing the Circle Button
As soon as you have modified the button’s form to a circle, you possibly can additional customise its look by adjusting the next properties:
Property | Description |
---|---|
radius | The radius of the circle button in pixels. |
borderWidth | The width of the button’s border in pixels. |
borderColor | The colour of the button’s border. |
fillColor | The colour of the button’s inside. |
picture | The trail to a picture file to be displayed on the button. |
imagePos | The place of the picture on the button. |
Instance
The next code demonstrates how one can create a customized circle button:
“`
btn.form = “circle”
btn.radius = 50
btn.borderWidth = 2
btn.borderColor = “#FF0000”
btn.fillColor = “#00FF00”
btn.picture = “button.png”
btn.imagePos = “middle”
“`
This code will create a round button with a purple border, a inexperienced inside, a radius of fifty pixels, and a centered picture.
Configuring the Circle Button’s Look
Customizing the circle button’s visible attributes entails setting particular parameters within the Nextion Editor’s object properties panel. The next steps information you thru the configuration course of:
1. Set Button Sort to “RoundRect”
Within the “Object” part, choose “Button” as the article kind. Then, beneath “Model”, select “RoundRect” to create a circle-shaped button.
2. Alter Nook Radius
The “Nook Radius” property determines the curvature of the circle’s corners. Set this worth to “0” for an ideal circle.
3. Configure Background Coloration and Border
Use the “BKG Coloration” and “Border Coloration” properties to specify the fill coloration and description coloration of the circle button, respectively.
4. Setting Superior Look Choices
The “Superior” part provides extra customization choices for the circle button:
Property | Description |
---|---|
Gradient | Provides a gradient impact to the button’s background |
Picture | Inserts a picture inside the button’s boundaries |
Align/Scale | Controls the place and measurement of the picture inside the button |
Alpha Transparency | Adjusts the transparency of the button’s general look |
Occasion Dealing with for the Circle Button
The circle button helps a variety of occasion dealing with choices, permitting you to customise its habits in response to person actions. Listed here are the most typical occasion handlers used with the circle button:
onTap(occasion)
The `onTap` occasion handler is triggered when the person faucets on the circle button. This occasion can be utilized to execute a particular motion or perform when the button is clicked.
So as to add an `onTap` occasion handler to the circle button, use the next syntax:
“`
my_circle_button.onTap(perform() {
// Code to execute when the button is clicked
});
“`
onTouchStart(occasion) and onTouchEnd(occasion)
The `onTouchStart` and `onTouchEnd` occasion handlers are triggered when the person touches and releases the circle button, respectively. These occasions can be utilized to carry out totally different actions primarily based on the person’s contact gesture.
So as to add `onTouchStart` and `onTouchEnd` occasion handlers to the circle button, use the next syntax:
“`
my_circle_button.onTouchStart(perform() {
// Code to execute when the button is touched
});
my_circle_button.onTouchEnd(perform() {
// Code to execute when the button is launched
});
<h4><ins>onHold(period)</ins></h4>
<p>The `onHold` occasion handler is triggered when the person holds the circle button for a specified period. This occasion can be utilized to carry out actions that require a sustained press, equivalent to opening a context menu.</p>
<p>So as to add an `onHold` occasion handler to the circle button, use the next syntax:</p>
my_circle_button.onHold(500, perform() {
// Code to execute when the button is held for 500ms
});
Nextion How To Make A Button Into A Circle
Nextion is a graphical person interface (GUI) for human-machine interfaces (HMIs). It’s a well-liked alternative for creating person interfaces for embedded techniques, equivalent to these present in industrial equipment, medical units, and client electronics. One of the crucial frequent components utilized in Nextion GUIs is the button. By default, buttons are rectangular, however it’s attainable to create round buttons.
To create a round button in Nextion, you will have to make use of the “ImageButton” object. The ImageButton object means that you can specify a picture file for use because the button’s background. You possibly can then use the “Form” property to specify that the button ought to be round.
Listed here are the steps on how one can create a round button in Nextion:
- Open the Nextion Editor and create a brand new challenge.
- Choose the “ImageButton” object from the Toolbox.
- Drag and drop the ImageButton object onto the Type.
- Within the Properties window, set the next properties:
- Identify: The title of the button.
- Picture: The picture file for use because the button’s background.
- Form: Circle.
- Measurement: The dimensions of the button.
- Place: The place of the button.
- Click on the “OK” button to avoid wasting the modifications.
Folks Additionally Ask About Nextion How To Make A Button Into A Circle
Can I exploit any picture file because the button’s background?
Sure, you should use any picture file because the button’s background. Nevertheless, the picture file have to be in a supported format, equivalent to BMP, JPG, or PNG.
Can I alter the scale and place of the button?
Sure, you possibly can change the scale and place of the button. To do that, merely choose the button after which use the Properties window to regulate the Measurement and Place properties.
How do I add textual content to the button?
So as to add textual content to the button, you should use the “Textual content” property. The Textual content property means that you can specify the textual content that might be displayed on the button.