У меня возникли некоторые проблемы с kivy еще раз. При каждом запуске следующей программы python мгновенно вылетает, открывающееся окно становится пустым, и у меня нет выбора, кроме как закрыть его. Пытаюсь исправить это в течение часа или около того, но, похоже, ничего не могу сделать.
Кроме того, я не получаю ошибки в трассировке.
Заранее спасибо за помощь
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.app import App
from os import listdir
class CustomDropDown(DropDown):
def __init__(self,**kwargs):
self.layout = FloatLayout()
self.fileList = []
def dropdown(self):
self.musDir = listdir(r'C://Users//danburnier//Desktop//PythonPrograms','r')
for file in self.musDir:
if file.endswith('.py'):
btn = Button(text=str(file[:-3]),size_hint_y=None,height=44)
btn.bind(on_release=lambda btn:self.select(btn.text))
self.add_widget(btn)
class DropDownApp(App):
def build(self):
mainButton = Button(text='Touch me.',size_hint=(None,None))
mainButton.bind(on_release=d.open)
d.bind(on_select=lambda instance, x: setattr(mainButton, 'text', x))
return CustomDropDown()
d = CustomDropDown()
if __name__ == '__main__':
DropDownApp().run()
Редактировать:
Я не знаю, может ли это помочь, но, запустив его на Thonny (на Raspberry Pi 4), я получаю следующую трассировку:
[INFO] [Logger ] Record log in /home/pi/.kivy/logs/kivy_20-03-
03_19.txt
[INFO] [Kivy ] v2.0.0rc1, git-Unknown, 20200303
[INFO] [Kivy ] Installed at "/home/pi/.local/lib/python3.7/site-
packages/kivy/__init__.py"
[INFO] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO] [Python ] Interpreter at "/usr/bin/python3"
[INFO] [Factory ] 184 symbols loaded
[INFO] [ImageLoaderFFPy] Using ffpyplayer 4.3.1
[INFO] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil,
img_ffpyplayer (img_gif ignored)
[INFO] [Window ] Provider: sdl2
[INFO] [GL ] Using the "OpenGL" graphics system
[INFO] [GL ] Backend used <sdl2>
[INFO] [GL ] OpenGL version <b'2.1 Mesa 19.2.0-rc1'>
[INFO] [GL ] OpenGL vendor <b'Broadcom'>
[INFO] [GL ] OpenGL renderer <b'V3D 4.2'>
[INFO] [GL ] OpenGL parsed version: 2, 1
[INFO] [GL ] Shading version <b'1.20'>
[INFO] [GL ] Texture max size <4096>
[INFO] [GL ] Texture max units <16>
[INFO] [Window ] auto add sdl2 input provider
[INFO] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO] [Text ] Provider: sdl2
Backend terminated or disconnected.Fatal Python error: Segmentation fault
Current thread 0xb6fccad0 (most recent call first):
File "/home/pi/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1309 in add_widget
File "/home/pi/.local/lib/python3.7/site-packages/kivy/app.py", line 927 in _run_prepare
File "/home/pi/.local/lib/python3.7/site-packages/kivy/app.py", line 949 in run
File "/home/pi/Desktop/Music21/ProgFin/ScrollMenu22.py", line 34 in <module>
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1211 in _execute_prepared_user_code
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1139 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1152 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1198 in execute_source
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 840 in _execute_source
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 826 in _execute_file
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 387 in _cmd_Run
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 195 in handle_command
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 137 in mainloop
File "/usr/lib/python3/dist-packages/thonny/backend_launcher.py", line 76 in <module> Use 'Stop/Restart' to restart ...