I am developing a GUI with Python/ Kivy, which consists out of several Screens that contain a variety of Kivy widgets (TextInput, Spinner, DropDown, CheckBox, Label,...). I am using Buttons and the ScreenManager to switch between different screens. The problem I am facing is that after switching screens, the input data is still saved in the widgets. My aim is that after the data has been entered and submitted to a database, the input will then be deleted from the kivy widgets.
What options does kivy offer, to reset the input data for an entire screen after a specific event (Button, ScreenChange, etc.)? The only thing I came up with, was defining a function reset_screen for every single screen, which will delete the entire input data of a screen. Is it possible to somehow save the default status of a screen and then call it again after an event?
Thanks!
Related
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
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 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.
I have a tkinter GUI that, when opened, is an empty widget with a menu bar on top. Clicking on the options on the menu causes for text boxes, more buttons and more menus to appear in the widget. My problem is that everything overlaps.
I need an easy way to delete everything that is currently there, like a "clear window" option.
I've tried packing everything into a frame and then destroying a frame but, for some reason, it's not working.
Any suggestions?
Ideally, I would make something that checks to see if there is anything (button, text box, menu) in a designated space, and it would delete it all before creating the new widget attributes.
The Problem I was having was fixed by creating a new frame within each function and having the code destroy any previously existing frames with Frame.destroy().
My second problem, where widgets within my frame were not, appearing was being caused by how Tkinter frames automatically resize to fit the original widgets. Therefore, when I added widgets to the frame, the frame remained the size of the first widget and didn't show the new buttons. I used frame.pack_propagate(0) to force the frame to remain the specified size.
I have a frame which I use as the main form (mainFrame), it inherits from mainFrameBase, which inherits from wxFrame.
It has a "close" system button. When it is pressed the app shuts down. All very much to my liking.
I inherit another frame from mainFrameBase (progScreen). When a button is pressed, the progScreen is shown. When I click its system close button, the form does not close.
What I want to achieve with this setup is that you can click a button on the main frame and a slightly different view of the main frame is shown to allow the user to "progam" certain buttons.
By the way, I'm using WXFormBuilder (excellent program) to create the screens.
What I would do is create two panels with the controls you want, one for the regular screen and one for the programming screen. Then when you want to switch, you hide one panel and show the other. That way, both screens are contained in one frame that when closed, exits the program. I actually have a tutorial that is similar to this here:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
Hope that helps!