I am currently learning KIVY in Python and trying to figure out how to freely choose position of an element such as label and buttons, like in Tkinter you can use relx and rely to choose excact position. Do anyone know if that is possible in KIVY?
Just set the pos and size to what you want. If the parent is something like a FloatLayout, also set the size_hint to None, None to avoid the layout automatically resizing it.
Can I create a Bokeh layout where the widgets section is set to be e.g. 10% of the screen height with plot section at 90%?
I'm trying to avoid manually re-sizing my plot and using sizing_mode='fixed' which wouldn't work with resizing the browser window.
Currently have:
layout = layout(
[plot],
[[button, slider]],
sizing_mode='stretch_both'
)
In this case, the bottom half of screen is filled entirely by the stretched button/slider.
There is currently (as of 1.3.4) no mechanism to specify a percentage, but you can put the widgets in a row and give that a fixed height while letting the plot vary. Here is one way:
layout = column(
plot,
row(button, slider, height=100, sizing_mode="stretch_width"),
sizing_mode="stretch_both"
)
Is there a way to set the border color for the pygame window, not the background, but the area were the close, maximise, and minimize buttons are
That cannot be set. It is system specific. Unless of course, you want to remove it altogether and make your own version. –
I'm embedding matplotlib in my PyQt 4 application and using it to display images. The matplotlib control is being displayed in a QDockWidget, and I'm setting some its parameters as follows:
imagePlot = self.axes.imshow(myNumpyArray, interpolation = "nearest")
imagePlot.axes.set_axis_off()
imagePlot.axes.get_xaxis().set_visible(False)
imagePlot.axes.get_yaxis().set_visible(False)
self.fig.subplots_adjust(bottom = 0, top = 1, left = 0, right = 1)
This has the desired effect i.e. the image is displayed filling as much space as possible in the QDockWidget while maintaining the aspect ratio. I can resize the dock widget by shrinking it horizontally and then expanding it and the image display is correct (filling as much space as possible while maintaining the aspect ratio). Now, if I add the following line:
imagePlot.axes.set(adjustable = "datalim")
I get unexpected behavior. Initially the image is displayed in the same manner as before, but after shrinking and expanding horizontally matplotlib seems to introduce a border around the data. For example, here's the image as it is displayed initially (and correctly):
And here's what matplotlib displays after I drag the side of the containing dock widget and shrink, then expand back to original size. Note the appearance of the border around the image.
What is causing this and how can I prevent it? Thank you.
For some reason, when I go to create_window in my Tkinter canvas, it erases everything that was previously in said window, and jams the window in the top left corner (even though I set it somewhere else.
canvas.create_window(30, height - 40, anchor = NW, width = 40,
window = canvas.data.buildSquareButton)
precedes
canvas.create_rectangle(0,0,width, 40, fill = "#888888888",
outline = "#888888888")
canvas.create_rectangle(0, height, width, (height-40), fill = "#888888888",
outline = "#888888888")
canvas.create_rectangle(0, 40, width, (height - 40), fill = "#fffffffff",
outline = "#fffffffff")
and an image.
I put in a 1 second time.sleep after the create_window, and I could see that the button was put in the right place. Then after the time.sleep was over, the button threw itself in the top right corner and the rectangle never appeared. I commented out the window, and the rectangles appeared fine.
Am I doing something wrong when I call the window, or is there a Tkinter glitch?
There's not enough information in your question to know for sure. However, my guess is that you are packing or griding a widget in the canvas, and that's causing the canvas to shrink to fit its contents. Or, you're doing something else to cause the canvas to shrink.
To compound the problem, your canvas probably has the same background color as your main window, so you think the contents are being erased, but in reality you're looking at the widget that the canvas is in rather than the canvas itself.
To help prove or disprove that theory, give your canvas a garish background color, such as a bright red. Then run your code and see what happens to the red part of the screen.
Bottom line: there is no bug in tkinter that would cause the behavior you describe. There is a bug in some code that you aren't showing us.
The best thing is for you to create the smallest possible program that reproduces the problem. The mere act of trying to do that may expose the bug in your code. If you are able to reproduce it in a dozen or two lines of code, update the question and we can probably spot the error.
I'm not entirely sure what your question is, but it looks like you're trying to remove everything from a canvas widget at one point in your code to allow for other things to override it, yes?
Try this to reset the canvas: canvas.delete("all")