本文整理汇总了Python中uix.dialogs.settings.SettingsDialog.update方法的典型用法代码示例。如果您正苦于以下问题:Python SettingsDialog.update方法的具体用法?Python SettingsDialog.update怎么用?Python SettingsDialog.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uix.dialogs.settings.SettingsDialog
的用法示例。
在下文中一共展示了SettingsDialog.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ElectrumWindow
# 需要导入模块: from uix.dialogs.settings import SettingsDialog [as 别名]
# 或者: from uix.dialogs.settings.SettingsDialog import update [as 别名]
class ElectrumWindow(App):
electrum_config = ObjectProperty(None)
language = StringProperty('en')
def set_URI(self, uri):
self.switch_to('send')
self.send_screen.set_URI(uri)
def on_new_intent(self, intent):
if intent.getScheme() != 'bitcoin':
return
uri = intent.getDataString()
self.set_URI(uri)
def on_language(self, instance, language):
Logger.info('language: {}'.format(language))
_.switch_lang(language)
def on_quotes(self, d):
#Logger.info("on_quotes")
pass
def on_history(self, d):
#Logger.info("on_history")
if self.history_screen:
Clock.schedule_once(lambda dt: self.history_screen.update())
def _get_bu(self):
return self.electrum_config.get('base_unit', 'mBTC')
def _set_bu(self, value):
assert value in base_units.keys()
self.electrum_config.set_key('base_unit', value, True)
self.update_status()
if self.history_screen:
self.history_screen.update()
base_unit = AliasProperty(_get_bu, _set_bu)
status = StringProperty('')
fiat_unit = StringProperty('')
def on_fiat_unit(self, a, b):
if self.history_screen:
self.history_screen.update()
def decimal_point(self):
return base_units[self.base_unit]
def btc_to_fiat(self, amount_str):
if not amount_str:
return ''
rate = run_hook('exchange_rate')
if not rate:
return ''
fiat_amount = self.get_amount(amount_str + ' ' + self.base_unit) * rate / pow(10, 8)
return "{:.2f}".format(fiat_amount).rstrip('0').rstrip('.')
def fiat_to_btc(self, fiat_amount):
if not fiat_amount:
return ''
rate = run_hook('exchange_rate')
if not rate:
return ''
satoshis = int(pow(10,8) * Decimal(fiat_amount) / Decimal(rate))
return format_satoshis_plain(satoshis, self.decimal_point())
def get_amount(self, amount_str):
a, u = amount_str.split()
assert u == self.base_unit
try:
x = Decimal(a)
except:
return None
p = pow(10, self.decimal_point())
return int(p * x)
_orientation = OptionProperty('landscape',
options=('landscape', 'portrait'))
def _get_orientation(self):
return self._orientation
orientation = AliasProperty(_get_orientation,
None,
bind=('_orientation',))
'''Tries to ascertain the kind of device the app is running on.
Cane be one of `tablet` or `phone`.
:data:`orientation` is a read only `AliasProperty` Defaults to 'landscape'
'''
_ui_mode = OptionProperty('phone', options=('tablet', 'phone'))
def _get_ui_mode(self):
return self._ui_mode
ui_mode = AliasProperty(_get_ui_mode,
#.........这里部分代码省略.........
示例2: ElectrumWindow
# 需要导入模块: from uix.dialogs.settings import SettingsDialog [as 别名]
# 或者: from uix.dialogs.settings.SettingsDialog import update [as 别名]
class ElectrumWindow(App):
electrum_config = ObjectProperty(None)
language = StringProperty("en")
def set_URI(self, uri):
self.switch_to("send")
self.send_screen.set_URI(uri)
def on_new_intent(self, intent):
if intent.getScheme() != "bitcoin":
return
uri = intent.getDataString()
self.set_URI(uri)
def on_language(self, instance, language):
Logger.info("language: {}".format(language))
_.switch_lang(language)
def on_quotes(self, d):
# Logger.info("on_quotes")
pass
def on_history(self, d):
# Logger.info("on_history")
if self.history_screen:
Clock.schedule_once(lambda dt: self.history_screen.update())
def _get_bu(self):
return self.electrum_config.get("base_unit", "mBTC")
def _set_bu(self, value):
assert value in base_units.keys()
self.electrum_config.set_key("base_unit", value, True)
self.update_status()
if self.history_screen:
self.history_screen.update()
base_unit = AliasProperty(_get_bu, _set_bu)
status = StringProperty("")
fiat_unit = StringProperty("")
def on_fiat_unit(self, a, b):
if self.history_screen:
self.history_screen.update()
def decimal_point(self):
return base_units[self.base_unit]
def btc_to_fiat(self, amount_str):
if not amount_str:
return ""
rate = run_hook("exchange_rate")
if not rate:
return ""
fiat_amount = self.get_amount(amount_str + " " + self.base_unit) * rate / pow(10, 8)
return "{:.2f}".format(fiat_amount).rstrip("0").rstrip(".")
def fiat_to_btc(self, fiat_amount):
if not fiat_amount:
return ""
rate = run_hook("exchange_rate")
if not rate:
return ""
satoshis = int(pow(10, 8) * Decimal(fiat_amount) / Decimal(rate))
return format_satoshis_plain(satoshis, self.decimal_point())
def get_amount(self, amount_str):
a, u = amount_str.split()
assert u == self.base_unit
try:
x = Decimal(a)
except:
return None
p = pow(10, self.decimal_point())
return int(p * x)
_orientation = OptionProperty("landscape", options=("landscape", "portrait"))
def _get_orientation(self):
return self._orientation
orientation = AliasProperty(_get_orientation, None, bind=("_orientation",))
"""Tries to ascertain the kind of device the app is running on.
Cane be one of `tablet` or `phone`.
:data:`orientation` is a read only `AliasProperty` Defaults to 'landscape'
"""
_ui_mode = OptionProperty("phone", options=("tablet", "phone"))
def _get_ui_mode(self):
return self._ui_mode
ui_mode = AliasProperty(_get_ui_mode, None, bind=("_ui_mode",))
"""Defines tries to ascertain the kind of device the app is running on.
Cane be one of `tablet` or `phone`.
:data:`ui_mode` is a read only `AliasProperty` Defaults to 'phone'
#.........这里部分代码省略.........