13 June 2021
add more FOMO to your life by constantly showing crypto prices as an applet. Wrote a small gnome applet to keep track of prices :)
I usually use bitbns as the source
Lock Thread
1 from gi.repository import Gtk as gtk
2 from gi.repository import AppIndicator3 as appindicator
3 import signal
4 from threading import Thread
5
6 APPINDICATOR_ID = "my-crypto-tracker"
7
8 def main():
9 indicator = appindicator.Indicator.new(
10 APPINDICATOR_ID,
11 os.path.abspath("crypto.svg"),
12 appindicator.IndicatorCategory.SYSTEM_SERVICES,
13 )
14 indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
15 indicator.set_menu(build_menu())
16 gtk.main()
17
18 def build_menu():
19 menu = gtk.Menu()
20 item_quit = gtk.MenuItem("Quit")
21 menu.append(item_quit)
22 menu.show_all()
23 return menu
24
25 def quit(source):
26 notify.uninit()
27 gtk.main_quit()
28
29 if __name__ == "__main__":
30 signal.signal(signal.SIGINT, signal.SIG_DFL)
31
1 CRYPTO_PRICE_ENDPOINT = "https://bitbns.com/order/getTickerWithVolume/"
2 def fetch_prices(coin_symbol):
3 response = requests.get(CRYPTO_PRICE_ENDPOINT)
4 response_to_json = response.json()
5 coin_price = response_to_json[coin_symbol]["last_traded_price"]
6 return coin_price
7
1 use indicator.set_label(your_thread) to keep updating the ticker
2
No comments yet.
933 views