How to show an image when app is loading

267 views
Skip to first unread message

Electronic Part

unread,
Feb 17, 2020, 2:40:14 AM2/17/20
to Kivy users support
Hello,

I want show an image when my app is loading(As you know , loading .kv file takes some time. in my case 8 seconds). Basically, that is going to be my loading image. i need to show the image first. a perfect example of what i need is PyCharm or MATLAB or other similar software. Thanks for your help in advance

Elliot Garbus

unread,
Feb 17, 2020, 7:49:28 AM2/17/20
to kivy-...@googlegroups.com

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.

  • Load a simple kv string that uses ModalView to display the image, under a screenmanager.
  • After the ModalView is displayed (on_open), load all of the other kv files.  Builder.load_file()
  • Dismiss the modal view after the loading  is complete
  • Add a widget to the screenmanger from your newly loaded kv content and switch to it.

 

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.

 

Andreas Ecker

unread,
Feb 17, 2020, 10:33:45 AM2/17/20
to kivy-...@googlegroups.com
p4a and buildozer are providing a pre-splash screen that can be easily used at least for your android apps simply by specifying an image.


Elliot Garbus

unread,
Feb 17, 2020, 11:11:20 AM2/17/20
to kivy-...@googlegroups.com
The op is running Windows. 

Sent from my iPhone

On Feb 17, 2020, at 8:36 AM, Andreas Ecker <aec...@gmail.com> wrote:



Electronic Part

unread,
Feb 18, 2020, 6:02:58 AM2/18/20
to kivy-...@googlegroups.com
Thanks but i still don't know what to do

Anoop Rana

unread,
Feb 18, 2020, 6:13:27 AM2/18/20
to kivy-...@googlegroups.com
There must be a splashscreen option inside your .spec file.Set splashscreen=image.jpg inside the .spec file.Where image.jpg or image.png is the image you want to display while the app is opening.I have created an app using kivy and it is on play store now !


Electronic Part

unread,
Feb 19, 2020, 1:27:43 AM2/19/20
to kivy-...@googlegroups.com
I found this in bulldozer.spec 
# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png 

what else i need to do?uncomment this line and add my pic and then run something like this?
python -m PyInstaller bulldozer .spec



Elliot Garbus

unread,
Feb 19, 2020, 7:55:17 PM2/19/20
to Kivy users support
Are you trying to do this for Windows or Android?

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.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.

--
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.

--
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.

--
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.

--
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.

Electronic Part

unread,
Feb 20, 2020, 1:09:34 AM2/20/20
to kivy-...@googlegroups.com
Windows 

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.

Anoop Rana

unread,
Feb 20, 2020, 7:00:36 AM2/20/20
to kivy-...@googlegroups.com
You need to uncomment that preplash.filename and set it equal to your image.png.
For example
preplash.filename=C:\\Mydirectory\\myimage.png.

If you're on windows

Electronic Part

unread,
Feb 20, 2020, 7:40:38 AM2/20/20
to kivy-...@googlegroups.com
Do I need to do anything else in order to apply the change into my project. I mean any command in terminal after changing this,line of spec file?

Anoop Rana

unread,
Feb 20, 2020, 8:06:22 AM2/20/20
to kivy-...@googlegroups.com
After doing this in the .spec file and saving it.Next you need to build your project using the following line in the terminal:

buildozer android debug

Elliot Garbus

unread,
Feb 20, 2020, 8:24:54 AM2/20/20
to kivy-...@googlegroups.com

Anoop,

‘Electronic Part’ is on Windows and targeting Windows (not Android) can he use Bulldozer to create a .exe?

Anoop Rana

unread,
Feb 20, 2020, 9:01:53 AM2/20/20
to kivy-...@googlegroups.com
I am using Linux and was  creating project(APK) for Android.
I don't know for windows exe.

Elliot Garbus

unread,
Feb 22, 2020, 7:35:22 PM2/22/20
to Kivy users support
I have been reflecting on how to best solve this problem.  I've realized my earlier suggestion was more complicated than it needed to be.
This is not exactly the same as a typical splash screen - but it provides the same effect.

The basic concept is that you arrange your application such that all the kv code outside of the root widget is arranged as screens.  All of these screens (and sub-screens) can be located in separate .kv files.
Lets make the Root Widget a layout with a screenmanager.

The first screen is an image and a progress bar.  No other screens are defined at this time.

after the first Window on_draw event, this is when the window is up and has been drawn, load each of the .kv fiiles, using Builder.load_file()
As each file loads, advance the progress bar, providing some feedback to the user that the app is loading.
After all of kv files have loaded, add the remaining screenwidgets to the screenmanager, then transition to your main screen.

Your initial kv code, and the only kv code in the initial build is something like:

 <SplashScreen@Screen>:
    BoxLayout:
orientation: 'vertical'
Label:
text: 'Splash Test'
ProgressBar:

BoxLayout:
ScreenManager:
id: main_sm
SplashScreen:
name: 'splash_screen'

I may try to prototype something like this.  I suspect this will work quite well.  Let me know if that makes sense.

Electronic Part

unread,
Feb 23, 2020, 12:31:04 AM2/23/20
to kivy-...@googlegroups.com
I understand it somehow. just don't know how to implement it. Can give me a simple example please? I really appreciate your help

--
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.

Elliot Garbus

unread,
Feb 23, 2020, 9:42:35 AM2/23/20
to Kivy users support
I have attached a set of files as a running example.  These kv files are too simple to show the value on my machine, but I have done a few experiments with programs that have more complex layouts and i'm confident this approach works.

The app has an initial screen and a screen manager. 
<SplashScreen@Screen>:
BoxLayout:
orientation: 'vertical'
Label:
text: 'Splash Test'
ProgressBar:
            id: p_bar


BoxLayout:
ScreenManager:
id: main_sm
SplashScreen:
name: 'splash_screen'

When build runs this is all of the kv code that runs.  You should edit SplashScreen to give it the look you like, perhaps an image and a progress bar.  This simple kv file will load quickly.

The initial Window is drawn after the on_draw event.  This is used to start loading the kv files.  load_file_init() and load_files() loads the kv files.  Clock.schedule_once is used between the file loads to allow the progress bar to update.  Set the time to 0 in your code, I have it set to .1 so you can see it change.  If the kv files were more complex, it would take more time.

After the kv files are loaded, create_screens() is called.  This adds the screen widgets to the existing screen manager and switches to screen00.

screen_stubs is a file I used to provide the screen names to the Python code.  You would import your python code related to each of the screens.
splash.py is the main file
splash_test_00.kv ... splash_test_00.kv are simple kv files I created for this test.  You will of course use your own kv files.

I don't know the structure or performance of you app.  This approach works if loading complex kv files are the performance bottleneck that is causing a delayed screen draw.
You could see if this is your problem by eliminating (comment it out) a complex screen and seeing if your app loads faster. 

Good luck,  Happy to answer any questions on this approach.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
screen_stubs.py
splash.py
splashtest_00.kv
splashtest_01.kv
splashtest_02.kv
splashtest_03.kv
splashtest_04.kv

Anoop Rana

unread,
Feb 23, 2020, 10:20:40 AM2/23/20
to kivy-...@googlegroups.com
What if we have multiple classes and corresponding to each class there is kv code(not a file)in a single program.How will we know when the splashscreen should end/exit or that the app has started?I mean how to do what you did for different kV files if we have the program as shown below.
For example:
<Mainwindow>:
        name: 'main'
        BoxLayout:
                  .....

<SecondWindow>:
         name: 'second'
         FloatLayout:
                   .....

class MainWindow(Screen):
      pass
class SecondWindow (Screen):
      pass

class MyApp(MDApp):
    def build(self):
           return WindowManager()

if __name__'main':
      MyApp().run()

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.

Elliot Garbus

unread,
Feb 23, 2020, 10:47:55 AM2/23/20
to kivy-...@googlegroups.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

Electronic Part

unread,
Feb 24, 2020, 3:10:57 AM2/24/20
to kivy-...@googlegroups.com
Can i have two kv file , one for loading page and one for main kv file

Anoop Rana

unread,
Feb 24, 2020, 3:19:34 AM2/24/20
to kivy-...@googlegroups.com
Yes you can have one file for loading and one for tjhe main app

Electronic Part

unread,
Feb 24, 2020, 4:49:26 AM2/24/20
to kivy-...@googlegroups.com
I have only one kv file and a screen for loading. How can i do something similar ?

Electronic Part

unread,
Feb 24, 2020, 4:50:22 AM2/24/20
to kivy-...@googlegroups.com
By the way, i do have a screen manger and several screens such as loading page

Elliot Garbus

unread,
Feb 24, 2020, 7:41:35 AM2/24/20
to kivy-...@googlegroups.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!

Electronic Part

unread,
Feb 27, 2020, 1:48:48 AM2/27/20
to kivy-...@googlegroups.com
I made an example which have two screens, one for loading and one more. Can you show me how put them in separate kv files and load loading page till another screen loading has been done.Thanks 

test.py
test.kv

Elliot Garbus

unread,
Feb 27, 2020, 6:13:08 PM2/27/20
to Kivy users support
It the attached files I have taken the same approach as in my example, but used your files.
Here is a brief summary of the changes:
I cut the LoginWindow screen from test.kv, and put it into a new fiile, login_window.kv
I added an id to your screenmanager, 'wm', short for window manager
I used Builder.load_file() to load the kv files.  I saw you were opening the kv file, and then reading them into a string, I assume to use the utf-8 encoder.  You can do the same thing here if required.  Do it where every you see the Builder.load_file()

Notes on how this works:
In build()
  • Window on_draw event is bound to a method in App, on_draw_event.  The on_draw event happens after the window is drawn.  We use this to kick off loading the other kv files. 
  • The initial kv file is load here.  The file contains only the first screen in the app. 
on_draw_event()
  • Called after the window is drawn.  Now your LoadingScreen is visible to the user.
  • This calls load_files_init().  The variable self.loaded is used to ensure the kv files are only loaded once.  This on_draw event call will occur many times (on screen moves, resize...).  We only want to load the kv files once.
load_files_init()
  • initializes the list of kv files you want to load, set the list self.kv_filenames = [ 'file1.kv', 'file2.kv'...]  in this case there is only on kv file.  When you have all the screens in separate kv files, you would list then all here. 
  • Sets the max of the progress bar to the number of files to load.
  • Uses Clock.schedule_once() to schedule executing load_files()
load_files()
  • load_files loads one kv file off the list, then calls itself to load the next kv file from the list.
  • Clock.schedule_once() is used between each file load to allow the progress bar to update.
  • after all of the kv files are loaded it calls create_screens()
create_screens()
  • instances the screen, adds the screen to the ScreenManager, and then switchs to the screen.  When you have multiple screens, you would create them all here.
  • switches to the desired screen, in this case your login screen.
At this point the entire app is loaded.



--
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.

--
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.

--
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.

--
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.

--
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.

--
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.
login_window.kv
test.kv
test.py

Electronic Part

unread,
Feb 29, 2020, 3:23:07 AM2/29/20
to kivy-...@googlegroups.com
Thanks. I got following error
 Traceback (most recent call last):
   File "kivy\properties.pyx", line 860, in kivy.properties.ObservableDict.__getattr__
 KeyError: 'wm'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\core\window\window_sdl2.py", line 257, in _event_filter
     EventLoop.idle()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\base.py", line 355, in idle
     window.dispatch('on_draw')
   File "kivy\_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
   File "D:/code/final_designe3/persian_fona_design.py", line 2552, in on_draw_event
     self.load_files_init()
   File "D:/code/final_designe3/persian_fona_design.py", line 2573, in load_files_init
     self.root.ids.wm.get_screen('progressbar').ids.progressBar1.max = len(self.kv_filenames)
   File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'
 Exception ignored in: 'kivy.core.window._window_sdl2._WindowSDL2Storage.cb_event_filter'
 Traceback (most recent call last):
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\core\window\window_sdl2.py", line 257, in _event_filter
     EventLoop.idle()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\base.py", line 355, in idle
     window.dispatch('on_draw')
   File "kivy\_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
   File "D:/code/final_designe3/persian_fona_design.py", line 2552, in on_draw_event
     self.load_files_init()
   File "D:/code/final_designe3/persian_fona_design.py", line 2573, in load_files_init
     self.root.ids.wm.get_screen('progressbar').ids.progressBar1.max = len(self.kv_filenames)
   File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'
[INFO   ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "kivy\properties.pyx", line 860, in kivy.properties.ObservableDict.__getattr__
 KeyError: 'wm'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "D:/code/final_designe3/persian_fona_design.py", line 2606, in <module>
     my_app.run()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\app.py", line 855, in run
     runTouchApp()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\base.py", line 504, in runTouchApp
     EventLoop.window.mainloop()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\core\window\window_sdl2.py", line 747, in mainloop
     self._mainloop()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\core\window\window_sdl2.py", line 479, in _mainloop
     EventLoop.idle()
   File "D:\ProgramData\Anaconda3\envs\conda_evnv\lib\site-packages\kivy\base.py", line 355, in idle
     window.dispatch('on_draw')
   File "kivy\_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
   File "D:/code/final_designe3/persian_fona_design.py", line 2552, in on_draw_event
     self.load_files_init()
   File "D:/code/final_designe3/persian_fona_design.py", line 2573, in load_files_init
     self.root.ids.wm.get_screen('progressbar').ids.progressBar1.max = len(self.kv_filenames)
   File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'


My code:
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.

Electronic Part

unread,
Feb 29, 2020, 3:52:39 AM2/29/20
to kivy-...@googlegroups.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'

Electronic Part

unread,
Feb 29, 2020, 7:53:23 AM2/29/20
to kivy-...@googlegroups.com
Got this solved. Now  i have another issue

Elliot Garbus

unread,
Feb 29, 2020, 7:57:42 AM2/29/20
to kivy-...@googlegroups.com

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:

Electronic Part

unread,
Feb 29, 2020, 8:18:21 AM2/29/20
to kivy-...@googlegroups.com
I did the same. I need to the picture be  borderless  by this command Window.borderless = True 
And then back to original setting (have boarder).my login username and password does not work and  all the stuffs i have done for login to the app. Too much work left. How can delete the boarder in this situation Thanks for your support.

Elliot Garbus

unread,
Feb 29, 2020, 8:31:04 AM2/29/20
to kivy-...@googlegroups.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.

Elliot Garbus

unread,
Feb 29, 2020, 8:36:56 AM2/29/20
to kivy-...@googlegroups.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. 

Electronic Part

unread,
Mar 1, 2020, 1:19:45 AM3/1/20
to kivy-...@googlegroups.com
So i have two question regarding this part of project.
1. How change screen size. I want the loading screen be borderless and not fullsize and then all other screens be with border and fullsize
2. How to change screen when i am on .kv side?

Electronic Part

unread,
Mar 1, 2020, 1:51:31 AM3/1/20
to kivy-...@googlegroups.com
I found the answer for the second question. Please only help me with the first one

Electronic Part

unread,
Mar 1, 2020, 7:38:02 AM3/1/20
to kivy-...@googlegroups.com
All problems have been solved except  one that is resizing problem. I am working on that. Thanks

Elliot Garbus

unread,
Mar 1, 2020, 9:53:48 AM3/1/20
to kivy-...@googlegroups.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?

Electronic Part

unread,
Mar 2, 2020, 2:50:47 AM3/2/20
to kivy-...@googlegroups.com
Hello, 

I would like to appreciate your contribution.
1. Run time significantly has been reduced (Almost half of the original code run time)
2. Loading bar works great

Regards

Electronic Part

unread,
Mar 2, 2020, 3:05:56 AM3/2/20
to kivy-...@googlegroups.com
Just there is something i wander if you can help me with. I changed the size from loading screen to other screens and my app shows resizing for a short period of time. Is there anyway that i can skip this resizing issue? 

Anoop Rana

unread,
Mar 2, 2020, 11:46:31 AM3/2/20
to kivy-...@googlegroups.com
What if the class inside the screen_stubs.py have thousands of lines inside it? .First the app shows the opening screen(till .kv files are loaded) but then it shows blank screen again (till all classes(from screen_stubs.py)are loaded.How can I show the opening screen for as long as the whole process (loading .kv files +class from screen_stubs.py) completes?

Elliot Garbus

unread,
Mar 2, 2020, 12:48:00 PM3/2/20
to kivy-...@googlegroups.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'
 

Elliot Garbus

unread,
Mar 2, 2020, 1:00:26 PM3/2/20
to kivy-...@googlegroups.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.

Electronic Part

unread,
Mar 3, 2020, 12:17:21 AM3/3/20
to kivy-...@googlegroups.com
Your code solve my problem. Thanks

Electronic Part

unread,
Mar 3, 2020, 12:30:29 AM3/3/20
to kivy-...@googlegroups.com
One more thing. How can i not allow my user to change the screen size?

Elliot Garbus

unread,
Mar 3, 2020, 3:56:22 AM3/3/20
to kivy-...@googlegroups.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.

Electronic Part

unread,
Mar 3, 2020, 7:51:01 AM3/3/20
to kivy-...@googlegroups.com
I found this although it did not work for me

from kivy.config import Config 
kivy.config.Config.set('graphics','resizable', False) 

I don't know how to implement your suggestion  

Elliot Garbus

unread,
Mar 3, 2020, 8:38:00 AM3/3/20
to kivy-...@googlegroups.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.

Reply all
Reply to author
Forward
0 new messages