免责声明:我是Python和Ubuntu的新手。完整代码位于https://github.com/bluppfisk/coinprice-indicator/tree/multipletickers
我正在调整一个cryptocoin价格代码,它使用libappindicator显示在Ubuntu的任务栏中,以便能够运行自己的多个实例。
但是,看起来系统无法区分各种通知项目,并尝试覆盖它们而不是添加另一个。错误:
libappindicator-WARNING **:无法在路径上注册对象 '/ org / ayatana / NotificationItem / Coin_Price_indicator':对象是 已经为org.kde.StatusNotifierItem接口导出了 /组织/阿亚坦/ 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
答案 0 :(得分:0)
问题在于AppIndicator.Indicator.new()
。运行多个实例总是会收到相同的名称,因此会占用彼此的空间。为每个实例运行更改第一个参数是解决方案。