本文整理汇总了Python中kivy.storage.jsonstore.JsonStore类的典型用法代码示例。如果您正苦于以下问题:Python JsonStore类的具体用法?Python JsonStore怎么用?Python JsonStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JsonStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_enter
def on_enter(self):
pathstore = JsonStore("pathstore.json")
if pathstore.exists("path"):
print pathstore["path"]
self.imagepath = pathstore["path"]["path"][0]
print self.imagepath
self.populateCarousel()
示例2: setUrls
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))
示例3: __init__
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: __init__
def __init__(self, the_app):
super(FinalForm, self).__init__()
self.the_app = the_app
self.statements = {}
store = JsonStore('final_statements.json').get('final_statements')
for key, value in store.items():
self.statements[key] = {}
for k,v in value.items():
self.statements[key][k] = v
title_txt = u"כל הכבוד!"
self.title.text = title_txt[::-1]
statement_layout = BoxLayout(orientation="vertical")
self.statement_label = []
statement_layout.add_widget(BoxLayout(size_hint_y=0.3))
for k in range(0,4):
self.statement_label.append(Label(font_size=40,
font_name="fonts/the_font.ttf",
halign='center', size_hint_y=0.4,
color=[0,0,0, 1]))
statement_layout.add_widget(self.statement_label[-1])
self.add_widget(statement_layout)
end_text = u"סיום"
self.end_button.text = end_text[::-1]
self.end_button.bind(on_press=self.next)
示例5: change_solution_text
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
示例6: on_enter
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
示例7: MbtMergeManager
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)
示例8: check_user_exists
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
示例9: on_enter
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)
示例10: storeformdata
def storeformdata(self):
store = JsonStore('forms.json')
store.put('forms',
walletname=self.input_name.text,
sendtoaddress=self.input_address.text,
amount=self.input_amount.text,
mixin=self.input_mixin.text,
paymentid=self.input_paymentid.text,
mineraddress=self.minerurl_input.text,
mineruser=self.mineruser_input.text,
minerpw=self.minerpw_input.text,
minerthreads=self.minerthreads_input.text)
示例11: save_values
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'))
示例12: UrbanRoot
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()
示例13: __init__
def __init__(self, **kwargs):
kwargs['cols'] = 2
super(MainView, self).__init__(**kwargs)
# def build(self):
# global store
project_store = JsonStore('projectlist.json')
self.list_adapter = ListAdapter(data=[("Project " + r + ' ' + project_store[r]['profile']['projecttitle'])
for r in project_store.keys()],
cls=ListItemButton,
sorted_keys=[])
self.list_adapter.bind(on_selection_change=self.callback)
list_view = ListView(adapter=self.list_adapter)
self.add_widget(list_view)
示例14: check_btn_solution
def check_btn_solution(self,value):
store = JsonStore('result.json')
jsonvalue = store.get('result').values().pop()
value = int(value)
#print ('value=',type(value), type(jsonvalue))
if value == jsonvalue:
#print 'its correct! change text and need to update score! +2'
self.update_score(2)
self.change_text()
#else:
#print 'here is something wrong'
return self.btn_text
示例15: MainApp
class MainApp(App):
#create the application screens
def build(self):
data_dir = getattr(self, 'user_data_dir') #get a writable path to save our score
self.store = JsonStore(join(data_dir, 'score.json')) # create a JsonScore file in the available location
if(not self.store.exists('score')): # if there is no file, we need to save the best score as 1
self.store.put('score', best=1)
if platform() == 'android': # if we are on Android, we can initialize the ADs service
revmob.start_session('54c247f420e1fb71091ad44a')
self.screens = {} # list of app screens
self.screens['menu'] = MenuScreen(self) #self the MainApp instance, so others objects can change the screen
self.screens['game'] = GameScreen(self)
self.root = FloatLayout()
self.open_screen('menu')
self.sound = SoundLoader.load('res/background.mp3') # open the background music
# kivy support music loop, but it was not working on Android. I coded in a different way to fix it
# but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat
# self.sound.loop = True It # was not working on android, so I wrote the following code:
self.sound.play() # play the sound
Clock.schedule_interval(self.check_sound, 1) #every second force the music to be playing
return self.root
# play the sound
def check_sound(self, dt = None):
self.sound.play()
# when the app is minimized on Android
def on_pause(self):
self.sound.stop() # the stop the sound
Clock.unschedule(self.check_sound)
if platform() == 'android': #if on android, we load an ADs and show it
revmob.show_popup()
return True
# when the app is resumed
def on_resume(self):
self.sound.play() # we start the music again
Clock.schedule_interval(self.check_sound, 1)
# show a new screen.
def open_screen(self, name):
self.root.clear_widgets() #remove the current screen
self.root.add_widget(self.screens[name]) # add a new one
self.screens[name].run() # call the run method from the desired screen