Running Kivy1.11 (Py3.6 with SDL2) in VSCode - python-3.x

I'm trying to debug my GUI in VSCode(1.39.1) using kivy1.11, python3.6.9 and Win10, but VSCode cannot compile.
I installed the kivy-package according to the official Kivy-page within conda. I tested whether this outside VSCode and started it in a terminal. This works:
(kivy_py36) C:\Users\...\RASPIapp_py3>python main.py
[INFO ] [Logger ] Record log in C:\Users\...\.kivy\logs\kivy_19-10-16_6.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\...\Anaconda3\envs\kivy_py36\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.5.0 - Build 25.20.100.6472'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics 630'>
[INFO ] [GL ] OpenGL parsed version: 4, 5
[INFO ] [GL ] Shading version <b'4.50 - Build 25.20.100.6472'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
But when I try the same environment within VSCode, I get this:
[INFO ] [Logger ] Record log in C:\Users\...\.kivy\logs\kivy_19-10-16_1.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\...\Anaconda3\envs\kivy_py36\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
[CRITICAL] [Text ] Unable to find any valuable Text provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\text\text_sdl2.py", line 13, in <module>
from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,
pil - ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\kivy\core\text\text_pil.py", line 7, in <module>
from PIL import Image, ImageFont, ImageDraw
File "C:\Users\...\Anaconda3\envs\kivy_py36\lib\site-packages\PIL\Image.py", line 95, in <module>
from . import _imaging as core
[CRITICAL] [App ] Unable to get a Text provider, abort.
The standard ".kivy/config.ini" was not changed in both cases.
Some installed packages of py36 are:
cython 0.29.13 py36ha925a31_0
…
kivy 1.11.1 py36hbc14df2_0 conda-forge
kivy-examples 1.11.1 pypi_0 pypi
…
pillow 6.1.0 py36h643dfcc_1 conda-forge
…
python 3.6.9 h5500b2f_0
…sdl2 2.0.10 h6538335_0 conda-forge
sdl2_image 2.0.5 h63225fd_0 conda-forge
sdl2_mixer 2.0.4 h6538335_0 conda-forge
sdl2_ttf 2.0.15 h4636d2b_0 conda-forge
and some of py27:
cython 0.27.3 py27h566c365_0
…
kivy 1.10.1 py27h7bc4a79_2 conda-forge
kivy-deps-glew 0.1.10 pypi_0 pypi
kivy-deps-sdl2 0.1.18 pypi_0 pypi
...
pillow 6.1.0 py27h6202ca7_0 conda-forge
…
python 2.7.13 h1b6d89f_16
...
sdl2 2.0.9 hc56fc5f_2 conda-forge
sdl2_image 2.0.5 h4bcde91_0 conda-forge
sdl2_mixer 2.0.1 hc56fc5f_1 conda-forge
sdl2_ttf 2.0.15 hdbef25a_0 conda-forge
This is the animate.py example from kivy-examples.
import kivy
from kivy.animation import Animation
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def animate(self, instance):
animation = Animation(pos=(100, 100), t='out_bounce')
animation += Animation(pos=(200, 100), t='out_bounce')
animation &= Animation(size=(500, 500))
animation += Animation(size=(100, 50))
animation.start(instance)
def build(self):
button = Button(size_hint=(None, None), text='plop',
on_press=self.animate)
return button
if __name__ == '__main__':
TestApp().run()
So I expected it to work in vscode, but it does only work in a terminal. So my question: How to force VSCode to find and use SDL2?
Funnily, if I try the same thing as above with Kivy and Python2.7(!), it works in VSCode and terminal.

After playing around with VSCode and finding this helpful link, I finally changed:
1) user -> settings.json
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
2) if a workspace with different folders is used (as in my case) -> change ".code-workspace"
"folders": [
{
"name": "RASPIapp_py3",
"path": "C:\\Users\\<YOURPATH>\\RASPIapp_py3",
"python.pythonPath": "C:\\Users\\<YOURUSERNAME>\\Anaconda3\\envs\\<YOURENVNAME>\\python.exe",
"terminal.integrated.shellArgs.windows": [
"/K",
"C:\\Users\\<YOURUSERNAME>\\Anaconda3\\Scripts\\activate.bat",
"C:\\Users\\<YOURUSERNAME>\\Anaconda3"
]
}
No I just wonder why it was able to find kivy in the first place, even though it seems the only problem was that the conda-shell was not probabley activated.

Related

Unable to debug Kivy in PyCharm while run is OK

I have an issue on debugging a Kivy project with PyCahrm.
I'm on Win 10 x64.
Config version 1:
Python: 3.7.9 x64
Kivy: 2.0.0
PyCharm (Community Edition): 2022.1.1
Config version 2:
Python: 3.10.4 x64
Kivy: 2.1.0
PyCharm (Community Edition): 2022.1.1
First, I need to say that with Config version 1 I worked bevor and still have no problems.
What I did:
installed Python 3.10
created new venv
installed Kivy
installed other for my project required packages
added Python Interpreter to the Project in PyCharm
edited Run/Debug configuration to new interpreter in PyCharm
If I just run the project, it works like I expected without any errors, but if I try to debug it, I always get an Exception.
With MS VSCode I'm able to debug the Project, so I assume there is something with my configuration in PyCharm.
This is my console Output while debugging in PyCharm:
[WARNING] [Config ] Older configuration version detected (21 instead of 24)
[WARNING] [Config ] Upgrading configuration in progress.
[DEBUG ] [Config ] Upgrading from 21 to 22
[DEBUG ] [Config ] Upgrading from 22 to 23
[DEBUG ] [Config ] Upgrading from 23 to 24
[INFO ] [Logger ] Record log in C:\Users\x\.kivy\logs\kivy_22-05-30_23.txt
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.4.5
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "C:\Projects\My Project\venv310\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Projects\My Project\venv310\Scripts\python.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[DEBUG ] [Cache ] register <kv.resourcefind> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[DEBUG ] [GL ] available extensions: b'GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_blend_color GL_EXT_abgr GL_EXT_texture3D GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_SGIS_texture_edge_clamp GL_SGIS_generate_mipmap GL_EXT_draw_range_elements GL_SGIS_texture_lod GL_EXT_rescale_normal GL_EXT_packed_pixels GL_EXT_texture_edge_clamp GL_EXT_separate_specular_color GL_ARB_multitexture GL_ARB_map_buffer_alignment GL_ARB_conservative_depth GL_EXT_texture_env_combine GL_EXT_bgra GL_EXT_blend_func_separate GL_EXT_secondary_color GL_EXT_fog_coord GL_EXT_texture_env_add GL_ARB_texture_cube_map GL_ARB_transpose_matrix GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_texture_env_add GL_IBM_texture_mirrored_repeat GL_ARB_texture_mirrored_repeat GL_EXT_multi_draw_arrays GL_SUN_multi_draw_arrays GL_NV_blend_square GL_ARB_texture_compression GL_3DFX_texture_compression_FXT1 GL_EXT_texture_filter_anisotropic GL_ARB_texture_border_clamp GL_ARB_point_parameters GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_EXT_texture_compression_s3tc GL_ARB_shadow GL_ARB_window_pos GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_ARB_vertex_program GL_EXT_texture_rectangle GL_ARB_fragment_program GL_EXT_stencil_two_side GL_ATI_separate_stencil GL_ARB_vertex_buffer_object GL_EXT_texture_lod_bias GL_ARB_occlusion_query GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_non_power_of_two GL_ARB_vertex_shader GL_NV_texgen_reflection GL_ARB_point_sprite GL_ARB_fragment_program_shadow GL_EXT_blend_equation_separate GL_ARB_depth_texture GL_ARB_texture_rectangle GL_ARB_draw_buffers GL_ARB_color_buffer_float GL_ARB_half_float_pixel GL_ARB_texture_float GL_ARB_pixel_buffer_object GL_ARB_texture_barrier GL_EXT_framebuffer_object GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_ARB_occlusion_query2 GL_EXT_draw_buffers2 GL_WIN_swap_hint GL_EXT_texture_sRGB GL_ARB_multisample GL_EXT_packed_float GL_EXT_texture_shared_exponent GL_ARB_texture_rg GL_ARB_texture_compression_rgtc GL_NV_conditional_render GL_ARB_texture_swizzle GL_EXT_texture_swizzle GL_ARB_texture_gather GL_ARB_sync GL_ARB_cl_event GL_ARB_framebuffer_sRGB GL_EXT_packed_depth_stencil GL_ARB_depth_buffer_float GL_EXT_transform_feedback GL_ARB_transform_feedback2 GL_ARB_draw_indirect GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_ARB_framebuffer_object GL_ARB_framebuffer_no_attachments GL_EXT_texture_array GL_EXT_texture_integer GL_ARB_map_buffer_range GL_ARB_texture_buffer_range GL_EXT_texture_snorm GL_ARB_blend_func_extended GL_INTEL_performance_query GL_ARB_copy_buffer GL_ARB_sampler_objects GL_NV_primitive_restart GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_uniform_buffer_object GL_ARB_depth_clamp GL_ARB_vertex_array_bgra GL_ARB_shader_bit_encoding GL_ARB_draw_buffers_blend GL_ARB_geometry_shader4 GL_EXT_geometry_shader4 GL_ARB_texture_query_lod GL_ARB_explicit_attrib_location GL_ARB_draw_elements_base_vertex GL_EXT_shader_integer_mix GL_ARB_instanced_arrays GL_ARB_base_instance GL_ARB_fragment_coord_conventions GL_EXT_gpu_program_parameters GL_ARB_texture_buffer_object_rgb32 GL_ARB_compatibility GL_ARB_texture_rgb10_a2ui GL_ARB_texture_multisample GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_timer_query GL_EXT_timer_query GL_ARB_tessellation_shader GL_ARB_vertex_array_object GL_ARB_provoking_vertex GL_ARB_sample_shading GL_ARB_texture_cube_map_array GL_EXT_gpu_shader4 GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_INTEL_fragment_shader_ordering GL_ARB_fragment_shader_interlock GL_ARB_clip_control GL_ARB_shader_subroutine GL_ARB_transform_feedback3 GL_ARB_get_program_binary GL_ARB_separate_shader_objects GL_ARB_shader_precision GL_ARB_vertex_attrib_64bit GL_ARB_viewport_array GL_ARB_transform_feedback_instanced GL_ARB_compressed_texture_pixel_storage GL_ARB_shader_atomic_counters GL_ARB_shading_language_packing GL_ARB_shader_image_load_store GL_ARB_shading_language_420pack GL_ARB_texture_storage GL_EXT_texture_storage GL_ARB_compute_shader GL_ARB_vertex_attrib_binding GL_ARB_texture_view GL_ARB_fragment_layer_viewport GL_ARB_multi_draw_indirect GL_ARB_program_interface_query GL_ARB_shader_image_size GL_ARB_shader_storage_buffer_object GL_ARB_texture_storage_multisample GL_ARB_buffer_storage GL_AMD_vertex_shader_layer GL_AMD_vertex_shader_viewport_index GL_ARB_query_buffer_object GL_EXT_polygon_offset_clamp GL_ARB_clear_texture GL_ARB_texture_mirror_clamp_to_edge GL_ARB_debug_output GL_ARB_enhanced_layouts GL_KHR_debug GL_ARB_arrays_of_arrays GL_ARB_texture_query_levels GL_ARB_invalidate_subdata GL_ARB_clear_buffer_object GL_INTEL_map_texture GL_ARB_texture_compression_bptc GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_robustness GL_ARB_robust_buffer_access_behavior GL_EXT_texture_sRGB_decode GL_ARB_copy_image GL_KHR_blend_equation_advanced GL_EXT_direct_state_access GL_ARB_stencil_texturing GL_ARB_texture_stencil8 GL_ARB_explicit_uniform_location GL_ARB_multi_bind GL_ARB_indirect_parameters '
[DEBUG ] [GL ] glShaderBinary is not available
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.3.0 - Build 20.19.15.5126'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics 4600'>
[INFO ] [GL ] OpenGL parsed version: 4, 3
[INFO ] [GL ] Shading version <b'4.30 - Build 20.19.15.5126'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load <C:\Projects\My Project\venv310\lib\site-packages\kivy\data\glsl\default.png>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[WARNING] Both Window.minimum_width and Window.minimum_height must be bigger than 0 for the size restriction to take effect.
[INFO ] [Text ] Provider: sdl2
[INFO ] [Clipboard ] Provider: winctypes
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Projects\My Project\src\My_App.py", line 27, in <module>
import doctodb.sql_utils as slq_utils # sqlite3 & Co.
File "C:\Projects\My Project\src\doctodb\sql_utils.py", line 14, in <module>
import my_globals
File "C:\Projects\My Project\src\my_globals.py", line 12, in <module>
from kivy.app import App
File "C:\Projects\My Project\venv310\lib\site-packages\kivy\app.py", line 414, in <module>
from os.path import dirname, join, exists, sep, expanduser, isfile
ImportError: cannot import name 'sep' from 'ntpath' (C:\Python\Python310\lib\ntpath.py)
Exception ignored in: <module 'threading' from 'C:\\Python\\Python310\\lib\\threading.py'>
Traceback (most recent call last):
File "C:\Python\Python310\lib\threading.py", line 1560, in _shutdown
lock.acquire()
KeyboardInterrupt:
Process finished with exit code 1
Any idea what could I try to solve this?

Kivy on Raspberry Pi 4 terminates before showing window

When I run my Kivy application it terminates early. I followed the installation instructions on Kivy's website.
main.py
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
import os
os.environ['KIVY_WINDOW'] = 'sdl2'
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
Builder.load_file('main.kv')
class MyLayout(Widget):
pass
class TheMonitorApp(App):
def build(self):
return MyLayout()
if __name__ == '__main__':
TheMonitorApp().run
main.kv
#:kivy 2.0.0
<MyLayout>
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Label:
text: "Monitor"
font_size: 32
Terminal
(kivy_venv) pi#raspberrypi:~/projects/HomeMonitor $ python main.py
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_21-11-03_19.txt
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "/home/pi/projects/HomeMonitor/kivy_venv/lib/python3.7/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0]
[INFO ] [Python ] Interpreter at "/home/pi/projects/HomeMonitor/kivy_venv/bin/python"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [ImageLoaderFFPy] Using ffpyplayer 4.3.2
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer
(kivy_venv) pi#raspberrypi:~/projects/HomeMonitor $
Notice the terminal output stops at "[INFO ] [Image ]", why does it stop here? It still needs to reach "Window" and "GL".
Also if I delete these lines nothing changes:
import os
os.environ['KIVY_WINDOW'] = 'sdl2'
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
Check:
https://kivy.org/doc/stable/gettingstarted/installation.html#installation-canonical
Install dependencies:
"For the Raspberry Pi, you must additionally install the dependencies listed in source dependencies before installing Kivy above."
Install kivy:
python -m pip install kivy[base] kivy_examples

Kivy error while running : TypeError: run() missing 1 required positional argument: 'self'

I was just watching a tutorial on kivy and for some reason my code won't work as the person teaching
import kivy
from kivy.app import App as App
from kivy.uix.label import Label
class myapp(App) :
def build(self):
return Label(text = "Hello world")
if __name__ == '__main__':
myapp.run()
thats the code and
[INFO ] [Logger ] Record log in C:\Users\Maza\.kivy\logs\kivy_21-10-13_21.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "C:\Users\Maza\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\Maza\AppData\Local\Programs\Python\Python39\python.exe"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
Traceback (most recent call last):
File "c:\Users\xxx\Documents\Projects\Python playground\Kivy\test1.py", line 12, in <module>
myapp.run()
TypeError: run() missing 1 required positional argument: 'self'
that's what it returned. I still dont know how to fix it
You need to change:
myapp.run()
to:
myapp().run()
That is, you must create an instance of myapp (the myapp() with parens), then call the run() method of that instance.

Unable to create a window using kivy 1.11.1 and python 3.7.0

I am trying to create a simple program using kivy. The program runs without errors, however, no window appears. Here are the steps I followed for installing kivy:
python -m pip install --upgrade pip wheel setuptools virtualenv
python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* kivy_deps.glew==0.1.*
python -m pip install kivy_deps.gstreamer==0.1.*
python -m pip install kivy_deps.angle==0.1.*
python -m pip install kivy==1.11.1
python -m pip install kivy_examples==1.11.1
This is the program that I'm trying to run:
import kivy
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
label = Label(text = 'Hello from kivy',size_hint = (.5,.5),pos_hint {'center_x':.5,'center_y':.5})
return label
if __name__ == " main" :
app = MainApp()
app.run() #App class contains run() - sets up the graphics
And this is the output I'm getting:
[INFO ] [Logger ] Record log in C:\Users\Ayesha.kivy\logs\kivy_19-12-22_0.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.1.17
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.1.9
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.1.12
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.1.22
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\Ayesha\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy__init__.py"
[INFO ] [Python ] v3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\Ayesha\AppData\Local\Programs\Python\Python37\pythonw.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2

kivy __init__ takes 1 arg

I have a problem with kivy :( Can you help me to fix it?
import kivy
import socket
import threading
kivy.require('1.9.1') # replace with your current kivy version !
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('localhost',9999))
from kivy.app import App
from kivy.uix.label import Label
duyuru=""
def readData():
data = s.recv(1024)
if data:
duyuru=data
else:
duyuru="Henüz duyuru yok!"
class MyApp(App):
def build(self):
t1 = threading.Thread(target=readData)
t1.start()
return Label(duyuru)
if __name__ == '__main__':
MyApp().run()
It give me an error says:"Type error: __init__ takes 1 positional argument but 2 were given ". And the kivy window opens but stops running :(
Traceback:
[INFO ] [Logger ] Record login
C:\Users\Beatless27\.kivy\logs\kivy_16-05-02_40.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'3.3.0'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce 9500 GT/PCIe/SSE2/3DNOW!'>
[INFO ] [GL ] OpenGL parsed version: 3, 3
[INFO ] [GL ] Shading version <b'3.30 NVIDIA via Cg compiler'>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Traceback (most recent call last):
File "AndroidClient.py", line 29, in <module>
MyApp().run()
File "C:\Python34\lib\site-packages\kivy\app.py", line 802, in run
root = self.build()
File "AndroidClient.py", line 27, in build
return Label(duyuru)
TypeError: __init__() takes 1 positional argument but 2 were given
Use Label(text=duyuru) - it is a keyword argument, not a positional one.

Resources