Button:
text: "Street"
size_hint: .5, .0
font_size: 50
on_press: Factory.StreetPop().open()
<StreetPop@Popup>:
class StreetPop(Popup):
def build(self):
layout = BoxLayout()
layout.add_widget(self.img1)
self.capture = cv2.VideoCapture(0)
cv2.namedWindow("CV2 Image")
Clock.schedule_interval(self.update, 1.0/33.0)
return layout
def update(self, dt):
ret, frame = self.capture.read()
cv2.imshow("CV2 Image", frame)
buf1 = cv2.flip(frame, 0)
buf = buf1.tostring()
texture1 = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
self.img1.texture = texture1
cv2.destroyAllWindows()
The build method only belongs to App(). Move the layout code to kv.
<StreetPop>: # remove the dynamic class creation because you are defining it in python.
Move the code you want to run at StreetPop object creation to __init__()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/cdfc3db8-4417-416e-b789-09b0accaac3a%40googlegroups.com.