Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.properties import ObjectProperty
- from kivy.uix.boxlayout import BoxLayout
- from kivy.uix.popup import Popup
- from kivy.uix.textinput import TextInput
- Builder.load_string("""
- <LoadWalletPopup>:
- id: load_wallet_popup
- title: "Load Wallet Window"
- size_hint: 0.75, 0.75
- auto_dismiss: False
- wallet_path: wallet_path
- wallet_pw: wallet_pw
- repeat_wallet_pw: repeat_wallet_pw
- BoxLayout:
- padding: 60, 30, 60, 30
- orientation: 'vertical'
- Label:
- text: "Enter wallet keys path:"
- TabTextInput:
- id: wallet_path
- next: wallet_pw
- Label:
- text: "Enter wallet password:"
- TabTextInput:
- id: wallet_pw
- password: True
- next: repeat_wallet_pw
- Label:
- text: "Repeat wallet password:"
- TabTextInput:
- id: repeat_wallet_pw
- password: True
- next: wallet_path
- Button:
- text: "Click to load wallet"
- on_press: root.submitForm()
- <RootWidget>
- BoxLayout:
- Button:
- text: "Press to launch popup"
- on_press: root.launchPopup()
- """)
- class TabTextInput(TextInput):
- """ Tab or enter to next TextInput class """
- def __init__(self, *args, **kwargs):
- self.next = kwargs.pop('next', None)
- super(TabTextInput, self).__init__(*args, **kwargs)
- self.multiline = False
- def set_next(self, next):
- self.next = next
- def _keyboard_on_key_down(self, window, keycode, text, modifiers):
- key, key_str = keycode
- print(key, key_str)
- if key == 9 and self.next is not None:
- self.next.focus = True
- self.next.select_all()
- else:
- super(TabTextInput, self)._keyboard_on_key_down(window, keycode, text, modifiers)
- class LoadWalletPopup(Popup):
- """ Wallet creation screen popup """
- wallet_name = ObjectProperty()
- wallet_pw = ObjectProperty()
- repeat_wallet_pw = ObjectProperty()
- def __init__(self, *args, **kwargs):
- super(LoadWalletPopup, self).__init__(*args, **kwargs)
- def _keyboard_on_key_down(self, window, keycode, text, modifiers):
- key, key_str = keycode
- print(key, key_str)
- if key in (13, 271):
- self.submitForm()
- else:
- super(LoadWalletPopup, self)._keyboard_on_key_down(window, keycode, text, modifiers)
- def submitForm(self):
- self.dismiss()
- print("dismissed")
- class RootWidget(BoxLayout):
- """Root Kivy accordion widget class"""
- def __init__(self, **kwargs):
- super(RootWidget, self).__init__(**kwargs)
- def launchPopup(self):
- p = LoadWalletPopup()
- p.open()
- class lightWalletApp(App):
- def build(self):
- root = RootWidget()
- return root
- if __name__ == '__main__':
- lightWalletApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement