import logging

from puithon.HotDOM import HotDOM
from puithon.Window import Window
from puithon.runtime import RuntimeManager


class HelloWindow(Window):

    def page_uri(self):
        return self.html_to_data_uri("""
            <!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>HelloWindow</title>
            </head>
            <body>
            
            <label for="name">Name:</label>
            <input type="text" id="name" value='twin'>
            <button id="ok-button">OK</button>
            <button id="reset-button">Reset</button>
            
            </body>
            </html>
        """)

    def register_handlers(self):
        # Set shortcut
        event_bridge = self._event_bridge

        # The widget to get the 'name' from user input
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    helloWindow = HelloWindow(winheight=500, winwidth=500)
    window_manager = RuntimeManager.get_instance().WindowManager
    window_manager.window_show(helloWindow)
    RuntimeManager.get_instance().start()




b6c87c7cbcb89a6457db5e8b11517e5807bebf02
<mask token>


class HelloWindow(Window):
    <mask token>

    def register_handlers(self):
        event_bridge = self._event_bridge
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


<mask token>

<mask token>


class HelloWindow(Window):

    def page_uri(self):
        return self.html_to_data_uri(
            """
            <!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>HelloWindow</title>
            </head>
            <body>
            
            <label for="name">Name:</label>
            <input type="text" id="name" value='twin'>
            <button id="ok-button">OK</button>
            <button id="reset-button">Reset</button>
            
            </body>
            </html>
        """
            )

    def register_handlers(self):
        event_bridge = self._event_bridge
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


<mask token>

<mask token>


class HelloWindow(Window):

    def page_uri(self):
        return self.html_to_data_uri(
            """
            <!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>HelloWindow</title>
            </head>
            <body>
            
            <label for="name">Name:</label>
            <input type="text" id="name" value='twin'>
            <button id="ok-button">OK</button>
            <button id="reset-button">Reset</button>
            
            </body>
            </html>
        """
            )

    def register_handlers(self):
        event_bridge = self._event_bridge
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    helloWindow = HelloWindow(winheight=500, winwidth=500)
    window_manager = RuntimeManager.get_instance().WindowManager
    window_manager.window_show(helloWindow)
    RuntimeManager.get_instance().start()

import logging
from puithon.HotDOM import HotDOM
from puithon.Window import Window
from puithon.runtime import RuntimeManager


class HelloWindow(Window):

    def page_uri(self):
        return self.html_to_data_uri(
            """
            <!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>HelloWindow</title>
            </head>
            <body>
            
            <label for="name">Name:</label>
            <input type="text" id="name" value='twin'>
            <button id="ok-button">OK</button>
            <button id="reset-button">Reset</button>
            
            </body>
            </html>
        """
            )

    def register_handlers(self):
        event_bridge = self._event_bridge
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    helloWindow = HelloWindow(winheight=500, winwidth=500)
    window_manager = RuntimeManager.get_instance().WindowManager
    window_manager.window_show(helloWindow)
    RuntimeManager.get_instance().start()

import logging

from puithon.HotDOM import HotDOM
from puithon.Window import Window
from puithon.runtime import RuntimeManager


class HelloWindow(Window):

    def page_uri(self):
        return self.html_to_data_uri("""
            <!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>HelloWindow</title>
            </head>
            <body>
            
            <label for="name">Name:</label>
            <input type="text" id="name" value='twin'>
            <button id="ok-button">OK</button>
            <button id="reset-button">Reset</button>
            
            </body>
            </html>
        """)

    def register_handlers(self):
        # Set shortcut
        event_bridge = self._event_bridge

        # The widget to get the 'name' from user input
        textinput = self._get_dom_by_selector('#name')

        @event_bridge('#ok-button', 'click')
        def on_ok_clicked(sender: HotDOM, event):
            name = textinput.get_value()
            print(f'the name is "{name}"')
            sender.set_innertext('Sure!')

        @event_bridge(textinput, 'keyup')
        def on_input_text_change(sender: HotDOM, event):
            print('keyup: value =', sender.get_value())

        @event_bridge('#reset-button', 'click')
        def on_reset(sender: HotDOM, event):
            self._get_dom_by_selector('#ok-button').set_innertext('OK')

    def on_window_ready(self):
        self.register_handlers()

    def on_before_close(self):
        RuntimeManager.get_instance().shutdown()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    helloWindow = HelloWindow(winheight=500, winwidth=500)
    window_manager = RuntimeManager.get_instance().WindowManager
    window_manager.window_show(helloWindow)
    RuntimeManager.get_instance().start()



