Kivy Button within Button - python

Is there a way to place a button inside of an existing button in Kivy? I am trying to create a library of videos (as buttons that open a popup when pressed) that each have the option to delete the video/widget when an 'x' is pressed in the top corner. I am wondering if there is a way to stack buttons on top of each other or place on button inside of another?

You can use FloatLayout and adjust the pos_hint to place the buttons at your desired location.
You can read about it on the link below.
https://kivy.org/doc/stable/api-kivy.uix.floatlayout.html

Related

Not able to display a treeview window

I'm trying to open a treeview window by clicking a button but it isn't working
[Code](https://i.stack.imgur.com/TorXR.png)
Move next_cmd() function inside buyerprop() function.

Is there a way to place a tkinter button behind tkinter canvas text?

In other words, is it possible to create a button with Tkinter and place Tkinter canvas text on top of it? The normal workaround would be to simply create a label containing the text on top of the button. However, the button where I want to place the text is an image containing a color gradient and you need to specify a background color for the label.
In other words, how can I create an image that I can click on and execute a function (like a button would do) and place text on top of this button without the need of specifying a background color for the text?
Is there a way to place a tkinter button behind tkinter canvas text?
No, there is not. Windows will always be on top of other canvas objects.
From the official documentation:
"Window items are an exception to the above rules. The underlying window systems require them always to be drawn on top of other items. In addition, the stacking order of window items is not affected by any of the canvas widget commands; you must use the Tk raise command and lower command instead."
In other words, how can I create an image that I can click on and execute a function (like a button would do) and place text on top of this button without the need of specifying a background color for the text?
You can create your own button widget by placing the image on a canvas, then writing text on top of the image. You can then add your own bindings that fire when you click on the canvas.

Changing Tkinter Screen when button is clicked?

I am aiming to change the a part of the Tkinter screen when a button is clicked. Do I have to destroy the screen then redraw it (to create the illusion that only a part is being changed?) Or can I keep the button there and somehow only change one part (like the graphics.) Thanks!
No, you do not have to destroy the screen and redraw it. You can easily insert widgets into the current window when a button is clicked. There's nothing special about being run from a button click -- the code is the same as your initialization code.

'hover over' popup with Tkinter

I have implemented an informational popup in a python app using a Tkinter Menu widget. I have a Text widget on a canvas in the root window. I created a Menu widget that has root as its parent. When I detect a mouse hover over the text widget I post the popup menu with menuWidget.post(). When I get a leave event from the text widget my intention was to have the popup disappear by calling menuWidget.unpost(), only the popup menu does not disappear until I click elsewhere outside the text widget.
First, is this a sane method for implementing an informational popup? And can anyone tell me why the popup menu won't disappear?
This is not the right way to do an informational popup. On the Mac and on windows machines menus are native controls. Because of this the unpost command doesn't work because tk cedes control to the system event loop in order to get platform-specific behavior.
What you want is to use instead is a toplevel window with the overrideredirect flag set. This lets you display a borderless window anywhere you want. The upside to this is that you aren't limited to simple text -- you can put anything you want in that toplevel -- another text widget, a canvas, buttons, etc.

Drag button between panels in wxPython

Does anyone know of an example where it is shown how to drag a button from one panel to another in wxPython?
I have created a bitmap button in a panel, and I would like to be able to drag it to a different panel and drop I there.
I haven't found any examples using buttons, just text and files.
I am using the latest version of Python and wxPython.
If you want to graphically represent the drag, one good way to do this is to create a borderless Frame that follows the mouse during a drag. You remove the button from your source Frame, temporarily put it in this "drag Frame", and then, when the user drops, add it to your destination Frame.

Categories