如何在Kivy中简化导入

时间:2017-12-09 00:42:05

标签: python kivy

我的起始代码通常如下所示:

import libs.apa_database
import inspect
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.scrollview import ScrollView
from kivy.properties import ObjectProperty, StringProperty, Property
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.clock import Clock

所以,我想知道是否有办法减少这样的混乱:

from system_assets import APADatabase, App, Clock 
from layout_assets import App, BoxLayout, GridLayout, ScrollView
from screen_assets import ScreenManager, Screen, FadeTransition
from interface_assets import DropDow, Button, 

1 个答案:

答案 0 :(得分:0)

答案是"是":

  1. 将新的Python文件创建为"文件夹"保持进口
  2. 将导入语句添加到该Python文件
  3. 从该文件导入资产
  4. (如果我有时间,会更详细地更新此问题。)