fg71
So modern HMI/Scada use web-based front-end to visual components or widgets for a user to interact with.
The great thing is we could do exactly the same thing with other UI Layout software + Render. In this case we will use Kivy.
If you are python programmer you are lucky because we could use front-end and back-end by using Python.
And use UI Layout script language to define the UI layout in markup type language.
 
Lets pretend we like to make UI Layout with 3 buttons to change the screen (same thing we do with tab for browser).
 
we will call this UI Layout markup language in Kivy drawer_nav.kv
 
When you understand how Kivy is working it could become very powerful for prototype touch-screen by visual interaction but also user inputs.
The idea is kind of simple using Raspberry Pi with a touch screen to communicate with other device. The great thing is Kivy
is made for touch inputs and use OpenGL ES in other words GPU acceleration.
 
In my journey to understand UI Layout and different use of markup language I discover how powerful Kivy is.
 
Enjoy, maybe it could become a start for something special
 
Here is the screenshot of the UI Layout
 
[203128%2F9378026%2Fmceclip0]
 
BoxLayout:
    orientation: 'horizontal'
    id: main_layout

    AnchorLayout:
        anchor_x: 'left'
        anchor_y: 'top'
        size_hint_x: 0.25
        canvas.before:
            Color:
                rgba: 0.1, 0.15, 0.2, 1
            Rectangle:
                pos: self.pos
                size: self.size

        BoxLayout:
            orientation: 'vertical'
            size_hint: None, None
            size: 100, 360
            padding: [15, 25, 15, 15] # x, y, width, height
            spacing: 15

            MDBoxLayout:
                orientation: 'horizontal'
                size_hint: None, None
                size: 250, 100
                md_bg_color: 0.2, 0.3, 0.4, 1
                radius: [24]
                padding: [20, 0]
                spacing: 15
                on_touch_up:
                    if self.collide_point(*args[1].pos): main_layout.ids.screen_manager.current = 'home'

                MDIcon:
                    icon: "view-dashboard"
                    size_hint: None, None
                    size: 36, 36
                    padding_y: 24
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1

                MDLabel:
                    text: "Home"
                    valign: "middle"
                    halign: "left"
                    text_size: self.size
                    padding_y: 10
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1
                    font_style: "Subtitle1"

            MDBoxLayout:
                orientation: 'horizontal'
                size_hint: None, None
                size: 250, 100
                md_bg_color: 0.2, 0.3, 0.4, 1
                radius: [24]
                padding: [20, 0]
                spacing: 15
                on_touch_up:
                    if self.collide_point(*args[1].pos): main_layout.ids.screen_manager.current = 'info'

                MDIcon:
                    icon: "information"
                    size_hint: None, None
                    size: 36, 36
                    padding_y: 24
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1

                MDLabel:
                    text: "Info"
                    valign: "middle"
                    halign: "left"
                    text_size: self.size
                    padding_y: 10
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1
                    font_style: "Subtitle1"

            MDBoxLayout:
                orientation: 'horizontal'
                size_hint: None, None
                size: 250, 100
                md_bg_color: 0.2, 0.3, 0.4, 1
                radius: [24]
                padding: [20, 0]
                spacing: 15
                on_touch_up:
                    if self.collide_point(*args[1].pos): main_layout.ids.screen_manager.current = 'conf'

                MDIcon:
                    icon: "cog"
                    size_hint: None, None
                    size: 36, 36
                    padding_y: 24
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1

                MDLabel:
                    text: "Conf"
                    valign: "middle"
                    halign: "left"
                    text_size: self.size
                    padding_y: 10
                    theme_text_color: "Custom"
                    text_color: 1, 1, 1, 1
                    font_style: "Subtitle1"

    ScreenManager:
        id: screen_manager

        Home:
        Info:
        Conf:

<Home>:
    name: 'home'
    MDLabel:
        text: "Dashboard Home View"
        halign: "center"
        valign: "center"

<Info>:
    name: 'info'
    MDLabel:
        text: "Information Panel"
        halign: "center"
        valign: "center"

<Conf>:
    name: 'conf'
    MDLabel:
        text: "Your Configuration Settings"
        halign: "center"
        valign: "center"
 
This is the main code in Python
from kivymd.app import MDApp
from kivy.lang import Builder
from kivymd.uix.screen import MDScreen

class Home(MDScreen): pass
class Info(MDScreen): pass
class Conf(MDScreen): pass

class MyApp(MDApp):
    def build(self):
        return Builder.load_file("drawer_nav.kv")

if __name__ == "__main__":
    MyApp().run()
 
Reply 0 0
fg71
Here is other example using Kivy markup language and Python.
 
Screenshot
[203128%2F9378711%2Fmceclip0]
 
 
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty, ListProperty, NumericProperty
from kivy.metrics import dp

class TemperatureCard(BoxLayout):
    title = StringProperty("")
    value = StringProperty("")
    unit = StringProperty("")
    bg_color = ListProperty([0.2, 0.6, 1, 1])
    text_color = ListProperty([1, 1, 1, 1])
    radius = NumericProperty(dp(24))
    title_size = NumericProperty(dp(24))
    value_size = NumericProperty(dp(48))
    unit_size = NumericProperty(dp(32))

class MainApp(App):
    def build(self):
        return RootLayout()

class RootLayout(BoxLayout):
    pass

if __name__ == "__main__":
    MainApp().run()
 
 
main.kv
 
<TemperatureCard>:
    # Stacks child widgets top-to-bottom (instead of side-by-side)
    orientation: 'vertical'

    # Disables automatic resizing.
    size_hint: None, None

    # Sets the container’s exact width to 300 device-independent pixels, screen scaling).
    width: dp(300)
    height: dp(150)

    # Adds inner spacing around all sides of the container — so children won’t touch the edges.
    padding: dp(20)

    # Defines the space between child widgets inside this layout (vertically, since orientation is vertical).
    spacing: dp(10)
    
    canvas.before:
        Color:
            rgba: root.bg_color
        RoundedRectangle:
            pos: self.pos
            size: self.size
            radius: [root.radius, root.radius, root.radius, root.radius]
    
    # Title
    Label:
        text: root.title
        font_size: root.title_size
        color: root.text_color
        bold: True
        size_hint_y: None
        height: self.texture_size[1]
        text_size: self.width, None
        halign: 'center'
        valign: 'middle'
    
    # Value and unit container
    BoxLayout:
        orientation: 'horizontal'
        size_hint_y: 1
        padding: [0, dp(10), 0, 0]
        
        # Value
        Label:
            text: root.value
            font_size: root.value_size
            color: root.text_color
            bold: True
            size_hint_x: 0.7
            text_size: self.width, None
            halign: 'right'
            valign: 'middle'
        
        # Unit
        Label:
            text: root.unit
            font_size: root.unit_size
            color: root.text_color
            size_hint_x: 0.3
            text_size: self.width, None
            halign: 'left'
            valign: 'bottom'
            padding: [dp(5), dp(15)]

<RootLayout>:
    orientation: 'vertical'
    padding: dp(50)
    spacing: dp(30)
    
    TemperatureCard:
        title: "Temperature"
        value: "10.2"
        unit: "°C"
        bg_color: [0.2, 0.8, 0.5, 1]  # Green
        text_color: [0, 0, 0, 1]       # Black
    
    TemperatureCard:
        title: "Humidity"
        value: "65"
        unit: "%"
        bg_color: [0.2, 0.5, 0.8, 1]  # Blue
        text_color: [1, 1, 1, 1]       # White
        value_size: dp(56)
        unit_size: dp(36)
    
    TemperatureCard:
        title: "Pressure"
        value: "1013"
        unit: "hPa"
        bg_color: [0.8, 0.5, 0.2, 1]  # Orange
        text_color: [1, 1, 1, 1]       # White
        radius: dp(16)
 
Reply 0 0
fg71
Lets go deeper and explore what KivyMD is
 
KivyMD is a fork of Kivy that use Google Material Design Material Design 3 - Google's latest open source design system
 
So I believe the core Kivy is a cross-platform compatible framework, there KivyMD is a fork using Google's Material Design used for Android platform.
For example you could use XCode + toolchain be able to compile Python project to iOS platform.
 
Same it would be for Android, could you see how powerful Kivy or KivyMD could be to build HMI/Scada and you do not need to know anything about C/C++
Reply 0 0
fg71
Simple temperature card with 2 container the first container showing icon, title, value + unit, the second container showing graph
To simulate I have used @davenardella SnapMB, lock at the card widget on left side.
The code is made in Python using KivyMD and pymodbus running on Windows 11 Pro computer.
The graph show a value between 0 and 100 and time interval of 60 second
 
 
[203128%2F9379898%2Fmceclip0]
Reply 0 0
Reply