2017-12-15 7 views
1

Nach einem fehlgeschlagenen Versuch mit 'pyforms' habe ich beschlossen, meine Hand mit 'kivy' zu versuchen.Erste Schritte mit Kivy

Sie es einfach über pip install kivy installiert

Versuch this example code zu laufen, aber ich bekomme diese Fehlermeldung. Ich habe keine Ahnung, wo ich damit anfangen soll, da ich nicht wirklich verstehe, was es zu sagen versucht. Ich bin auf Windows 10, 32-Bit-Python3.4.4 ausgeführt. Kann jemand anderen den Fehler verstehen?

[INFO ] [Logger  ] Record log in U:\.kivy\logs\kivy_17-12-15_1.txt 
[INFO ] [Kivy  ] v1.10.0 
[INFO ] [Python  ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] 
[INFO ] [Factory  ] 194 symbols loaded 
[INFO ] [Image  ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored) 
[INFO ] [Text  ] Provider: pil(['text_sdl2'] ignored) 
[CRITICAL] [Window  ] Unable to find any valuable Window provider. 
sdl2 - ImportError: DLL load failed: The specified module could not be found. 
    File "C:\Python34\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib 
    fromlist=[modulename], level=0) 
    File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module> 
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage 

[CRITICAL] [App   ] Unable to get a Window, abort. 
Exception ignored in: 'kivy.properties.dpi2px' 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\kivy\utils.py", line 496, in __get__ 
    retval = self.func(inst) 
    File "C:\Python34\lib\site-packages\kivy\metrics.py", line 174, in dpi 
    EventLoop.ensure_window() 
    File "C:\Python34\lib\site-packages\kivy\base.py", line 127, in ensure_window 
    sys.exit(1) 
SystemExit: 1 
[CRITICAL] [App   ] Unable to get a Window, abort. 

Beispielcode:

from kivy.app import App 
from kivy.uix.label import Label 
from kivy.clock import Clock 
from kivy.graphics import Color, Rectangle 


class TestApp(App): 

    @staticmethod 
    def get_x(label, ref_x): 
     """ Return the x value of the ref/anchor relative to the canvas """ 
     return label.center_x - label.texture_size[0] * 0.5 + ref_x 

    @staticmethod 
    def get_y(label, ref_y): 
     """ Return the y value of the ref/anchor relative to the canvas """ 
     # Note the inversion of direction, as y values start at the top of 
     # the texture and increase downwards 
     return label.center_y + label.texture_size[1] * 0.5 - ref_y 

    def show_marks(self, label): 

     # Indicate the position of the anchors with a red top marker 
     for name, anc in label.anchors.items(): 
      with label.canvas: 
       Color(1, 0, 0) 
       Rectangle(pos=(self.get_x(label, anc[0]), 
           self.get_y(label, anc[1])), 
          size=(3, 3)) 

     # Draw a green surround around the refs. Note the sizes y inversion 
     for name, boxes in label.refs.items(): 
      for box in boxes: 
       with label.canvas: 
        Color(0, 1, 0, 0.25) 
        Rectangle(pos=(self.get_x(label, box[0]), 
            self.get_y(label, box[1])), 
           size=(box[2] - box[0], 
            box[1] - box[3])) 

    def build(self): 
     label = Label(
      text='[anchor=a]a\nChars [anchor=b]b\n[ref=myref]ref[/ref]', 
      markup=True) 
     Clock.schedule_once(lambda dt: self.show_marks(label), 1) 
     return label 

TestApp().run() 
+0

Der allererste Fehler, nach den "informativen" Nachrichten, besagt, dass "keinen wertvollen Windows-Anbieter finden kann". Was schlägt dies ein Duplikat von https://StackOverflow.com/Q/44219563/2564301 – usr2564301

Antwort

0

Bitte folgen installation guide auf Kivy Ort. Sie sollten auch Abhängigkeiten installieren:

+0

Ich habe dies getan und ich bekomme immer noch die Nachrichten – WhatsThePoint

+0

@WhatsThePoint Sind Sie sicher, die Installation aller Dinge erfolgreich abgeschlossen? Zeigt 'python -m pip freeze' dir kivy und alle Abhängigkeiten einschließlich' kivy.deps.sdl2'? Können Sie versuchen, kivys nächtliches Rad [von hier] zu installieren (https://kivy.org/docs/installation/installation-windows.html#nightly-wheel-installation) und prüfen, ob der Fehler immer noch vorhanden ist? –

+0

Ich habe diese Kivy == 1.10.0 Kivy-Garden == 0.1.4 kivy.deps.angle == 0.1.6 kivy.deps.glew == 0.1.9 kivy.deps.gstreamer == 0,1 .12 kivy.deps.sdl2 == 0.1.17 – WhatsThePoint