Add Buttons To ActionBar App On KIVY. Python
This a code I copied from the KIVY example directory that comes with the software, I' am trying to modify it, and add other widgets. .KV File #:kivy 1.0 :
Solution 1:
Your problem is that you don't understand how it works.
The .kv file is only loaded if you create a subclass of kivy.app.App and let its name end with "App". Then a .kv file that has the same name without the "App" gets loaded. You can simply avoid your confusion with moving everything in Builder.load_string to your .kv file and create a subclass of App.
Now you can put your ActionBar and your new Button in a horizontal BoxLayout like this:
ActionBarTest.kv:
BoxLayout:
orientation: "horizontal"
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
...
Button:
#new Button
text: "Hello World"
main.py
import kivy
from kivy.app import App
class ActionBarTestApp(App):
def build(self):
#self.root is already defined, because
#you set a root object in .kv file
return self.root
app = ActionBarTestApp()
app.run()
Post a Comment for "Add Buttons To ActionBar App On KIVY. Python"