From cff2bf7c6f08d9f8e10c7bfb1c3e7976b375391c Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sat, 24 Sep 2016 22:34:44 +0300 Subject: [PATCH] Implement _on_play method --- youtube_dl_gui/mainframe.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 1faf1e5..81c3c96 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -331,7 +331,19 @@ class MainFrame(wx.Frame): self._download_list.remove(object_id) def _on_play(self, event): - raise Exception("Implement me!") + selected_row = self._status_list.get_selected() + + if selected_row == -1: + self._create_popup("No row selected", self.ERROR_LABEL, wx.OK | wx.ICON_EXCLAMATION) + else: + object_id = self._status_list.GetItemData(selected_row) + selected_download_item = self._download_list.get_item(object_id) + + if selected_download_item.stage == "Completed": + filename = selected_download_item.get_files()[-1] + open_file(filename) + else: + self._create_popup("Item is not completed", self.INFO_LABEL, wx.OK | wx.ICON_INFORMATION) def _on_arrow_up(self, event): raise Exception("Implement me!")