The effect your looking for is called a splash screen.
Very interesting question. (Than means, I don’t know!)
Here is how I would approach creating a splash screen.
The trick is jumping to the newly loaded kv code.
The app Kivy Catalog (\kivy-examples\demo\kivycatalog\main.py) dynamically reevaluates kv code, to support interactive editing. I suggest looking there for clues.
I don’t think you will require something that sophisticated, but there are some interesting ideas there.
In the main.py you will find this section of code:
def change_kv(self, *largs):
'''Called when the update button is clicked. Needs to update the
interface for the currently active kv widget, if there is one based
on the kv file the user entered. If there is an error in their kv
syntax, show a nice popup.'''
txt = self.language_box.text
kv_container = self.screen_manager.current_screen.children[0]
try:
parser = Parser(content=txt)
kv_container.clear_widgets()
widget = Factory.get(parser.root.name)()
Builder._apply_rule(widget, parser.root, parser.root)
kv_container.add_widget(widget)
except (SyntaxError, ParserException) as e:
self.show_error(e)
except Exception as e:
self.show_error(e)
--
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/8c0cdf93-a501-4809-bf44-6d7287b3925d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e4a8bd0.1c69fb81.ffad8.36deSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
On Feb 17, 2020, at 8:36 AM, Andreas Ecker <aec...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAN5U2U-24d13VWBqkTF2oON0ySgyUgP2JvXtAD81cnj8BFP%2Bkw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CC545F1E-7903-4858-B7BB-BE55AC2C2F1F%40cox.net.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQgYV3XxQOq17SvKfce_USCmAAS%3Dvf%2B7Nmb8V01zLEDmw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EoGpG4dvcZW5mrOnWYPbgk7z23MN78q-wPFme39dy7hbQ%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/8c0cdf93-a501-4809-bf44-6d7287b3925d%40googlegroups.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e4a8bd0.1c69fb81.ffad8.36deSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAN5U2U-24d13VWBqkTF2oON0ySgyUgP2JvXtAD81cnj8BFP%2Bkw%40mail.gmail.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CC545F1E-7903-4858-B7BB-BE55AC2C2F1F%40cox.net.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQgYV3XxQOq17SvKfce_USCmAAS%3Dvf%2B7Nmb8V01zLEDmw%40mail.gmail.com.
--
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-...@googlegroups.com.
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/16c6e2e8-c0fb-4735-80ad-cd681f0a3c6e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQm8KFiUGXnPA1X1FbMALDfTYoBbTLWZsK9tKbGAT7ZgA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EpormzTu9NQLscn9DORxKod7Bme8yrfX-q0HX0XVGuh_A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQP5btLc8FT8VvfHWsySt49WyvXwK1VheNM1oKQdJGxBA%40mail.gmail.com.
Anoop,
‘Electronic Part’ is on Windows and targeting Windows (not Android) can he use Bulldozer to create a .exe?
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EqKYEPd5y5NDO1T%2B2FAS%3D%2BQzQ_FRRE6RfWxa-VsPyYGRg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e4e889c.1c69fb81.f5c02.6a6eSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
BoxLayout:
orientation: 'vertical'
Label:
text: 'Splash Test'
ProgressBar:
BoxLayout:
ScreenManager:
id: main_sm
SplashScreen:
name: 'splash_screen'
--
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/e2d2521d-6929-45dd-a9b1-c79e6ad439e5%40googlegroups.com.
<SplashScreen@Screen>:
BoxLayout:
orientation: 'vertical'
Label:
text: 'Splash Test'
ProgressBar:
id: p_bar
BoxLayout:
ScreenManager:
id: main_sm
SplashScreen:
name: 'splash_screen'
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
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/2c711495-e8ac-4089-92d8-2cbe45819d3b%40googlegroups.com.
If each of your files contains the both the kv code, and the python code, you could try deferring the import of the file into your main file.
Experiment and see. This assumes you are dong the load string in the same file with the python code, and would normally import the code in the top of your main.py file.
In the code where I am loading files using Builder.load_file() you would put an import statement.
It may be simpler to restructure your program to have the kv files separate.
From: Anoop Rana
Sent: Sunday, February 23, 2020 8:20 AM
To: kivy-...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EqPaQcgCPATtjRMNDdwN-yBxsUxGM_gnm7kc88uWs6eYw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e529ea1.1c69fb81.27015.1092SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shTy7VYiBL3%2Bnz4zyXGRQuDCHsJnvxM2sA%3DeckY_sgxJWQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EoMn3OERm8m_iOEF2hmh29ZXYvVOt4%3DOYgO%2B4gyseAgOA%40mail.gmail.com.
There are a number of ways you could split your existing single kv file into multiple kv files.
Here is a suggestion.
Create a new screen for the loading page, SplashScreen. Initially, just make this a label that says ‘application loading’. We just want to test that things are working as expected. Put this new screen in your existing screenmanager, and make it the first screen under the screen manager.
At this point do not bother with a progress bar.
Remove all of the other screens from below the screen manager. (at this point just comment them out)
Cut all of the definitions of the other screens from the kv file, and paste them to a new file, let’s call it screen_defs.kv
After the on_draw event, use Builder.load_file(‘screen_defs.kv’) to load the screen definitions.
Then instance the screens, and add them to the screenmanager, as I did in the example.
If this works, you can decide how you want the splash screen to look and work. If you want a progress bar, you could further split screen_defs.kv into separate files with a new file for each screen, and update the progress bar after each screen load.
I look forward to hearing how it works out!
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shSyLOOqfPONwt02V-LVBSTHEU4YB57Hc5pR0XC3biZ5vA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e53c476.1c69fb81.3a8c2.9fbaSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/2c711495-e8ac-4089-92d8-2cbe45819d3b%40googlegroups.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EqPaQcgCPATtjRMNDdwN-yBxsUxGM_gnm7kc88uWs6eYw%40mail.gmail.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e529ea1.1c69fb81.27015.1092SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shTy7VYiBL3%2Bnz4zyXGRQuDCHsJnvxM2sA%3DeckY_sgxJWQ%40mail.gmail.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71EoMn3OERm8m_iOEF2hmh29ZXYvVOt4%3DOYgO%2B4gyseAgOA%40mail.gmail.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shSyLOOqfPONwt02V-LVBSTHEU4YB57Hc5pR0XC3biZ5vA%40mail.gmail.com.
--
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-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e53c476.1c69fb81.3a8c2.9fbaSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
try:
with open(dirpath+"\\persian_fona.kv", encoding='utf-8') as f: # Note the name of the .kv
kv = Builder.load_string(f.read())
except:
with open(current_folder_path+"\\persian_fona.kv", encoding='utf-8') as f: # Note the name of the .kv
kv = Builder.load_string(f.read())
class MyMainApp(App):
small_font = NumericProperty(12)
medium_font = NumericProperty(20)
large_font = NumericProperty(28)
data_items = ListProperty([])
ft = FileTest()
title = 'VEV'
def __init__(self, **kwargs):
self.loaded = False
self.kv_filenames = [] # used to store the kv_files names
self.kv_file_index = 0 # used to keep track of the files loaded
super(MyMainApp, self).__init__(**kwargs)
@staticmethod
def restart():
print(f'exec: {sys.executable} {["python"] + sys.argv}')
os.execvp(sys.executable, ['python'] + sys.argv)
def _image_loaded(self, proxyImage):
if proxyImage.image.texture:
self.image.texture = proxyImage.image.texture
def build(self):
#change icon
self.icon = 'arm_vista_Program_logo.png'
proxyImage = Loader.image("pathlib.PureWindowsPath(os.getcwd())).as_posix()+'/images.jpg")
proxyImage.bind(on_load=self._image_loaded)
Loader.num_workers = 2
Window.bind(on_draw=self.on_draw_event)
return kv
def on_start(self):
self.fullsize = Window.size
def on_draw_event(self, *args): # After window is drawn, then load other kv files
if not self.loaded: # only load the file once
self.load_files_init()
self.loaded = True
def load_files(self, dt):
# load one file at a time, and then a one frame schedule to update the progress bar
# after all the files are loaded, create the screens
# this method calls itself
if self.kv_file_index < len(self.kv_filenames):
Builder.load_file(self.kv_filenames[self.kv_file_index])
self.kv_file_index += 1
self.root.ids.wm.get_screen('progressbar').ids.progressBar1.value += 1
Clock.schedule_once(self.load_files, 0)
else:
self.create_screens()
def load_files_init(self):
# This is sets up loading the kv files
self.kv_filenames = ['PersianLoginWindow.kv','LoginWindow.kv','create_pannel_table.kv',\
'ArabicLoginWindow.kv','PreferencesWindow.kv','GeneralPrefrenceWindow.kv',\
'AccountPrefrenceWindow.kv','AppearancePrefrenceWindow.kv','DevicePrefrenceWindow.kv',\
'PatientListWindow.kv','CaptureImageWindow.kv'] # The list of kv files to load
self.root.ids.wm.get_screen('progressbar').ids.progressBar1.max = len(self.kv_filenames)
Clock.schedule_once(self.load_files, 0)
def create_screens(self):
s = PersianLoginWindow(name= "PersianLogin")
self.root.ids.wm.add_widget(s)
s=LoginWindow()
self.root.ids.wm.add_widget(s)
s=create_pannel_table()
self.root.ids.vm.add_widget(s)
s = ArabicLoginWindow()
self.root.ids.vm.add_widget(s)
s = PreferencesWindow()
self.root.ids.vm.add_widget(s)
s = GeneralPrefrenceWindow()
self.root.ids.vm.add_widget(s)
s = AccountPrefrenceWindow()
self.root.ids.vm.add_widget(s)
s = AppearancePrefrenceWindow()
self.root.ids.vm.add_widget(s)
s = DevicePrefrenceWindow()
self.root.ids.vm.add_widget(s)
s = PatientListWindow()
self.root.ids.vm.add_widget(s)
s = CaptureImageWindow()
self.root.ids.vm.add_widget(s)
self.root.ids.wm.current = 'PersianLogin'
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/38e105c2-880d-4bc0-9315-a9a8604adbee%40googlegroups.com.
def create_screens(self):
s = PersianLoginWindow(name= "PersianLogin")
self.root.ids.wm.add_widget(s)
s=LoginWindow()
self.root.ids.wm.add_widget(s)
s=create_pannel_table()
self.root.ids.wm.add_widget(s)
s = ArabicLoginWindow()
self.root.ids.wm.add_widget(s)
s = PreferencesWindow()
self.root.ids.wm.add_widget(s)
s = GeneralPrefrenceWindow()
self.root.ids.wm.add_widget(s)
s = AccountPrefrenceWindow()
self.root.ids.wm.add_widget(s)
s = AppearancePrefrenceWindow()
self.root.ids.wm.add_widget(s)
s = DevicePrefrenceWindow()
self.root.ids.wm.add_widget(s)
s = PatientListWindow()
self.root.ids.wm.add_widget(s)
s = CaptureImageWindow()
self.root.ids.wm.add_widget(s)
self.root.ids.wm.current = 'PersianLogin'
Share your persian_fona.kv file.
I suspect one of two issues
BoxLayout: #1 Put the WindowManager in a BoxLayout
WindowManager:
id: wm #2 give the WIndowManger the id wm
transition: FadeTransition()
LoadingScreen:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shTQfZwWv8y78E%2Bgv7jdth9ekufL9H48J2%2BC5nr%2B1r8Rew%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e5a5fbe.1c69fb81.790e2.8800SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To make the ‘splash screen’ borderless. In on_start() add:
Window.borderless = True
And at the end of create_screens()
Window.borderless = False
You mention you have things that are not working. For each screen that is defined in create_screens, the associated python code for that screen needs to be imported into you main file or in your main file.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQ4r4uY8or1mcNUzs8wNG7v%3DHz81J%3DXTBh_MfMVDTB9SA%40mail.gmail.com.
This is not critical, but thought you would like to know:
In a few spots I see:
pathlib.PureWindowsPath(os.getcwd())).as_posix()+'/images.jpg"
You can get the same result with:
str(pathlib.Path().cwd() / 'images.jpg')
This is much fewer characters, and more portable. The ‘/’ operator is overloaded by Path to join paths.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQ4r4uY8or1mcNUzs8wNG7v%3DHz81J%3DXTBh_MfMVDTB9SA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e5a68ed.1c69fb81.2200b.1768SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
Glad to hear your making progress.
How did the deferred loading of the screens impact the app start time?
Is the progress bar working out okay?
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shQyT_zpMKe91Me7HQ6z23rCVb0c027kmxv0aEnxR8LrHA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e5bcc71.1c69fb81.a0e79.b2bfSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shR-R9vUuOKUvQqen4-dHS6rRt%3D40AqdWfPmiU2h3RGj_A%40mail.gmail.com.
I did a quick experiment that creates a smooth transition for me.
I created a new method, called screen_change(). I set the Window.borderless to false, and schedule screen_change to run on the next screen refresh.
In screen_change() I maximize the window, and switch to the new window.
def create_screens(self):
s = Screen00(name='screen_00')
self.root.ids.main_sm.add_widget(s)
s = Screen01(name='screen_01')
self.root.ids.main_sm.add_widget(s)
s = Screen02(name='screen_02')
self.root.ids.main_sm.add_widget(s)
s = Screen03(name='screen_03')
self.root.ids.main_sm.add_widget(s)
s = Screen04(name='screen_04')
self.root.ids.main_sm.add_widget(s)
Window.borderless = False
Clock.schedule_once(self.screen_change, 0)
def screen_change(self, dt):
Window.maximize()
self.root.ids.main_sm.current = 'screen_00'
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shR-R9vUuOKUvQqen4-dHS6rRt%3D40AqdWfPmiU2h3RGj_A%40mail.gmail.com.
Your scenario is a little confusing. If you have imported screen_stubs.py, the import should be complete prior to anything else running. The classes need to be defined prior to the instancing of the screens.
Please share some code.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAHG71Eq3m_%2BQYwUDjgQqC5La1Qa63nJP-8y%3D6X3w9zdjxum5Vg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e5d49b0.1c69fb81.2200b.8dcaSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
You can set the minimum window size
See Window.minimum_height, Window.minimum_width This will be the minimum size the user can make the window.
https://kivy.org/doc/stable/api-kivy.core.window.html?highlight=window#kivy.core.window.WindowBase
If this is not sufficient, you could bind a method to the Window.on_resize event, and set the Window size.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shTbiw69tcHGMYGSJNezTDN3_73iKxPa08SDFeXzBbGYrw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5e5e1bac.1c69fb81.5d017.9e16SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
This will work, it needs to be put at the very top of the main file. Above all other imports.
from kivy.config import Config
Config.set('graphics','resizable', 0)
to set the minimum allowable window size:
from kivy.core.window import Window # This should already be in place
and then after the window is sized:
def screen_change(self, dt):
self.root.ids.main_sm.current = 'screen_00'
Window.maximize()
Window.minimum_height = Window.height # or any value you want for the minimum window size.
Window.minimum_width = Window.width
In this case the window cannot be made smaller, it can be made larger.
Let me know if this is sufficient or if you want to see how to bind to the Window on_resize event.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAGb7shTeN6V1a9V4JMDNcVNussV4HJAOTxNqqUqkUzc0c%3DN-RQ%40mail.gmail.com.