【发布时间】:2018-03-23 15:36:42
【问题描述】:
我想在 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()
我想运行这个 Splash Screen 应用程序 5 秒钟,然后启动主应用程序,即 TestApp 类定义的 FileBrowser。
我该怎么做?
【问题讨论】:
标签: python python-3.x user-interface kivy splash-screen