本文整理汇总了Python中kivy.storage.jsonstore.JsonStore.get方法的典型用法代码示例。如果您正苦于以下问题:Python JsonStore.get方法的具体用法?Python JsonStore.get怎么用?Python JsonStore.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.storage.jsonstore.JsonStore
的用法示例。
在下文中一共展示了JsonStore.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WeatherRoot
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class WeatherRoot(BoxLayout):
carousel = ObjectProperty()
current_weather = ObjectProperty()
forecast = ObjectProperty()
locations = ObjectProperty()
add_location_form = ObjectProperty()
def __init__(self, **kwargs):
super(WeatherRoot, self).__init__(**kwargs)
self.store = JsonStore("weather_store.json")
if self.store.exists('locations'):
current_location = self.store.get("locations")["current_location"]
self.show_current_weather(current_location)
def show_current_weather(self, location=None):
self.clear_widgets()
if self.current_weather is None:
self.current_weather = CurrentWeather()
if self.locations is None:
self.locations = Factory.Locations()
if (self.store.exists('locations')):
locations = self.store.get("locations")['locations']
self.locations.locations_list.adapter.data.extend(locations)
if location is not None:
self.current_weather.location = location
if location not in self.locations.locations_list.adapter.data:
self.locations.locations_list.adapter.data.append(location)
self.locations.locations_list._trigger_reset_populate()
self.store.put("locations",
locations=list(self.locations.locations_list.adapter.data),
current_location=location)
self.current_weather.update_weather()
self.add_widget(self.current_weather)
def show_forecast(self, location=None):
self.clear_widgets()
if self.forecast is None:
self.forecast = Factory.Forecast()
if location is not None:
self.forecast.location = location
self.forecast.update_weather()
self.add_widget(self.forecast)
# BEGIN SHOW_MODAL_VIEW
def show_add_location_form(self):
self.add_location_form = AddLocationForm()
self.add_location_form.open()
# END SHOW_MODAL_VIEW
def show_locations(self):
self.clear_widgets()
self.add_widget(self.locations)
示例2: on_enter
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def on_enter(self):
""" The filebrowser screen is being opened """
if not self.initailized:
self.initailized = True
store = JsonStore("zenplayer.json")
if store.exists("filebrowser"):
if "path" in store.get("filebrowser").keys():
file_path = store.get("filebrowser")["path"]
if exists(file_path):
self.filechooser.path = file_path
示例3: __init__
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
self.workers[0].start()
self.workers[1].start()
self.workers[2].start()
self.workers[3].start()
Clock.schedule_interval(self.checkisrunning, 0.1)
Clock.schedule_interval(self.getblockinfo, 1)
Clock.schedule_interval(self.checkbalance, 1)
Clock.schedule_interval(self.checkname, 0.1)
# load data if it exists
if isfile('forms.json'):
try:
store = JsonStore('forms.json')
self.input_name.text = store.get('forms')['walletname']
self.input_address.text = store.get('forms')['sendtoaddress']
self.input_amount.text = store.get('forms')['amount']
self.input_mixin.text = store.get('forms')['mixin']
self.input_paymentid.text = store.get('forms')['paymentid']
self.minerurl_input.text = store.get('forms')['mineraddress']
self.mineruser_input.text = store.get('forms')['mineruser']
self.minerpw_input.text = store.get('forms')['minerpw']
self.minerthreads_input.text = store.get('forms')[
'minerthreads']
except:
pass
示例4: save_values
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def save_values(self,value1,value2,rsvalue):
store = JsonStore('result.json')
store['first'] = {'first': value1}
store['second'] = {'second': value2}
store['result'] = {'result': rsvalue}
store['f1'] = {'f1': rsvalue + int(random()*20) + 1}
store['f2'] = {'f2': rsvalue - int(random()*20) - 1}
store['f3'] = {'f3': rsvalue * int(random()*20) + 20}
store['f4'] = {'f4': rsvalue - int(random()*25) - 1}
print(store.get('first'))
print(store.get('second'))
print(store.get('result'))
示例5: ScoreBar
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class ScoreBar(BoxLayout):
score = NumericProperty()
hi_score = NumericProperty()
game_id = StringProperty()
players = NumericProperty()
active_player = NumericProperty()
def __init__(self,**kwargs):
super(ScoreBar,self).__init__(**kwargs)
self.store = JsonStore(os.path.join(get_user_path(),'scores.json'))
self.bind(score = self.score_changed)
self.set_game_id()
def set_game_id(self, game_id = 'default', multiplayer = False):
self.players = int(multiplayer) + 1
self.active_player = 1
self.game_id = game_id
if self.players == 1:
if self.store.exists(game_id):
data = self.store.get(game_id)
self.hi_score = data['high_score']
else:
self.hi_score = 0
def score_changed(self, *args):
if self.players == 2:
return
if self.game_id != 'default':
date = uspac.fromutc(datetime.datetime.utcnow())
game_id = 'd%i%i%i'%(date.year, date.month, date.day)
if self.game_id != game_id:
#daily challenge has finished, the game reverts to default type so we only update the default high score table
self.set_game_id()
else:
#store the high score in the default table as well as in the daily table
hi_score = 0
if self.store.exists('default'):
data = self.store.get('default')
hi_score = data['high_score']
if self.score > hi_score:
self.store.put('default',high_score=int(self.score))
if self.score > self.hi_score:
self.hi_score = self.score
self.store.put(self.game_id,high_score=int(self.score))
if platform == 'android' and self.players == 1:
if self.score > 600:
App.get_running_app().gs_achieve('achievement_score_of_600')
if self.score > 800:
App.get_running_app().gs_achieve('achievement_score_of_800')
if self.score > 1000:
App.get_running_app().gs_achieve('achievement_score_of_1000')
if self.score > 1200:
App.get_running_app().gs_achieve('achievement_score_of_1200')
示例6: on_enter
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def on_enter(self, *args):
feeds=JsonStore("UmutRss.json")
if len(self.grid.children)>0:
self.grid.clear_widgets()
self.grid.bind(minimum_height=self.grid.setter("height"))
for feed in feeds.keys():
title=feeds.get(feed)["title"]
url=feeds.get(feed)["url"]
btn=MButton(text=title,height=65)
btn.urls=url
btn.bind(on_press=self.next_screen)
self.grid.add_widget(btn)
示例7: UrbanRoot
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class UrbanRoot(BoxLayout):
urbansearch = ObjectProperty()
urbandict = ObjectProperty()
def __init__(self, **kwargs):
super(UrbanRoot, self).__init__(**kwargs)
self.store = JsonStore("dictionary.json")
self.update_urbandict()
def add_to_dictionary(self, word, definition, example):
current = self.store.get('dictionary')['dictionary'] if self.store.exists('dictionary') else []
d = {
'word' : word.encode('utf-8'),
'definition' : definition.encode('utf-8'),
'example' : example.encode('utf-8')
}
if d not in current:
current.append(d)
self.store.put('dictionary', dictionary = list(current))
self.update_urbandict()
Popup(size_hint=(0.8,0.2),title='Success', content = Label(text = 'Word has been added into dictionary')).open()
def update_urbandict(self):
current = self.store.get('dictionary')['dictionary'] if self.store.exists('dictionary') else []
self.urbandict.urbandictcontainer.clear_widgets()
for d in current:
item = Factory.UrbanItemDict()
item.word = d['word'].encode('utf-8')
item.definition = d['definition'].replace('\r','').replace('\t','').encode('utf-8')
item.example = d['example'].replace('\r','').replace('\t','').encode('utf-8')
self.urbandict.urbandictcontainer.add_widget(item)
def remove_from_dict(self, word, definition, example):
current = self.store.get('dictionary')['dictionary'] if self.store.exists('dictionary') else []
d = {
'word' : word.encode('utf-8'),
'definition' : definition.encode('utf-8'),
'example' : example.encode('utf-8')
}
if d in current:
current.remove(d)
self.store.put('dictionary', dictionary = list(current))
print 'removed'
self.update_urbandict()
示例8: change_solution_text
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def change_solution_text(self,value):
store = JsonStore('result.json')
value = store.get(value).values().pop()
#print value
result = self.set_solution_value(value)
self.btn_text = str(result)
return self.btn_text
示例9: setUrls
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def setUrls(self):
if self.urls.__len__()>0:
if hasattr(self,"side"):
self.side.container.clear_widgets()
self.remove_widget(self.side)
del self.side
title=JsonStore("titles.json")
titles=title.get("titles")
self.side = LeftSide()
for k in self.urls:
all=titles["all"]
if all[k]:
lbl = MToggleButton(text=all[k], size_hint=(1, None), height=100)
lbl.urlToShow = self.urls[k]
lbl.ac=self.container
lbl.gndmLabel=self.gndmLabel
if all[k]==u"Gündem":
lbl.state="down"
self.gndmLabel.text=self.title+u" Gündem"
lbl.reqData()
self.side.container.add_widget(lbl)
self.add_widget(self.side)
self.side.x=-self.side.width-self.manager.width*0.2
self.side.y=0
self.side.container.height=100*(len(self.side.container.children))
示例10: Form1App
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class Form1App(App):
def build(self):
self.icon = 'cropped_lumpy2.png'
Config.set("input", "mouse", "mouse, disable_multitouch")
root = RootHome()
self.title = 'hello'
self.store = JsonStore('projectlist.json')
from kivy.core.window import Window
# Window.borderless = True
return root
def on_start(self):
time.sleep(.5)
def g_store(self):
w = self.store
return w
def spit_store(self, text,DR_F, DRR_F, DRIS_F, DRISR_F):
# store = JsonStore('projectlist.json')
print text
print PROJECT
g = self.store.get(PROJECT)
print g
if text == lisp[0][0]:
print DR_F
print type(DRR_F)
print DRIS_F
print DRISR_F
g['content']['designrequirements'][lisp[0][1]] = {"drisr": DRISR_F, "drr": DRR_F, "dr": DR_F, "dris": DRIS_F}
print g
print g['content']
# store[PROJECT]= {"content":{'designrequirements':{ lisp[0][1] : { 'drisr':DRISR_F,
# 'drr':DRR_F,
# 'dr':DR_F,
# 'dris':DRIS_F}}}}
print lisp[0][1]
elif text == lisp[1][0]:
print lisp[1][1]
store[PROJECT]['content']['designrequirements'][lisp[1][1]] = {"drisr": DRISR_F, "drr": DRR_F, "dr": DR_F, "dris": DRIS_F}
print store[PROJECT]['content']
elif text == lisp[2][0]:
print lisp[2][1]
store[PROJECT]['content']['designrequirements'][lisp[2][1]] = {"drisr": DRISR_F, "drr": DRR_F, "dr": DR_F, "dris": DRIS_F}
elif text == lisp[3][0]:
print lisp[3][1]
elif text == lisp[4][0]:
print lisp[4][1]
elif text == lisp[5][0]:
print lisp[5][1]
else:
pass
return store
示例11: __int__
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def __int__(self, **kwargs):
super().__init__(**kwargs)
store = JsonStore('hello.json')
#put some values
store.put('tito', name='Mathieu', org='kivy')
store.put('tshirtman', name='Gabriel', age=27)
store.put('tito', name='Mathieu', age=30)
print('tito is', store.get('tito')['age'])
示例12: check_password
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def check_password(self, un, pw):
general_store = JsonStore('general.json')
key = '%s' % (un)
p = general_store.get("users")
list = json.dumps(p.keys())
print list
if key in p:
matching_pw = json.dumps(general_store.get("users")[key])
print("\nmatching_pw = " + matching_pw)
print '%s' % (pw)
if '"%s"' % (pw) == matching_pw:
return True
else:
return False
else:
warning = 'username not found'
return warning
示例13: MbtMergeManager
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class MbtMergeManager(object):
"""
Keeps track mbtiles merging state (merged vs not merged)
and handles merging.
"""
def __init__(self):
json_store_path = App.get_running_app().json_store_path
self.store = JsonStore(json_store_path)
def merge_not_merged(self):
"""
Merges not merged files.
"""
mbtmerge = MbtMerge()
sources = self.not_merged()
destination = App.get_running_app().main_mbtiles_path
mbtmerge.merge(sources, destination)
for source in sources:
self.add_to_merged(source)
def not_merged(self):
"""
Returns the list of not merged files.
"""
merged_list = self.merged()
not_merged_list = App.get_running_app().mbtiles_paths
for merged in merged_list:
not_merged_list.remove(merged)
return not_merged_list
def merged(self):
"""
Returns the list of merged files.
"""
try:
merged = self.store.get('merged_mbtiles')['list']
except KeyError:
merged = []
return merged
def add_to_merged(self, mbtiles_path):
"""
Adds the mbtiles to the merged list.
"""
merged = self.merged()
merged.append(mbtiles_path)
self.store.put('merged_mbtiles', list=merged)
def remove_from_merged(self, mbtiles_path):
"""
Removes the mbtiles from the merged list.
"""
merged = self.merged()
merged.remove(mbtiles_path)
self.store.put('merged_mbtiles', list=merged)
示例14: check_user_exists
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
def check_user_exists(self, username):
general_store = JsonStore('general.json')
un = username
key = '%s' % (un)
p = general_store.get("users")
list = json.dumps(p.keys())
if key in p:
return True
else:
False
示例15: EntryStackLayout
# 需要导入模块: from kivy.storage.jsonstore import JsonStore [as 别名]
# 或者: from kivy.storage.jsonstore.JsonStore import get [as 别名]
class EntryStackLayout(StackLayout):
def __init__(self, **kwargs):
super(EntryStackLayout, self).__init__(**kwargs)
'''
Build a list of entries to be displayed on the app
'''
self.id = 'entry_stack_layout'
self.name = 'entry_stack_layout'
self.size_hint = (1,1)
self.entry_widgets = []
self.screen_manager = App.get_running_app().sm
self.build_list()
for i in self.entry_widgets:
self.add_widget(i)
def build_list(self):
self.data_store = JsonStore('./dat.json')
entries = json.loads(self.data_store.get('feeds')['entries'])
entries_count = len(entries)
card_contents = StackLayout(size_hint = [1, 0.0225])
for entry in entries:
self.size_hint[1] += 0.35
card_contents.add_widget(Image(source = './assets/images/talkpython-nowrds.png', size_hint = [0.15,0.4]))
card_contents.add_widget(Label(text=entry['title'],
valign='top',
size_hint=[0.85, 0.4],
text_size= [Window.width * 0.35, None]))
card_contents.add_widget(MyAudioPlayer(source="./assets/audio/043_monitoring_high_performance_python_apps_at_opbeat.mp3",
thumbnail= './assets/images/talkpython.png',
size_hint = [1,0.4],
allow_fullscreen= False
))
#card_contents.add_widget(VideoPlayer(source="./assets/videos/hst_1.mpg", size_hint = [1,0.8]))
self.entry_widgets.append(card_contents)
card_contents = StackLayout(size_hint = [1, 0.0225])
def test_bind(self):
print('test bind EntryStackLayout', self.test_data_store)