# Path: multi_input_box.py
# class MultiInputBox(Popup):
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def __init__(self, **kwargs):
#         self.window = Window
#         super(MultiInputBox, self).__init__(**kwargs)
#         self.content = self.ids["content"]
#         self.contentButtons = self.ids["contentButtons"]
#         self.wl = []
# 
#     def _dismiss(self):
#         self.dismiss()
# 
#     def open(self):
#         super(MultiInputBox, self).open()
# 
#     def _ok(self):
#         if self.optionCallBack is not None:
#             opts = {}
#             for x in self.wl:
#                 opts[x[0]] = x[1].text
#             self.optionCallBack(opts)
#         self.dismiss()
# 
#     def on_open(self):
#         if self.wl:
#             self.wl[0][1].focus = True
# 
#     def setOptions(self, options, callBack):
#         self.optionCallBack = callBack
#         self.contentButtons.clear_widgets()
#         self.wl = []
#         for name in options:
#             self.contentButtons.add_widget(Label(text=name, size_hint_y=None, height='30dp', halign='right'))
#             tw = TextInput(multiline=False, write_tab=False, use_bubble=False, use_handles=False)
#             self.contentButtons.add_widget(tw)
#             self.wl.append((name, tw))


import kivy
import configparser
import subprocess
import threading
import select
import re
import os
from kivy.app import App
from kivy.logger import Logger
from kivy.uix.stacklayout import StackLayout
from kivy.config import ConfigParser
from kivy.clock import Clock, mainthread
from kivy.factory import Factory
from multi_input_box import MultiInputBox
from functools import partial
                    self.toggle_buttons[name] = (lon, loff, cmd_on, cmd_off, tbtn, poll)
                    tbtn.bind(on_press=partial(self._handle_toggle, name))
                    tbtn.ud = True
                    self.add_widget(tbtn)

                elif section.startswith('script '):
                    name = config.get(section, 'name', fallback=None)
                    script = config.get(section, 'exec', fallback=None)
                    args = config.get(section, 'args', fallback=None)
                    io = config.getboolean(section, 'io', fallback=False)
                    self.debug = config.getboolean(section, 'debug', fallback=False)
                    btn = Factory.MacroButton()
                    btn.text = name
                    btn.background_color = (1, 1, 0, 1)
                    btn.bind(on_press=partial(self.exec_script, script, io, args))
                    btn.ud = True
                    self.add_widget(btn)

            # add simple macro buttons (with optional prompts)
            for (key, v) in config.items('macro buttons'):
                btn = Factory.MacroButton()
                btn.text = key
                btn.bind(on_press=partial(self.send, v))
                btn.ud = True
                self.add_widget(btn)

        except Exception as err:
            Logger.warning('MacrosWidget: WARNING - exception parsing config file: {}'.format(err))

    def new_macro(self):

# Path: multi_input_box.py
# class MultiInputBox(Popup):
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def __init__(self, **kwargs):
#         self.window = Window
#         super(MultiInputBox, self).__init__(**kwargs)
#         self.content = self.ids["content"]
#         self.contentButtons = self.ids["contentButtons"]
#         self.wl = []
# 
#     def _dismiss(self):
#         self.dismiss()
# 
#     def open(self):
#         super(MultiInputBox, self).open()
# 
#     def _ok(self):
#         if self.optionCallBack is not None:
#             opts = {}
#             for x in self.wl:
#                 opts[x[0]] = x[1].text
#             self.optionCallBack(opts)
#         self.dismiss()
# 
#     def on_open(self):
#         if self.wl:
#             self.wl[0][1].focus = True
# 
#     def setOptions(self, options, callBack):
#         self.optionCallBack = callBack
#         self.contentButtons.clear_widgets()
#         self.wl = []
#         for name in options:
#             self.contentButtons.add_widget(Label(text=name, size_hint_y=None, height='30dp', halign='right'))
#             tw = TextInput(multiline=False, write_tab=False, use_bubble=False, use_handles=False)
#             self.contentButtons.add_widget(tw)
#             self.wl.append((name, tw))


# Path: macros_widget.py
import kivy
import configparser
import subprocess
import threading
import select
import re
import os
from kivy.app import App
from kivy.logger import Logger
from kivy.uix.stacklayout import StackLayout
from kivy.config import ConfigParser
from kivy.clock import Clock, mainthread
from kivy.factory import Factory
from multi_input_box import MultiInputBox
from functools import partial

                    self.toggle_buttons[name] = (lon, loff, cmd_on, cmd_off, tbtn, poll)
                    tbtn.bind(on_press=partial(self._handle_toggle, name))
                    tbtn.ud = True
                    self.add_widget(tbtn)

                elif section.startswith('script '):
                    name = config.get(section, 'name', fallback=None)
                    script = config.get(section, 'exec', fallback=None)
                    args = config.get(section, 'args', fallback=None)
                    io = config.getboolean(section, 'io', fallback=False)
                    self.debug = config.getboolean(section, 'debug', fallback=False)
                    btn = Factory.MacroButton()
                    btn.text = name
                    btn.background_color = (1, 1, 0, 1)
                    btn.bind(on_press=partial(self.exec_script, script, io, args))
                    btn.ud = True
                    self.add_widget(btn)

            # add simple macro buttons (with optional prompts)
            for (key, v) in config.items('macro buttons'):
                btn = Factory.MacroButton()
                btn.text = key
                btn.bind(on_press=partial(self.send, v))
                btn.ud = True
                self.add_widget(btn)

        except Exception as err:
            Logger.warning('MacrosWidget: WARNING - exception parsing config file: {}'.format(err))

    def new_macro(self):

        o = MultiInputBox(title='Add Macro')