Advertisement
jwinterm

buttonList.py

Dec 23rd, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.core.clipboard import Clipboard
  3. from kivy.lang import Builder
  4. from kivy.uix.boxlayout import BoxLayout
  5. from kivy.uix.button import Button
  6.  
  7.  
  8.  
  9. Builder.load_string("""
  10. <RootWidget>
  11.    BoxLayout:
  12.        padding: 30, 30, 30, 30
  13.        orientation: "vertical"
  14.        Label:
  15.            size_hint: 1, 0.2
  16.            text: "Double click buttons to copy tx id"
  17.        ScrollView:
  18.            id: tx_scroller
  19.            size_hint: 1, 0.8
  20.            GridLayout:
  21.                cols: 1
  22.                spacing: 7
  23.                size_hint_y: None
  24.                id: tx_list
  25. """)
  26.  
  27. tx_list = [
  28.     ['asdf', 1.234, False],
  29.     ['fghj', 2.234, False],
  30.     ['xvbb', 3.234, False],
  31.     ['wetw', 4.234, False],
  32.     ['hjkl', 5.234, False],
  33.     ['wret', 6.234, False],
  34.     ['bvnm', 7.234, False],
  35.     ['zzzz', 8.234, False]
  36.     ]
  37.  
  38.  
  39. class RootWidget(BoxLayout):
  40.     """Root Kivy accordion widget class"""
  41.     tx_dict = {}
  42.     def __init__(self, **kwargs):
  43.         super(RootWidget, self).__init__(**kwargs)
  44.         for idx, val in enumerate(tx_list):
  45.             self.tx_dict[idx] = Button(text="tx_id: {0} | amount: {1:.4f}".format(val[0], val[1]),
  46.                                        size_hint_y=None, height=15, font_size=9)
  47.             self.tx_dict[idx].bind(on_press=Clipboard.put(val[0]))
  48.             self.ids.tx_list.add_widget(self.tx_dict[idx])
  49.  
  50. class lightWalletApp(App):
  51.     def build(self):
  52.         root = RootWidget()
  53.         return root
  54.  
  55.  
  56. if __name__ == '__main__':
  57.     lightWalletApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement