diff options
author | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
---|---|---|
committer | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
commit | 9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch) | |
tree | 9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /gui/plist.py | |
parent | 11cc316b74d5f3f283413a33e7693b314741aa4a (diff) | |
download | manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2 manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip |
Initial commit
Diffstat (limited to 'gui/plist.py')
-rw-r--r-- | gui/plist.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gui/plist.py b/gui/plist.py new file mode 100644 index 0000000..a009a32 --- /dev/null +++ b/gui/plist.py @@ -0,0 +1,54 @@ +from kivy.app import App +from kivy.adapters.listadapter import ListAdapter +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.floatlayout import FloatLayout +from kivy.properties import StringProperty, ListProperty +from kivy.uix.listview import ListView, ListItemLabel + + +class PlayersListItem(BoxLayout, ListItemLabel): + nick = StringProperty(allow_none=False) + + def on_touch_down(self, touch): + if not self.collide_point(*touch.pos): + return False + touch.grab(self) + return True + + def on_touch_up(self, touch): + if not self.collide_point(*touch.pos): + return False + if touch.grab_current is self: + app = App.get_running_app() + app.root.chat_input.text = '/w "{}" '.format(self.nick) + app.root.chat_input.focus = True + touch.ungrab(self) + return True + + +class PlayersList(FloatLayout): + items = ListProperty([]) + + def __init__(self, **kwargs): + super(PlayersList, self).__init__(**kwargs) + + player_args_coverter = lambda row_index, nick: {"nick" : nick, + "size_hint_y": None, "height": "30dp", "pos_hint_y": 0.9 } + + list_adapter = ListAdapter( + data=["Ginaria", "Celestia"], + args_converter=player_args_coverter, + selection_mode='single', + allow_empty_selection=True, + cls=PlayersListItem) + + list_view = ListView(adapter=list_adapter, + size_hint=(1.0, 1.0), + pos_hint={'center_x': 0.5}) + + def data_changed(instance, value): + list_adapter.data = value + + self.bind(items=data_changed) + + self.add_widget(list_view) |