Skip to content

Instantly share code, notes, and snippets.

@matham
Last active August 5, 2018 18:37
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/2005a18d8c94c9edd5a6890eef4f4d61 to your computer and use it in GitHub Desktop.
Save matham/2005a18d8c94c9edd5a6890eef4f4d61 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 = self << Factory.Label(
pos_hint={'x': .2, 'y': .6}, size_hint=(.6, .2))
opening.text @= 'Opening %s' % self.path
flt = self << Factory.FloatLayout(
pos_hint={'x': .2, 'y': .4}, size_hint=(.6, .2))
pb = flt << Factory.ProgressBar(pos_hint={'x': 0, 'center_y': .5})
pb.max @= self.total
pb.value @= self.index
label = flt << Factory.Label(
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 = self << Factory.AnchorLayout(
pos_hint={'x': .2, 'y': .2}, size_hint=(.6, .2))
btn = anchor << Factory.Button(
text='Cancel', size_hint=(None, None), size=(150, 44))
with KVRule(btn.on_release):
self.cancel()
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(
pos_hint={'x': .2, 'y': .6}, size_hint=(.6, .2))
opening.text @= 'Opening %s' % self.path
flt = Factory.FloatLayout(
pos_hint={'x': .2, 'y': .4}, size_hint=(.6, .2))
pb = Factory.ProgressBar(pos_hint={'x': 0, 'center_y': .5})
pb.max @= self.total
pb.value @= self.index
label = Factory.Label(
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(
pos_hint={'x': .2, 'y': .2}, size_hint=(.6, .2))
btn = Factory.Button(
text='Cancel', size_hint=(None, None),
size=(150, 44))
with KVRule(btn.on_release):
self.cancel()
with self:
with opening:
pass
with flt:
with pb:
pass
with label:
pass
with anchor:
with btn:
pass
class FileChooserProgress(FileChooserProgressBase):
@KV()
def apply_kv(self):
with KVCtx():
with -self:
self.pos_hint = {'x': 0, 'y': 0}
with ~self.canvas:
with ~Factory.Color(rgba=(0, 0, 0, .8)):
pass
with ~Factory.Rectangle() as rect:
rect.pos ^= self.pos
rect.size ^= self.size
with -Factory.Label(
pos_hint={'x': .2, 'y': .6},
size_hint=(.6, .2)) as opening:
opening.text @= 'Opening %s' % self.path
with -Factory.FloatLayout(
pos_hint={'x': .2, 'y': .4}, size_hint=(.6, .2)):
with -Factory.ProgressBar(
pos_hint={'x': 0, 'center_y': .5}) as pb:
pb.max @= self.total
pb.value @= self.index
with -Factory.Label(
pos_hint={'x': 0}, size_hint_y=None,
font_size='13sp', color=(.8, .8, .8, .8)) as label:
label.text @= '%d / %d' % (self.index, self.total)
label.height @= label.texture_size[1]
label.y @= pb.center_y - label.height - 8
with -Factory.AnchorLayout(
pos_hint={'x': .2, 'y': .2}, size_hint=(.6, .2))
with -Factory.Button(
text='Cancel', size_hint=(None, None),
size=(150, 44)) as btn:
pass
with KVRule(btn.on_release):
self.cancel()
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()
class FileChooserProgress(FileChooserProgressBase):
@KV()
def apply_kv(self):
with KVCtx():
with self:
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
with Factory.Label(
parent=self, pos_hint={'x': .2, 'y': .6},
size_hint=(.6, .2)) as opening:
opening.text @= 'Opening %s' % self.path
with Factory.FloatLayout(
parent=self, pos_hint={'x': .2, 'y': .4},
size_hint=(.6, .2)) as flt:
with Factory.ProgressBar(
parent=flt,
pos_hint={'x': 0, 'center_y': .5}) as pb:
pb.max @= self.total
pb.value @= self.index
with Factory.Label(
parent=flt, pos_hint={'x': 0}, size_hint_y=None,
font_size='13sp', color=(.8, .8, .8, .8)) as label:
label.text @= '%d / %d' % (self.index, self.total)
label.height @= label.texture_size[1]
label.y @= pb.center_y - label.height - 8
with Factory.AnchorLayout(
parent=self, pos_hint={'x': .2, 'y': .2},
size_hint=(.6, .2)) as anchor:
btn = Factory.Button(
parent=anchor, text='Cancel', size_hint=(None, None),
size=(150, 44))
with KVRule(btn.on_release):
self.cancel()
@tshirtman
Copy link

tshirtman commented Aug 5, 2018

class FileChooserProgress(FileChooserProgressBase):
    @KV()
    def apply_kv(self):
        with KVCtx():
            with self.add_widget:
                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

                Factory.Label(
                    pos_hint={'x': .2, 'y': .6},
                        size_hint=(.6, .2))
                opening.text @= 'Opening %s' % self.path

                with Factory.FloatLayout(
                    pos_hint={'x': .2, 'y': .4},
                        size_hint=(.6, .2)).add_widget:
                    pb = Factory.ProgressBar(
                            parent=flt,
                            pos_hint={'x': 0, 'center_y': .5})
                    pb.max @= self.total
                    pb.value @= self.index

                    label = Factory.Label(
                        pos_hint={'x': 0}, size_hint_y=None,
                            font_size='13sp', color=(.8, .8, .8, .8)) as label:
                    label.text @= '%d / %d' % (self.index, self.total)
                    label.height @= label.texture_size[1]
                    label.y @= pb.center_y - label.height - 8

                with Factory.AnchorLayout(
                    parent=self, pos_hint={'x': .2, 'y': .2},
                        size_hint=(.6, .2)).add_widget:
                    Factory.Button(
                        text='Cancel', size_hint=(None, None),
                        size=(150, 44))
                    with KVRule(btn.on_release):
self.cancel()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment