免責事項:私はPythonとUbuntuについてはかなり新しいです。フルコードは、https://github.com/bluppfisk/coinprice-indicator/tree/multipletickers複数のAppIndicatorインスタンスを起動するPython/Gtk
私は自分自身の複数のインスタンスを実行できるように、libappindicatorを使用してUbuntuのタスクバーに表示されるcryptocoinの価格ティッカーを調整しています。
しかし、システムはさまざまな通知項目を区別することができず、別の通知項目を追加するのではなく上書きしようとします。エラー:
libappindicator-WARNING **: Unable to register object on path '/org/ayatana/NotificationItem/Coin_Price_indicator': An object is already exported for the interface org.kde.StatusNotifierItem at /org/ayatana/NotificationItem/Coin_Price_indicator
Indicatorクラス(NotificationItemを起動する)の新しいインスタンスを作成すると、自動的にこれが行われるはずです。また、私はそれらをマルチスレッドとスレッドを開始した後、メインのGtkスレッドを開始しました:
for cp_instance in cp_instances:
++counter
settings = cp_instance['exchange'] + ':' + cp_instance['asset_pair'] + ':' + str(cp_instance['refresh'])
indicator = Indicator(config, 'indicator' + str(counter), counter, config, settings)
indicators.append(indicator)
for indicator in indicators:
indicator.start()
indicator.join()
Gtk.main()
Indicator.py
class Indicator(object):
def __init__(self, config, settings=None):
self.config = config
self.settings = Settings(settings)
self.refresh_frequency = self.settings.refresh()
self.active_exchange = self.settings.exchange()
icon = self.config['project_root'] + '/resources/icon_32px.png'
self.indicator = AppIndicator.Indicator.new(self.config['app']['name'], icon,
AppIndicator.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE)
self.indicator.set_label("syncing", "$888.88")
self.exchanges = None
おそらくマルチスレッドなしで実行できます。私は、犯人がNotificationItemの複数のインスタンスにあると仮定します – bluppfisk
コードスニペットが何であるかを知ることは難しいです(変数が何であるかわからず、Indicator()コンストラクタはちょうど怪しいと思われます)。 – jku
インジケータ用のコードスニペットが追加されました。 – bluppfisk