Skip to content

Commit

Permalink
Add a link to open in browser
Browse files Browse the repository at this point in the history
Partially addresses Issue #7
  • Loading branch information
quasistoic committed Mar 8, 2023
1 parent e28cccb commit 581cb1d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gui_kivy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import logging
import webbrowser

# pylint: disable=import-error
from kivy.app import App
Expand Down Expand Up @@ -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."""

Expand Down
6 changes: 6 additions & 0 deletions op_dedupe.kv
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
text: "Refresh"
icon_source: 'src/images/white-24dp/2x/twotone_refresh_white_24dp.png'

<OpenLinkButton>:
text: "Open in browser"
icon_source: 'src/images/white-24dp/2x/twotone_launch_white_24dp.png'

<Screen>:
on_pre_leave: app.previous_screen = self.name
color: periwinkle
Expand Down Expand Up @@ -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

<HeaderRow>:
height: 240
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 581cb1d

Please sign in to comment.