From 581cb1d34ccd55a585c08be71b5d88ee8350902c Mon Sep 17 00:00:00 2001 From: Danny Dawson Date: Tue, 7 Mar 2023 20:39:37 -0700 Subject: [PATCH] Add a link to open in browser Partially addresses Issue #7 --- gui_kivy.py | 9 +++++++++ op_dedupe.kv | 6 ++++++ .../white-24dp/2x/twotone_launch_white_24dp.png | Bin 0 -> 258 bytes 3 files changed, 15 insertions(+) create mode 100644 src/images/white-24dp/2x/twotone_launch_white_24dp.png diff --git a/gui_kivy.py b/gui_kivy.py index 64c9a8e..e6eb11a 100644 --- a/gui_kivy.py +++ b/gui_kivy.py @@ -2,6 +2,7 @@ import logging +import webbrowser # pylint: disable=import-error from kivy.app import App @@ -223,6 +224,14 @@ def on_release(self): navigate_to_screen(SET_DETAILS_SCREEN_ID, direction='up', refresh=True) +class OpenLinkButton(IconButton): + """A button to open a link in a web browser.""" + selected_item = ObjectProperty(None) + + def on_release(self): + # pylint: disable=no-self-use + webbrowser.open_new_tab(self.selected_item.fields['urls'][0]) + class BackToListButton(IconButton): # pylint: disable=too-few-public-methods """A button for navigating back to the list view.""" diff --git a/op_dedupe.kv b/op_dedupe.kv index 4524a18..7c02bc9 100644 --- a/op_dedupe.kv +++ b/op_dedupe.kv @@ -49,6 +49,10 @@ text: "Refresh" icon_source: 'src/images/white-24dp/2x/twotone_refresh_white_24dp.png' +: + text: "Open in browser" + icon_source: 'src/images/white-24dp/2x/twotone_launch_white_24dp.png' + : on_pre_leave: app.previous_screen = self.name color: periwinkle @@ -125,6 +129,8 @@ selected_item: root.selected_item text: "Archive" icon_source: 'src/images/white-24dp/2x/twotone_archive_white_24dp.png' + OpenLinkButton: + selected_item: root.selected_item : height: 240 diff --git a/src/images/white-24dp/2x/twotone_launch_white_24dp.png b/src/images/white-24dp/2x/twotone_launch_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..2a9dae6c563c6baa5a1b7975f7625ce21d499894 GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtlb$Y)Ar*{oXKv&@?7(xRXU#;O zN3J#rT-C%4a_?vQZx-ttoSqilnW#KfisNH z?=Z3^-Zy(7##Hmuqd}+sICIKRUAcr)?$3e^o<42ZvqxmYba5u0N<{^IeHM;Sks2JI zoEj8BOecqkxQHajIF5iPtw41G38%6d56qfg&MbGpTK7H6l#V5P!~&GAsWu2CTws*F zz<8)I{OOr_*K5DsX+Hd%*@jtPZ7%l>_9w2hmSxtZgmxD*b>?dWJ;mVZ>gTe~DWM4f DJCtCJ literal 0 HcmV?d00001