how to remove the time and the navigation bar of the phone visible on my application? - kivy

I want to see my kivy application compiled with Buildozer on an android phone without seeing the navigation bar and the phone time .
I try:
from kivy.config import Config
Config.set('graphics', 'borderless', '1')
Config.set('graphics', 'fullscreen', 'True')
from kivy.core.window import Window
Window.show()

Related

Screen not appearing in python turtle

This is my code
import turtle
scr = turtle.Screen()
When I run it the screen appears and then disappears, what am I doing wrong?
Add scr.mainloop() at the end of your code.

Kivy-- Image as Button

I am just beginner in kivy and object oriented programming.
I have been practicing this code as a combination of the tutorials here:
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
Builder.load_string("""
<ImageButton>:
FloatLayout:
Image:
source:'resizedA.png'
size_hint: .2, .2
""")
class ImageButton(ButtonBehavior,FloatLayout, Image):
def on_press(self):
print ('pressed')
class The_AssignmentApp(App):
def build(self):
return ImageButton()
if __name__ == "__main__":
The_AssignmentApp().run()
My question is, why is that even if I press the other parts of the screen(not the image), the app still considers the whole scree as a button?
Pardon my ignorance here, I would really want to learn. Thanks!
class ImageButton(ButtonBehavior,FloatLayout, Image):
Don't inherit from multiple widgets (in this case FloatLayout and Image), this will lead to some weird bugs.
As for your specific problem, the ButtonBehavior is a parent class of the ImageButton which is the root widget and fills the screen. For this reason, the whole screen is a button, though you clearly intended otherwise.
Is the following more like what you wanted? You can also just use a FloatLayout instead of creating the new RootWidget class, I just did this to fit with what you already wrote.
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
class RootWidget(FloatLayout):
pass
class ImageButton(ButtonBehavior, Image):
def on_press(self):
print ('pressed')
Builder.load_string("""
<RootWidget>:
ImageButton:
source:'resizedA.png'
size_hint: .2, .2
""")
class The_AssignmentApp(App):
def build(self):
return RootWidget()
if __name__ == "__main__":
The_AssignmentApp().run()

How to print button text value on console in Kivy

My app just have one button and its text is a random number from 1 to 9. I want to print the button text on console on on_press. Actually, i have minimized my problem, i want to compare the value with a variable, if button.text=5, do something else do_something_else.
My attempt:
#!/usr/bin/kivy
import kivy
kivy.require('1.7.2')
from random import random
from random import choice
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.properties import StringProperty
Builder.load_string("""
<Highest>:
GridLayout:
cols: 1
Button:
text: root.r1c2
on_press: root.new()
""")
class Highest(Screen):
r1c2 = StringProperty(str(int(random()*10)))
def new(self):
print self.text
# Create the screen manager
sm = ScreenManager()
sm.add_widget(Highest(name='Highest'))
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
But this gives error.
You don't say what error you're getting, but one obvious problem is self.text doesn't exit. You are calling it on Highest(Screen), not the Button. To access kv objects from python you would normally tag them with ids and then use root_widget.ids.id_of_widget(see docs). An alternative is to use Kivy Properties.
Since you already have a Kivy Property bound to the text of the button, you can just print that out:
print self.r1c1

How to call a function as soon as widget is launched in Kivy

My app just have one button. I want to call a function as soon as widget is created/called. I have used init for the same.
My attempt:
#!/usr/bin/kivy
import kivy
kivy.require('1.7.2')
from random import random
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from random import random
from random import choice
from kivy.properties import StringProperty
import time
Builder.load_string("""
<Highest>:
GridLayout:
cols: 1
Button:
id: btn_0
text: "0"
on_press: root.new()
""")
class Highest(Screen):
def __init__(self,name):
print "widget launched"
def new(self):
print "button pressed"
# Create the screen manager
sm = ScreenManager()
sm.add_widget(Highest(name='Highest'))
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
On running, "widget launched" is displayed in consolde, but my application crashes with statement "python have stopped working". Please help.
If you really want to detect instantiation, create your own Button subclass that calls the function in its __init__ method.
If that's not directly what you really want, there may be better alternatives.

blackberry java wait screen (ActivityIndicatorView)

how to add a activity screen to a button click event ?
ActivityIndicatorView view = new ActivityIndicatorView(Field.FIELD_HCENTER);
Bitmap spinImage = Bitmap.getBitmapResource("spinner.png");
view.createActivityImageField(spinImage,6,0);
LabelField label = new LabelField("Loading Hockey...");
s.add(label);
s.add(view);
pushScreen(s);
by this code, it will shows error. ie no import package
how to solve this ?
Are you importing all the right packages? i.e.
import net.rim.device.api.ui.component.progressindicator.*;
import net.rim.device.api.ui.*;
and so on....

Resources