How to clear screen after leaving? Kivy - python

Title might be misleading, but I am creating a login system with kivy, and I was wondering how to clear what is typed in the TextInput boxes once the user leaves the screen. I found one way, with the built in on_pre_enter function with kivy, but noticed even though it's empty, when the user returns and clicks the box everything comes back up. A way to fix this?
<LoginScreen>:
name: 'login'
on_pre_enter:
userid.canvas.clear()
userpw.canvas.clear()

Related

How can I swipeable Kivy Button that can also have single, long or double press functionality?

I want to make Kivy mobile app that has similar swipeable Buttons (or other purpose filling widgets). In adition to that I want to have seccond type of input from same Button. For instance Gmail mobile app uses this feature:
I have this code:
main.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class ItemList(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.orientation = "vertical"
self.item_list = []
for i in range(10):
self.item_list.append(Button(text=str(i),
on_release=lambda x, this_item=i: print(this_item)))
self.add_widget(self.item_list[-1])
class MainApp(App):
pass
MainApp().run()
main.kv
ItemList:
I want the program to be able to understand witch button on the list is pressed and is the press "type" a swipe or single/double/long press (any one of three will do) and excecute corresponding method.
I was looking for pre built package for this, but I maybe using the wrong keywords, since I cannot find any to suit this type of Buttons/widgets on a list aproach.
The following explanations or suggestions are based on the fact that you are new (as it seems) to Kivy.
As I understood until now, in kivy you perhaps can not expect something as ready-to-use component. But this, rather than being a downside, actually is a very effective way to let the developer choose, implement their own. There are numerous ways to program a CustomWidget, say a Button. You can change the appearance, touch feedback, texture etc. to name a few.
I want the program to be able to understand witch button on the list is pressed and is the press "type" a swipe or single/double/long press (any one of three will do) and excecute corresponding method.
To get a touch behaviour (behavior) of your own, aside from the default mixin ButtonBehavior, you can implement the required logic with three touch events on_touch_down, on_touch_move and on_touch_up. To enable a long press/ hold behaviour one way can be scheduling an action in on_touch_down event with a time threshold beyond which the action will be fired via the same event. Again to get a swipe behaviour you can implement the logic within on_touch_move event and in others' as necessary. You can also restrict the touch event to propagate further by checking collide_point, collide_widget etc.
You can track/identify any Button with its ids or by passing some argument(s) through it.
I was looking for pre built package for this, but I maybe using ...
Yes, there are some. KivyMD is one of these projects developed based on Kivy that approximates the Google's Material Design.

Kivy popup contents

I am trying to use kivy as the graphical system and yet i dont know how to put inside a button and a label at the same time where label shows text and button closes popup also there is one import ant thing here it must be a function that can have editable title and contents and buttob(text) and can be launched like: self.popup(text1, text1, text3) Does anyone know how do it?
Kivy popup contents: What do you want ? Nobody can answer this !!! Give a precise question (here are some propositions for your next SO post).
I am trying to use kivy as the graphical system: How to use kivy app as a graphical system ?
and yet i dont know how to put inside a button and a label at the same time where label shows text and button closes popup
Kivy: how to add a widget (Label/Button) to an app ?
Kivy: how to change Label text ?
Kivy: how to bind a function on a button click ?
Kivy: How to close a popup ?
also there is one import ant thing here: .
it must be a function that can have editable title and contents and buttob(text):
I think you should check out what theses terms are: POO, Inheritance, attribute, method.

How to Switch from a login screen (without the navigationdrawer layout) to a screen with a navigationdrawer layout python/kivy/kivymd

I am relatively new to app development and I am attempting to create a login screen that, if successfully logged into, takes you to a "dashboard" screen that has the layout of NavigationDrawer.
I attempted to leverage what I found on Git hub here: https://github.com/kivymd/KivyMD/wiki/Components-Navigation-Drawer
I was thinking it would be as "easy" as taking what is at that URL and creating a screen with the NavigationDrawer disabled, but have been pretty unsuccessful in find a solution.
Any ideas or help would be very appreciated.
You can create a button at the end of your login screen like let's go or continue or whatever. Then you can bind an on-press action to that which change the screen to your home screen. To change screen you have to do so using a screen_manager. Make sure all of your screens are inside it. Then to change to a particular screen just use screen_manager.current = screen_id.

Kivy module switch widget pressed anywhere

I have a kivy file with several widgets, one of them is a switch.
The problem is that wherever I press on the screen, it flips the switch.
I have 2 other widgets - one of them is a check-box and another is radio-buttons, which also have some problems and I think they are occuring because of the switch.
The problem is that in order to press them I need to press on a different part of the screen and not on the widget itself.
Any help would be appreciated.
UPDATE
I am using Windows only for development.
You probably have a switch that is larger than you expect. From the documentation of the switch: "The entire widget is active, not just the part with graphics. As long as you swipe over the widget’s bounding box, it will work." I would try changing the background of the switch to see how big it really is.

Looking for algorithm to help determine shortest path from one terminal screen to another

I am using a terminal client to interact with a mainframe computer. The entire interface is based on the concept of screens. An example workflow might look like:
Login Screen: enter login credentials, press enter
Menu Screen: enter the number of the menu item you want (lets say "6" for memos), press enter
Memo Screen: enter account number, press enter
Add Memo Screen: enter memo details, etc, press enter to save, F3 to go back
I have written a python application to automate the processing of records through this terminal interface. One of the difficulties I am having is that there are a lot of different screens and my application right now is pretty dumb about how to get from one screen to another. It can go from the login screen, to adding memos. But, if it finds itself on the memo screen and needs to de-activate an account, it has to logout and login again because it only knows how to get to the deactivation screen from the login screen, not from the add memos screen.
So, I would like to create a "map" in my application that links each screen to the screens that are "next" to it. Then, I need an algorithm that could tell how to get from any screen A to any screen B in the shortest manner possible.
I already have some screen objects setup and have "related" them to the screens next to them. So, I am looking for some kind of algorithm that I can implement or python library that I can use that will do the work of calculating the route from one screen to another.
Edit: I realize that I am looking for some kind of shortest-path graph algorithm. What is currently throwing me is that I don't really have a "distance", I just have nodes. So, I really don't want shortest-distance, I want least-nodes.
If you have created a topology of the screens, the A* algorithm should work fine.
Since I am using an unweighted graph, it looks like the simplest approach is going to be Breadth-first search:
http://en.wikipedia.org/wiki/Breadth-first_search
Edit: I found a library which does everything I need:
http://networkx.lanl.gov/reference/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html

Categories

Resources