Reputation: 111
When i run this code, screen is all black and does show the progress bar. I have no idea why. Can someone help me or explain why nothing is showing on the screen. Thanks in advance !
progressbar.py file
import kivy
from kivy.app import App
kivy.require('1.9.0')
from kivy.uix.label import Label
from kivy.uix.progressbar import ProgressBar
from kivy.uix.boxlayout import BoxLayout
class ProgBar(BoxLayout):
pass
class mainApp(App):
def build(self):
return ProgBar()
if __name__ == '__main__':
mainApp().run()
progressbar.kv file
<ProgBar>:
orientation: 'vertical'
canvas:
Color:
rgb: .45, .28, .5
Rectangle:
pos: self.pos
size: self.size
Label:
text: '[size = 40px]Progress Bar 1 (at .25)'
color: .5, 0, .5, 1
markup: True
ProgressBar:
value: .25
min: 0
max: 1
pos_hint: {'x':.1}
size_hint_x: .8
Label:
text: '[size = 40px]Progress Bar 2 (at .55)'
color: .5, 0, .5, 1
markup: True
ProgressBar:
value: .55
min: 0
max: 1
pos_hint: {'x':.1}
size_hint_x: .8
Upvotes: 1
Views: 217
Reputation: 243897
In what part of your code do you indicate that the .kv load? Well nowhere do you do it, by default kivy loads the x.kv if the name of the class that inherits from App is xApp that is not met in your case so you must load it explicitly using the Builder through the Builder.load_file()
method :
import kivy
kivy.require("1.9.0")
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang.builder import Builder
Builder.load_file("progressbar.kv")
class ProgBar(BoxLayout):
pass
class mainApp(App):
def build(self):
return ProgBar()
if __name__ == "__main__":
mainApp().run()
Upvotes: 1