我想用python制作一个基于GUI的应用程序。我使用来自Kivy
的FileBrowser
作为主应用程序。在
我想显示一个启动屏幕大约5秒钟,然后我想启动主应用程序,即FileBrowser
我提供了我在下面使用的文件浏览器和启动屏幕的代码。在
# FileBrowser
class TestApp(App):
def build(self):
user_path = os.path.join(browser_base.get_home_directory(), 'Documents')
browser = browser_base.FileBrowser(select_string='Select',
favorites=[(user_path, 'Documents')])
browser.bind(on_success=self._fbrowser_success,
on_canceled=self._fbrowser_canceled,
on_submit=self._fbrowser_submit)
return browser
def _fbrowser_canceled(self, instance):
print('cancelled, Close self.')
self.root_window.hide()
sys.exit(0)
def _fbrowser_success(self, instance): # select pressed
global file
print(instance.selection)
file = instance.selection[0]
def _fbrowser_submit(self, instance): # clicked on the file
global file
print(instance.selection)
file = instance.selection[0]
TestApp().run()
# Splash Screen..!!
class timer():
def work1(self):
print('Hello')
class arge(App):
def build(self):
wing = Image(source='grey.png', pos=(800, 800))
animation = Animation(x=0, y=0, d=2, t='out_bounce')
animation.start(wing)
Clock.schedule_once(timer.work1, 5)
return wing
arge().run()
我想运行这个启动屏幕应用程序5秒钟,然后启动主应用程序,即由TestApp
类定义的FileBrowser。在
我怎么能做到呢。?在
您正在为每个屏幕创建单独的应用程序。相反,你只需要屏幕管理器。下面是一个简单的示例,让您了解ScreenManager的工作原理:
相关问题 更多 >
编程相关推荐