Skip to content

Instantly share code, notes, and snippets.

@matham
Created August 5, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matham/8eef2400ca1035b9d1b3608b19fe21fe to your computer and use it in GitHub Desktop.
Save matham/8eef2400ca1035b9d1b3608b19fe21fe to your computer and use it in GitHub Desktop.
class FileChooserProgress(FileChooserProgressBase):
@KV()
def apply_kv(self):
with KVCtx():
self.pos_hint = {'x': 0, 'y': 0}
with self.canvas:
Factory.Color(rgba=(0, 0, 0, .8))
rect = Factory.Rectangle()
rect.pos ^= self.pos
rect.size ^= self.size
opening = Factory.Label(
parent=self, pos_hint={'x': .2, 'y': .6}, size_hint=(.6, .2))
opening.text @= 'Opening %s' % self.path
flt = Factory.FloatLayout(
parent=self, pos_hint={'x': .2, 'y': .4}, size_hint=(.6, .2))
pb = Factory.ProgressBar(
parent=flt, pos_hint={'x': 0, 'center_y': .5})
pb.max @= self.total
pb.value @= self.index
label = Factory.Label(
parent=flt, pos_hint={'x': 0}, size_hint_y=None,
font_size='13sp', color=(.8, .8, .8, .8))
label.text @= '%d / %d' % (self.index, self.total)
label.height @= label.texture_size[1]
label.y @= pb.center_y - label.height - 8
anchor = Factory.AnchorLayout(
parent=self, pos_hint={'x': .2, 'y': .2}, size_hint=(.6, .2))
btn = Factory.Button(
parent=anchor, text='Cancel', size_hint=(None, None),
size=(150, 44))
with KVRule(btn.on_release):
self.cancel()
__kv_kvc_compile_flags = "('minimal', False, True, False, False, True)"
def apply_kv(self):
from kivy.lang.compiler.kv_context import KVCtx as __KVCtx, KVRule as __KVRule
from kivy.lang.compiler.runtime import add_graphics_callback as __kv_add_graphics_callback
__kv_mod_func = apply_kv
globals().clear()
globals().update(__kv_mod_func._kv_src_func_globals)
globals()["apply_kv"] = __kv_mod_func
__kv_rule_0 = __kv_rule_1 = __kv_rule_2 = __kv_rule_3 = __kv_rule_4 = __kv_rule_5 = __kv_rule_6 = __kv_rule_7 = __kv_rule_8 = None
__kv_ctx_0 = __KVCtx()
__kv_rule_0 = __KVRule()
__kv_rule_0.delay = "canvas"
__kv_rule_0.name = None
__kv_ctx_0.add_rule(__kv_rule_0)
__kv_rule_1 = __KVRule()
__kv_rule_1.delay = "canvas"
__kv_rule_1.name = None
__kv_ctx_0.add_rule(__kv_rule_1)
__kv_rule_2 = __KVRule()
__kv_rule_2.delay = None
__kv_rule_2.name = None
__kv_ctx_0.add_rule(__kv_rule_2)
__kv_rule_3 = __KVRule()
__kv_rule_3.delay = None
__kv_rule_3.name = None
__kv_ctx_0.add_rule(__kv_rule_3)
__kv_rule_4 = __KVRule()
__kv_rule_4.delay = None
__kv_rule_4.name = None
__kv_ctx_0.add_rule(__kv_rule_4)
__kv_rule_5 = __KVRule()
__kv_rule_5.delay = None
__kv_rule_5.name = None
__kv_ctx_0.add_rule(__kv_rule_5)
__kv_rule_6 = __KVRule()
__kv_rule_6.delay = None
__kv_rule_6.name = None
__kv_ctx_0.add_rule(__kv_rule_6)
__kv_rule_7 = __KVRule()
__kv_rule_7.delay = None
__kv_rule_7.name = None
__kv_ctx_0.add_rule(__kv_rule_7)
__kv_rule_8 = __KVRule()
__kv_rule_8.delay = None
__kv_rule_8.name = None
__kv_ctx_0.add_rule(__kv_rule_8)
self.pos_hint = {'x': 0, 'y': 0}
with self.canvas:
Factory.Color(rgba=(0, 0, 0, 0.8))
rect = Factory.Rectangle()
rect.pos = self.pos
rect.size = self.size
opening = Factory.Label(parent=self, pos_hint={'x': 0.2, 'y': 0.6}, size_hint=(0.6, 0.2))
opening.text = 'Opening %s' % self.path
flt = Factory.FloatLayout(parent=self, pos_hint={'x': 0.2, 'y': 0.4}, size_hint=(0.6, 0.2))
pb = Factory.ProgressBar(parent=flt, pos_hint={'x': 0, 'center_y': 0.5})
pb.max = self.total
pb.value = self.index
label = Factory.Label(parent=flt, pos_hint={'x': 0}, size_hint_y=None, font_size='13sp', color=(0.8, 0.8, 0.8, 0.8))
label.text = '%d / %d' % (self.index, self.total)
label.height = label.texture_size[1]
label.y = pb.center_y - label.height - 8
anchor = Factory.AnchorLayout(parent=self, pos_hint={'x': 0.2, 'y': 0.2}, size_hint=(0.6, 0.2))
btn = Factory.Button(parent=anchor, text='Cancel', size_hint=(None, None), size=(150, 44))
self.cancel()
__kv_bind_store_0 = [None, ] * 7
__kv_bind_store_1 = [None, ] * 2
__kv_bind_store_2 = [None, ] * 1
__kv_bind_store_3 = [None, ] * 1
__kv_ctx_0.bind_stores_by_graph = (__kv_bind_store_0, __kv_bind_store_1, __kv_bind_store_2, __kv_bind_store_3, )
__kv_ctx_0.rebind_functions = ()
def __kv_leaf_callback_canvas_0(*__kv_largs, rect=rect, self=self):
rect.pos = self.pos
def __kv_leaf_callback_0(*__kv_largs, __kv_canvas_item=[__kv_leaf_callback_canvas_0, None, None]):
__kv_add_graphics_callback(__kv_canvas_item, __kv_largs)
def __kv_leaf_callback_canvas_1(*__kv_largs, rect=rect, self=self):
rect.size = self.size
def __kv_leaf_callback_1(*__kv_largs, __kv_canvas_item=[__kv_leaf_callback_canvas_1, None, None]):
__kv_add_graphics_callback(__kv_canvas_item, __kv_largs)
def __kv_leaf_callback_2(*__kv_largs, opening=opening, self=self):
opening.text = 'Opening %s' % self.path
def __kv_leaf_callback_3(*__kv_largs, pb=pb, self=self):
pb.max = self.total
def __kv_leaf_callback_4(*__kv_largs, pb=pb, self=self):
pb.value = self.index
def __kv_leaf_callback_5(*__kv_largs, label=label, self=self):
label.text = '%d / %d' % (self.index, self.total)
def __kv_leaf_callback_6(*__kv_largs, label=label):
label.height = label.texture_size[1]
def __kv_leaf_callback_7(*__kv_largs, label=label, pb=pb):
label.y = pb.center_y - label.height - 8
def __kv_leaf_callback_8(*__kv_largs, self=self):
self.cancel()
__kv__fbind = getattr(self, "fbind", None)
if __kv__fbind is not None:
__kv_bind_store_0[0] = [self, "size", __kv_leaf_callback_1, __kv__fbind("size", __kv_leaf_callback_1), 1, (0, )]
__kv_bind_store_0[1] = [self, "pos", __kv_leaf_callback_0, __kv__fbind("pos", __kv_leaf_callback_0), 1, (1, )]
__kv_bind_store_0[2] = [self, "path", __kv_leaf_callback_2, __kv__fbind("path", __kv_leaf_callback_2), 1, (2, )]
__kv_bind_store_0[3] = [self, "index", __kv_leaf_callback_4, __kv__fbind("index", __kv_leaf_callback_4), 1, (3, )]
__kv_bind_store_0[4] = [self, "total", __kv_leaf_callback_5, __kv__fbind("total", __kv_leaf_callback_5), 1, (4, )]
__kv_bind_store_0[5] = [self, "total", __kv_leaf_callback_3, __kv__fbind("total", __kv_leaf_callback_3), 1, (5, )]
__kv_bind_store_0[6] = [self, "index", __kv_leaf_callback_5, __kv__fbind("index", __kv_leaf_callback_5), 1, (6, )]
else:
__kv_bind_store_0[0] = [self, "size", __kv_leaf_callback_1, None, 1, (0, )]
__kv_bind_store_0[1] = [self, "pos", __kv_leaf_callback_0, None, 1, (1, )]
__kv_bind_store_0[2] = [self, "path", __kv_leaf_callback_2, None, 1, (2, )]
__kv_bind_store_0[3] = [self, "index", __kv_leaf_callback_4, None, 1, (3, )]
__kv_bind_store_0[4] = [self, "total", __kv_leaf_callback_5, None, 1, (4, )]
__kv_bind_store_0[5] = [self, "total", __kv_leaf_callback_3, None, 1, (5, )]
__kv_bind_store_0[6] = [self, "index", __kv_leaf_callback_5, None, 1, (6, )]
__kv__fbind = getattr(label, "fbind", None)
if __kv__fbind is not None:
__kv_bind_store_1[0] = [label, "texture_size", __kv_leaf_callback_6, __kv__fbind("texture_size", __kv_leaf_callback_6), 1, (0, )]
__kv_bind_store_1[1] = [label, "height", __kv_leaf_callback_7, __kv__fbind("height", __kv_leaf_callback_7), 1, (1, )]
else:
__kv_bind_store_1[0] = [label, "texture_size", __kv_leaf_callback_6, None, 1, (0, )]
__kv_bind_store_1[1] = [label, "height", __kv_leaf_callback_7, None, 1, (1, )]
__kv__fbind = getattr(pb, "fbind", None)
if __kv__fbind is not None:
__kv_bind_store_2[0] = [pb, "center_y", __kv_leaf_callback_7, __kv__fbind("center_y", __kv_leaf_callback_7), 1, (0, )]
else:
__kv_bind_store_2[0] = [pb, "center_y", __kv_leaf_callback_7, None, 1, (0, )]
__kv__fbind = getattr(btn, "fbind", None)
if __kv__fbind is not None:
__kv_bind_store_3[0] = [btn, "on_release", __kv_leaf_callback_8, __kv__fbind("on_release", __kv_leaf_callback_8), 1, (0, )]
else:
__kv_bind_store_3[0] = [btn, "on_release", __kv_leaf_callback_8, None, 1, (0, )]
__kv_rule_0.callback = __kv_leaf_callback_0
__kv_rule_0._callback = __kv_leaf_callback_canvas_0
__kv_rule_0.bind_stores = ((__kv_bind_store_0, (1, )), )
__kv_rule_1.callback = __kv_leaf_callback_1
__kv_rule_1._callback = __kv_leaf_callback_canvas_1
__kv_rule_1.bind_stores = ((__kv_bind_store_0, (0, )), )
__kv_rule_2.callback = __kv_leaf_callback_2
__kv_rule_2._callback = None
__kv_rule_2.bind_stores = ((__kv_bind_store_0, (2, )), )
__kv_rule_3.callback = __kv_leaf_callback_3
__kv_rule_3._callback = None
__kv_rule_3.bind_stores = ((__kv_bind_store_0, (5, )), )
__kv_rule_4.callback = __kv_leaf_callback_4
__kv_rule_4._callback = None
__kv_rule_4.bind_stores = ((__kv_bind_store_0, (3, )), )
__kv_rule_5.callback = __kv_leaf_callback_5
__kv_rule_5._callback = None
__kv_rule_5.bind_stores = ((__kv_bind_store_0, (4, 6, )), )
__kv_rule_6.callback = __kv_leaf_callback_6
__kv_rule_6._callback = None
__kv_rule_6.bind_stores = ((__kv_bind_store_1, (0, )), )
__kv_rule_7.callback = __kv_leaf_callback_7
__kv_rule_7._callback = None
__kv_rule_7.bind_stores = ((__kv_bind_store_1, (1, )), (__kv_bind_store_2, (0, )), )
__kv_rule_8.callback = __kv_leaf_callback_8
__kv_rule_8._callback = None
__kv_rule_8.bind_stores = ((__kv_bind_store_3, (0, )), )
del __kv_rule_0, __kv_rule_1, __kv_rule_2, __kv_rule_3, __kv_rule_4, __kv_rule_5, __kv_rule_6, __kv_rule_7, __kv_rule_8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment