Well hi, just signed up for this question.
Ive started working with Kivy this week, so far so good, I guess. Im making some sort of POS software, so far I've done things separately, a folder for each module, dashboard(this one module has other modules, sales, providers, products, clients, reports, etc.), operator, and login. I have a main.py and main.kv on root folder, in main.kv I have a ScreenManager that opens the login form on start and then takes me to either operator or dashboard depending the user. Thing is dashboard has another ScreenManager, so i can switch between the other modules that it has in it, it works on standalone but when i call it on main.py withing main.kv it crashes, it doesn't seem to accept two ScreenManager widgets.
My goal is to:
Apparently i cant post GIF yet.
The dashboard works like the gif when I run the dashboard.py file alone but when invoked in main.py it crashes, to be able to run I've to remove the ScreenManager widget class from dashboard.kv and ofc the container that holds the screen widgets crashes it displays all the other modules at once.
I thought about using the add_widget method and threat the screen widgets like a regular box widget but figured that it would just spam the widget on every click like one on top of the other and i think using the clear_widget to remove the previous widget would be just too hard coded, plus I would loose the transition animation
Question is, how can i achieve mentioned goal?
sorry about the gif, it was a 5 mins blender thing.
also English, not main. :s
Related
Problem
We have a FloatLayout that gets some widgets and loses some (using add_widget and remove_widget) inside a function.The problem is the window gets updated when the function reaches its end. Then Kivy updates the window and user only sees the last results.
How to update the window when we are inside a function so user can see results ???
What i tried
I tried do_layout and _trigger_layout (read that somewhere on SO). None of them did the job (no traceback, no warning, literally no change)
Also read Kivy documentation but nothing was helpful there
Instead of making all your changes while blocking the gui, use Clock.schedule_interval or Clock.schedule_once to let Kivy go back to rendering in between each change.
Edit: Also to be clear, your problem is not that you have failed to update the layout, but that you haven't given Kivy any opportunity to render the changes.
i am getting a problem in my project this is the little bit information regarding that:--
link given below is the link to my project. For running it you should have to download all the files in a same folder.
the main problem is when you run it you will get three icons one of them is binoculars you have to click on it after that a new screen will be opened in that screen you will have two text input widget including 4 small icons
what i want is:-- whenever i will click on rocket icon i should get the text of upper text input widget is there any way to do so .
link to my project :-----
https://github.com/themockingjester/search_in_depth_app/tree/master/venv
I think this might work (haven't tested it):
def go(self):
# here i want to print entry1 objectproperty value
print(self.info_page.entry1.text)
I am trying to open one GUI from a completely different GUI. I am developing on a desktop and the windows have different sizes from each other. I looked at screen manager but I feel as if there is an easier way to do this.
Thanks in advance!
It's possible, but kinda inconvenient. The issue is that kivy supports only one window per app, so you need to work around it somehow. I personally just use multiple *Layouts (which are different GUIs with different functions) in a single window, showing and hiding them as necessary. Obviously this approach has its restrictions, eg it doesn't support multiple monitors, but it's as simple as it gets.
Then there is a question here on SO where people spawn separate kivy apps for every window, thus getting windows that can be dragged and resized relatively. It requires some fiddling with subprocesses and communicating between apps, but this method is more powerful.
ScreenManager, as I understand, doesn't help you: it allows just to define multiple widget trees for the same window and switch between them on the fly. It's a normal use case on touchscreens, but makes pretty little sense on desktop. Which is true for quite a few things in kivy, to be honest. If you don't plan to move to mobiles later, Tkinter or PyQT may be a better choice than kivy.
You can use PageLayout or ScreenManager. They can create multiple screen (NOT WINDOWS) at a time. They can be really helpful! Because kivy doesn't support multiple windows, you can use those.
from kivy.uix.pagelayout import PageLayout
from kivy.uix.screenmanager import Screen, ScreenManager. FadeTransition
I am currently working on a project using Python and tkinter.
The problem is that I don't know what's the proper way to display multiple windows, or screens, I don't know how to call them. Let me explain better.
When the application starts the login screen appears. After that, if I click register, I want to go to the register screen, but I don't want it to be a separate window (I don't want to have 2 windows displayed at the same time), but rather another window with different content ?!
How should I handle properly this situation? Create a second window using Toplevel and hiding the first (can I do that?) or changing the widgets of the first?
Code I've written so far
You can do that- just call window.withdraw() on the Toplevel you need to hide after creating a new Toplevel. Changing the widgets in the first is also an option- if you like, you could always try a Notebook widget and disable manual flipping or just put each "screen" in a frame and grid_ or pack_forget them to remove them from the window.
My kivy app has nearly 100 screens. I am using ScreenManager to load the screens on startup (code below), but this is causing the app to take 30 seconds to load. Is there a more efficient way to handle screens in kivy, so screens only load when they are needed instead of loading all screens at app launch? I've seen kivy's switch_to(), but I'm unsure of how to use this instead of the on_press: root.manager.current = 'login' in a Button widget, for instance, or if switch_to() is even appropriate for this use case. What is the best practice for efficiently loading and switching between screens in a kivy app that has many screens?
class LoginScreen(Screen):
...
class GameApp(App):
sm = ScreenManager()
def build(self):
self.sm.add_widget(LoginScreen(name='login'))
self.sm.add_widget(SignUpScreen(name='signup'))
...
My kivy app has nearly 100 screens. I am using ScreenManager to load the screens on startup (code below), but this is causing the app to take 30 seconds to load. Is there a more efficient way to handle screens in kivy, so screens only load when they are needed instead of loading all screens at app launch?
Yes, code the screen caching yourself, e.g. with your own method that does whatever you want (e.g. unloading screens if too many are present, creating the new screen if it doesn't exist yet, showing the new screen by setting .current etc.)
I've seen kivy's switch_to()
switch_to() just takes a new screen, removes the old one entirely, and shows the new one (unlike just setting .current, which doesn't remove the old one entirely). You might find it convenient, but it doesn't directly solve your problem.