I'm designing a simple Kivy-based app that has an image in a Scatter widget and two buttons at a fixed position on the screen.
depthproblem.kv:
FloatLayout:
Scatter:
Image:
source: "img.png"
Button:
text: "Alpha"
pos_hint: {"x":0.00, "y":0}
size_hint: 0.20, 0.15
Button:
text: "Beta"
pos_hint: {"x":0.20, "y":0}
size_hint: 0.20, 0.15
depthproblem.py:
from kivy.app import App
class DepthProblemApp(App):
pass
DepthProblemApp().run()
The program starts with the buttons on top of the image, which is what I intend. This is because the buttons are declared after the scatter.
But when I touch the image, it lifts the image layer above the buttons. I don't understand why this happens, and couldn't find any documentation about how to control this behavior (searched z-index, order, layer, depth, etc.).
How can I specify the buttons to always be painted on top of the scatter/image?
Your problem with the scatter image coming to the front can be fixed by setting auto_bring_to_front to False. It defaults to True which is why you're getting that behavior.
Normally, the z-index (depth order) can be controlled by the order in which the widgets are added. The last one added, is displayed at the top I believe. See index of add_widget.
Related
We have a lot of text and background colors proposed to our user. (around 40 colors)
But all theses colors does not fit in the panel's height and the "more color" button is unreachable.
There is no scrollbar in this panel (this is explicitly forced in the code).
According to the code, this panel should "autoSize" but it seems there is a limit maybe ?
Some settings:
{
skin: 'moono-lisa',
colorButton_colors: [000000,323232,424242,535353,878787,a9a9a9,cbcbcb,eeeeee,ffffff,002a38,00384b,005571,007197,008ebd,32a4ca,66bbd7,99d1e4,cce8f1,252712,4a4e25,6f7637,949d4a,b9c55d,c7d07d,d5dc9d,e3e7be,f1f3de,4c1f03,672c07,9c470f,d76418,ff781f,ff9c5a,ffb787,ffd2b4,fff1e8,331f0d,663e1b,995e28,cc7d36,ff9d44,ffb069,ffcea1,ffe1c6,fff5ec]
colorButton_colorsPerRow: 9,
colorButton_enableAutomatic: true
}
CKEditor version: 4.17.2
Therefore I found all panels heights too narrow and it should be nice if I can globally increase their size.
I have a background image and I need to add bunch of oval buttons or images on in my case the "greenish" buttons on top of the background image, that I can click in each one of them and call a function passing a parameter. Please look on the screen shot and let me know how I can position every one of the buttons on top of the image and access them with a click (onPress). I guess the only way is using flex box but I couldn't figure out the style for it.
Thanks
Just style all the green buttons on relatively to the image's boundaries with position: absolute. Percentage values for positioning should work, if your image scales properly on screen size change.
i have a GridLayout with a Button and an image to display inside the Button. when i run my app the Image in the button sometimes centers and sometimes it don't. why? i believe it should always be centered.
.kv file:
MyLayout:
cols: 2
height: self.minimum_height
pos: root.pos
Button:
size_hint_y: None
height: self.parent.width/2
Image:
source: 'Images/employee/userprofile.png'
size: self.parent.size
center_x: self.parent.center_x
center_y: self.parent.center_y
the following image is what I expect every time:
this is what I get sometimes:
This is a common issue with alias properties like center_x, right, top, etc. Setting them in kv doesn't automatically bind to the size of the widget (adding that to kivy is not as trivial as it sounds), so while the image is positionned correctly at first, if it's resized after, then the position is not updated, because the parent's pos didn't change, only the children's size! As luck would have it, in such situation, it's not uncommon to have code that seems to work half of the time, depending on the timing of dispatching in that particular run.
Anyway, the solution is quite simple, explicitly reference the children's size in the bindings, so the expression is recomputed every time it changes.
center_x: self.width and self.parent.center_x
center_y: self.height and self.parent.center_y
How do you set the width of a Round Textured Button in an NSToolbar, that is, set the width so that it is actually kept at run-time? If I drag a Rounded Textured Button and drop it on an NSToolbar. I've set the width to 25 for both the Custom View/Toolbar Item and the Round Textured Button within it, but as soon as you run the app, the button looks to be three times the width it should be.
I was going to post pictures but I have insufficient reputation points. I hope somebody can figure it out without pictures.
I'm using XCode 6.1.1. Thanks.
The anomaly was caused by my use of 64x64 images. Even though it appeared to scale it properly, the stretching of the button must have occurred first before downscaling the image. If I set the button to NSActionTemplate, for example, the button is correctly sized. I'll look for more appropriately-sized images.
I've written some code which displays a wx.Frame, within which there is a wx.Panel, within which there is a jpg. The jpg is the same size as the frame, so that when the program starts up the user is presented with a picture covering the whole of the window. Overlayed over the top of this picture, and in the centre of the panel I want to put a wx.BoxSizer containing various widgets. So far I've got the sizer visible but, try as I might, I cannot shift it from the uppermost lefthand corner of the panel to the center. No doubt there are many round-about ways of doing this involving grids and borders, but before I set off down this path, I was wondering if I'm missing something simple and there is a command that can be used to position in widget in a specified part of a panel.
ps. I also know I could do this using absolute positioning, but I want to be able to resize the window while keeping the sizer at its centre.
Normally, you can't see a sizer. But regardless, you don't really center a sizer. You center the widgets INSIDE the sizer. So when you add a widget to the sizer, you'd want to do something like this:
mySizer = wx.BoxSizer(wx.VERTICAL)
mySizer.Add(widget, 0, wx.CENTER|wx.ALL, 5)
Now, that will only center it horizontally. If you want it in the very center of the panel, then create another BoxSizer that is oriented horizontally and add the first sizer to the second one, centering it too.
hSizer = wx.BoxSizer(wx.HORIZONTAL)
hSizer.Add(mySizer, 0, wx.CENTER)