Kivy automatically adjusting buttons and labels to fit screen - python

Hello I need help making my buttons and labels to stay fixed whenever I'm changing the display resolution. I have a video link of what I mean by that.
link: https://youtu.be/GJ3f88ebDqc?t=29s
If anyone could make me a example of code or explain and show me that would be great. Thanks!

Read kivy documentation about size_hint and pos_hint in the layouts you are using, and read the documentation about layouts in general.
https://kivy.org/docs/gettingstarted/layouts.html
https://kivy.org/docs/api-kivy.uix.layout.html
if you are still blocked, post a short code showing what you have in a simple way, and explain what's not behaving how you expect it to.

Related

Kivy sometimes does not show widgets and images

Does anyone know why kivy sometimes does not show new widgets on the screen. I have the identical code for several screens in an app writtin in .kv-language. It works fine in all screen but one screen wont show my the widgets and images.
I had the same problem a view times now, sometimes it works after a while but it is starting to get annoying since I can not continue coding before my widgets decide to show up.
it often helps to just change the name of the screen and all its mentions. I still do not get what is going on, so if somebody has an answer please tell me.

Is it possible to set activeforeground/activebackground using customtkinter?

I am able to use activeforeground and activebackground to change color in background/text when button is clicked in tkinter.
Is it possible to do the same thing in customtkinter as well? I have checked the website if similar context is available, however, could not see any.
Thanks in advance.
From both the documentation and the GitHub webpage, I could not see any changes that would suggest this is possible.
You cannot have it on the button event function, so that the moment the button is clicked, the background and foreground is changed and then it is changed back to the normal. This is beacuse the the switch will be too fast and it does not work if you add sleep().
The closest work around that you can have is probably just to have it on the hover event as I belive the Hover event may be interfering with the changing of the colour in runtime straight away. If this is a deal breaker you may want to use PySide2/6 instead as they do have this exact custimastion readily availabe.
Also for anyone else interested in Custom Tkinter, make sure to use the GitHub page to see any progress or fucntions as it is mantained, the best documentation is from the Wiki found at:
https://github.com/TomSchimansky/CustomTkinter/wiki

How can I implement a typewrite mode in a Tkinter GUI?

Im on Python 3.9 on Windows 10, and im building a text editor app. Id like to have a typewriter mode where the current text stays centred on the screen and finished/written text scrolls up the screen.
I have tried googling every variation of what that could be called or how to implement it. Ive also looked through 3 or 4 different tutorials and all the docs on every parameter of every method in Tkinters widgets. Im not asking for a complete code snippet necessarily, but im stumped as to how im going to do this.
Thanks for any help received, itd be much appreciated, even a nudge in the right direction.
Chris

Kivy Look and Feel

I am trying to build a Kivy application with a sharp, crisp look and feel but the default Kivy UI is not exactly what I had in mind? Is there any way to create a custom theme to give your Kivy app style?
This app here is called Pithon and it was made from Kivy. I have searched everywhere but I can not find anything on how the developer managed such a clean look. Does anyone have any ideas?
A kivy developer called Andrés Rodríguez released a set of widgets based on google's material design principles. I am currently using them myself and they have surely saved me from alot of work. You can find KivyMD here (see bottom of this answer for more info). Their are some themes also based on the same principles but am yet to try them out one is FlatKivy and another is kivy material ui by Federico Curzel.
Some screenshots for kivyMD,flatkivy and kivy material ui respectively are here.
Click the highlighted links you will find a lot more info about the three projects.
The original KivyMD project by Andrés Rodríguez is no longer maintained but there is active fork of KivyMD by HeaTTheatR.
(Almost) all widgets have properties that can be used to set aspects of their style. For instance, with a Button you can change the background colour, the background image when pressed or released, and the size of the border region (it's scaled like in CSS border images). You can check the documentation for the specifics of a given widget.
An theme like in the screenshot you posted could be achieved by turning off background images for the buttons and just using solid colours, with the non-button text being normal Labels and the circle being drawn directly with a kivy canvas instruction or via an Image widget (along with an image of the circle).
I notice you mentioned padding in a comment but I'm not sure what you mean by it - do you mean the distance between the buttons? They may well be placed in a GridLayout which has a padding property controlling this, so you could set it to whatever you like.
I recognise that you're asking a more general question than 'how does this screenshot do it?', but the key point is that just about everything is customisable and it doesn't take many changes to go from the default theme to your image.
Edit: One useful feature that helps this kind of customisation is that you can use kv language to override styles for widget classes very easily, so you don't need to manually change every button etc.

Python Tkinter get image of whats behind a window

Well i am creating a utility for my own needs, that being to help improve my reading on the computer. What i need to do is create a tool which can add a colour filter to a section of the screen, as well as add zoom. The first thing was easy to do, i set the attributes to add alpha, topmost and gave a frame a set bg colour.
What i dont know how to do is the zoom. I was thinking of getting a screen capture cut the selected bit apply image transformation then render it in the window. Of course the utility window will also be drawn and obscure the screen capture. I dont know tkinter well enough and i really want to avoid doing GDI work, but if someone has a solution with it i dont mind using it. Clearly referencing GDI, im making it to run on windows.
Optional: Something i have a work around for but would be nice to have is the ability to click through a window, but i doubt i can do that with tkinter.
EDIT: Since im getting negative votes, and i don't know why please help me improve with a comment.
I'm not looking for someone to do the work for me i just want a hint on what might be the right way to do this. With the main problem being how to get a image for whats underneath the Tkinter window so i can process it.

Categories