Fps bar on Kivy apps not disabling on mac os - python

I used Config.set('modules', 'monitor', '') on one of my Kivy apps to get the fps bar, but I can't get it disabled now.
Kivy version -- 1.10.1
I've tried everything and checked every line of code but can't get it disabled. Also if I write a basic code with just
from kivy.app import App
from kivy.uix.button import Button
imports I still getting the fps bar. I even reinstalled the whole Kivy environment but still I have the fps bar.
These are all the imports that I used in my file which created all the problem.
import kivy
kivy.require("1.10.1")
# from kivy.config import Config
# Config.set('graphics', 'resizable', 0)
# Config.set('graphics', 'width', 500)
# Config.set('graphics', 'height', 300)
# Config.set('modules', 'monitor', '')
from kivy.metrics import *
from kivy.core.window import Window
Window.size = (sp(500), sp(300))
from kivy.app import App
from kivy.uix.label import Label
from kivy.graphics import Line, InstructionGroup, Color
from kivy.properties import ObjectProperty, Property
from kivy.core.audio import SoundLoader
from kivy.clock import Clock
from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition
from kivy.lang import Builder
import random as rnd
import time
This is the basic code.
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
Output Image

From eyllanesc's comment I've found a fix to this problem in case anyone else gets into the same problem.
Note: Always create a backup of the file.
Go to this directory.
Windows: C:\Users\tito\.kivy\config.ini
macOS: /Users/tito/.kivy/config.ini
Linux: /home/tito/.kivy/config.ini
Open config.ini
Find
[modules]
monitor =
Delete monitor = and Save it.
If anything happens just delete the config.ini and Kivy will create a new one but all your configurations will reset.

Related

close webview in kivy

iam trying to close or destroy the webview and show other layout
here is my code for webview or if that won't possible i want to get the link of the current page and if current page link is equal to some link i want to exit the webview pls help me out this
from android.runnable import run_on_ui_thread as run_thread
from jnius import autoclass
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.app import runTouchApp
from kivy.clock import Clock, mainthread
#mainthread
def quit_screen():
app = App.get_running_app()
e=GridLayout()
d1=button(text="hi end")
e.add_widget(e)
app.root.switch_screen(e)
#run_thread
def key_back_handler():
webview.loadUrl("about:blank")
webview.clearHistory()
webview.clearCache(True)
webview.clearFormData()
webview.freeMemory()
Clock.schedule_once(quit_screen, 0)
#run_thread
def WebView(link,*args):
WebV = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.kivy.android.PythonActivity').mActivity
webview = WebV(activity)
settings = webview.getSettings()
settings.setJavaScriptEnabled(True)
settings.setUseWideViewPort(True)
settings.setLoadWithOverviewMode(True)
settings.setSupportZoom(True)
settings.setBuiltInZoomControls(True)
wvc = WebViewClient()
webview.setWebViewClient(wvc)
activity.setContentView(webview)
webview.loadUrl(link)
m=GridLayout(cols=1,rows=1)
d=GridLayout(cols=1,rows=1)
m.add_widget(d)
def Push(butoon):
WebView("https://www.google.com")
b=Button(text="hi")
b.bind(on_press=Push)
d.add_widget(b)
runTouchApp(m).run()
like this but its not closing on back pressed on android
Thanks for help in advance
The trick is to put the Webview in a Kivy ModalView and catch the back button/gesture from Java to exit the ModalView , for example:
https://github.com/RobertFlatt/Android-for-Python/tree/main/webview

filechooser in kivy without class

hi there i new in kivy iam learning without classes i want filechooser but any one tell me kivy filechooserIconView without class and not with kivy file only python file
from kivy.uix.button import Button
from kivy.app import runTouchApp
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.uix.gridlayout import GridLayout
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.uix.scrollview import ScrollView
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.uix.filechooser import FileChooserIconView
a=GridLayout(cols=1)
def a1():
global b
global c
c.text=str(b.path)
b=FileChooserIconView(path='/storage/emulated/0/')
from functools import partial
c=Button(text='ok')
a.add_widget(c)
b.bind(on_release=a1)
a.add_widget(b)
runTouchApp(a)
Your code almost works, just a couple issues. First, you are binding on_release to the FileChooser, but I think you want that bound to the Button. Second, our a1() method must accept an argument (the button). Here is a modified version of your code with those changes:
from kivy.uix.button import Button
from kivy.app import runTouchApp
from kivy.uix.gridlayout import GridLayout
from kivy.uix.filechooser import FileChooserIconView
a=GridLayout(cols=1)
def a1(button): # handle required arg
global b
global c
c.text=str(b.path)
b=FileChooserIconView(path='/home/jra')
c=Button(text='ok')
a.add_widget(c)
c.bind(on_release=a1) # bind to button, not FileChooser
a.add_widget(b)
runTouchApp(a)

Kivy Text Editor Input Not Showing Up

I have unfortuanlly have encourtered an error in kivy and Python 3. I have not found a soultion via Google. I wanted to get text input at the very least but it does not show up. Just the text itself. Thank you for your time!
import kivy
kivy.require('1.10.1') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
class ColdKivyApp(App):
def build(self):
f = FloatLayout()
label = Label(text="Cold") #I acutally orginally called it Zone unitil I changed it into Cold cause it's really cold now
f.add_widget(label)
txt = TextInput(text='', focus=True, multiline=True, cursor_blink=True, background_color=(1,1,1,1))
f.add_widget(txt)
return f
if __name__ == '__main__':
ColdKivyApp().run()
It seems that there is a bug in TextInput when setting the focus in the constructor, a workaround is to set the focus an instant after the window is shown through Clock:
import kivy
kivy.require('1.10.1') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.clock import Clock
class ColdKivyApp(App):
def build(self):
f = FloatLayout()
label = Label(text="Cold")
f.add_widget(label)
txt = TextInput(multiline=True, cursor_blink=True, background_color=(1,1,1,1))
f.add_widget(txt)
Clock.schedule_once(lambda *args: setattr(txt, "focus", True))
return f
if __name__ == '__main__':
ColdKivyApp().run()

How to simplify imports in Kivy

My starting code often looked like this:
import libs.apa_database
import inspect
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.scrollview import ScrollView
from kivy.properties import ObjectProperty, StringProperty, Property
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.clock import Clock
So, I wondered if there were a way to reduce the clutter like this:
from system_assets import APADatabase, App, Clock
from layout_assets import App, BoxLayout, GridLayout, ScrollView
from screen_assets import ScreenManager, Screen, FadeTransition
from interface_assets import DropDow, Button,
The answer is "yes":
Create new Python files as a "folder" to hold your imports
Add the import statements to that Python file
Import the assets from that file
(Will update this Q with more detail when I have time.)

Old Kivy Label doesn't disappear on updating text property

I'm writing a clock application (will eventually run on Raspberry Pi, but developing on Windows), and whenever a label updates the changed characters are drawn on top of the old ones, but the old one doesn't disappear.
It looks like this.
Here's my code:
main.py:
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivy.properties import StringProperty
from kivy.config import Config
import time
class RPiClock(BoxLayout):
timeString = StringProperty()
def __init__(self, **kwargs):
super(RPiClock, self).__init__(**kwargs)
def update(self, *args):
self.timeString = str(time.strftime("%I:%M:%S %p"))
class RPiClockApp(App):
def build(self):
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
appWindow = RPiClock()
Clock.schedule_interval(appWindow.update, 1)
return appWindow
if __name__ == "__main__":
RPiClockApp().run()
RPiClock.kv:
<RPiClock>
Label:
id: TimeLabel
text: root.timeString
font_size: '50sp'
What's causing these graphics to stick around?
I had a similar issue, try adding a colored canvas in the background -- in your case I would likely use a black rectangle that fills up your layout. It may solve your problem (it did for me).

Categories

Resources