Reputation: 55
I am getting error
NameError: name 'Factory' is not defined
when I try to import Factory in kv file. But I have already imported in py file.
Below is my code,
Kv file:
<MessagePopup>:
id: popup
auto_dismiss: False
title: "User Verification"
size_hint: None, None
size: 300,300
space_x: self.size[0]/6
space_y: self.size[1]/6
BoxLayout:
orientation: "vertical"
spacing: 20
padding: popup.space_x, popup.space_y
Label:
text: "Click to verify"
Button:
id:popup_phone
text:"Verify"
size_hint_y: 5.5
on_release:
Factory.PhonePopup().open()
<PhonePopup@Popup>:
id: "Phno_popup"
title: "Verify"
size_hint: None, None
size: 300,300
space_x: self.size[0]/6
space_y: self.size[1]/6
BoxLayout:
orientation: "vertical"
spacing: 20
padding: Phno_popup.space_x, Phno_popup.space_y
Label:
text:"Enter"
size_hint_y: 5.5
TextInput:
id: id_phno
size_hint_y: 5.5
multiline: False
Button:
text: "Verify"
size_hint_y: 5.5
on_press: root.id_verify()
Py file:
import mysql.connector
from kivy.app import App
from kivy.config import Config
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.textinput import TextInput
from kivy.factory import Factory
I am beginner in kivy.
Upvotes: 3
Views: 582
Reputation: 5202
You need to import Factory in kv too.
Add the following line to the top of your .kv
file:
#:import Factory kivy.factory.Factory
Upvotes: 3