Black boxes around slider in wxpython GUI - python

I imagine this is a simple question and was hoping it someone would be able to help me figure it out. I have multiple wxpython sliders in my GUI but some of them have black boxes around.
The sliders are placed inside a StaticBox which is placed inside ScrolledPanel. It seems that those that are on top (i.e. are shown without the need to scroll the panel) look normal, as for the 'Annotation font size' but the ones that were hidden have black background behind it. Anyone has any ideas?
I thought it was because I was not calling Layout() but it doesn't make any difference.

I managed to fix this problem on my side. Maybe it helps you too. In my case, I have a lot of text boxes and sliders on a scrolled panel (wx.lib.scrolledpanel.ScrolledPanel):
Black boxes around sliders:
I am fixing it by setting the background color of the panel after I have finished populating it with graphic elements:
self.SetBackgroundColour('WHITE')
Here is the result:
No more black boxes around sliders:

Related

How to set a background drawing area for cairo with other items on top

I have tried a bunch of stuff over the last few months to only find the best way is as per the attached image which is to use a fixed container in the window to then carry on as per normal but it then makes it hard to have everything else resize properly.
Just curious if there would happen to be a better way to have the drawing area behind everything else to draw on with out having to use a "fixed" container.
In trying over the last few months if I use say a table then put a drawing area in it fills on of the boxes which is not how i feel it should work for what i am trying to do.
I have found it hard as if i try to resize the window I then have to resize the "fixed" container which is ok but if I try to make the window smaller by the bottom right corner it will not resize, I got round this by hard coding a window size and linking this to a button to "minimize" the window correctly.
If anyone has any pointers to information or has any help to offer that would be great.
If nothing comes up I guess I will keep trying to make it happen as I have worked out so far and have a minimum window size and maximum window size with maybe a x/y input box to customize the window size if required.

How to trick Tkinter to make canvas invisible, but not its drawings? Python

(0) Introduction
Hello Everyone! I am an absolute beginner to Tkinter and not sure how to achieve my result. I tried several strategies and was disappointed multiple times. Didn't work due to my ignorance.
I am building my own little programming text editor.
I want to add functionality like yellow light bulbs in IntelliJ IDEA.
According to the idea, a yellow circle with a question mark appears on the screen next to a character which caused a syntax error in the code.
The question is not about positioning objects. I sort of confident in it. I am struggling with tk.Canvas imposing its background. I want to get rid of background and keep drawings visible.
(1) A "Naive" approach
In the code editor tk.Frame I have the following widgets:
tk.Text where user types code.
Positioned with .pack() method.
Line numbers tk.Canvas which is responsible for displaying line numbers.
Positioned with .pack() method
For each syntax error in the code I create a tk.Canvas object where I create yellow circle and question mark text.
Positioned with .place() method
It turned out, tk.Canvas _object has solid background which is covering half of the screen and looks ugly
(2) Attempted strategies, which failed
I looked for a way to make the Canvas object transparent, but from what I found, transparency is platform-dependent. Scary. I gave up.
I also tried to make the canvas have zero size with canvas.configure(width=0, height=0).
I was hoping that the canvas will become invisible and as a result, its objects will have a transparency illusion.
Unfortunately, Canvas objects, rectangles, circles and others are not displayed outside the canvas itself.
The image above is evidence of that property.
The circle is not displayed fully, because a part of it is outside the canvas rectangle.
(3) Some Ideas
I have a couple ideas, which haven't been attempted yet, due to the lack of confidence and research
3.1. Maybe Z-index hack ?
I hope, that It is possible to use a single tk.Canvas to store all circles.
The canvas will be placed in the same position as the text.
Tweaking z-indices, hopefully, can be done in such a way, that the canvas background will be "bellow" The text field, while the yellow circles will be "above" the text.
However. That Idea raises the following questions:
Does tkinter have absolute Z-indexing?
Do the Canvas objects (circles) share the same Z-index?
If so then I guess, the strategy is doomed and will fail. The Canvas is a widget, while as long as I know, canvas objects are not widgets.
3.2. Switch from Canvas approach to Images?
I heard that tk.Label can store Images.
I could draw a simple PNG of yellow circle with question mark. Maybe instead of canvas circle I could display these labels with images and use .place() to adjust their positions. Maybe worth trying.
(4) Summary of the question
How to hack tk.Canvas or achieve transparent background by keeking floating circles not transparent on top of a text? Thank you very much!
EDIT:
The target Platform is Linux.
Hence using root.wm_attrinutes("-transparentcolor", somecolor) hack doesn't work.

wxPython Slider background colour incomplete change

wxPython 2.8.10, Python 2.6.2, Windows 7 x64
So I am having a bit of a wxPython issue I am hoping someone can say where I am going wrong. In my application I have Sliders where the background colour changes as you move the slider around. I do this via SetBackgroundColour from within a EVT_SLIDER handler. It mostly works, but I end up with a border of unchanged colour around the outer edge of the widget.
I have tried Refresh up the chain, RefreshRect on the top level Frame around the widget (and a few pixels further out), various combinations of Update and Layout, but nothing seems to erase it. The best I have managed is if I use something like:
frame = wx.GetTopLevelParent(slider)
rect = slider.GetRect()
slider.ClearBackground()
slider.SetBackgroundColour(wx.Colour(red,green,blue))
frame.RefreshRect(rect)
It will correctly draw the background box with the new colour without the border issue, but it will not repaint the slider itself.
However, if I click away so the focus is elsewhere, the border snaps to the new colour.
I could probably use an overlay or custom paint function but I am hoping there is something I am missing here that will get me the desired results.
Any suggestions?
(edited to add)
Looks like resizing the window manually corrects the issue, but Layout() does not.
It also functions correctly if you do the client size trick:
w,h = slider.GetClientSize()
slider.SetClientSize( (w+1,h) )
slider.SetClientSize( (w,h) )

Is there a simple way to add a border to Kivy Labels, Buttons, Widgets etc. with-out images?

I'm trying to add a border to Kivy Buttons but it doesn't work as expected.
For labels my implementation seems to be OK but for buttons it overrides/clears the standard look of the button.
How can I draw the border above the button with-out changing normal behavior? I'd like to implement it like the ButtonBehavior so I can add a border to every Kivy object with a canvas. I've called it BorderBehavior.
Styling dashed, dotted works only for line width of 1 because there is a bug in Kivy (see https://github.com/kivy/kivy/issues/2037) (Need to figure out what's wrong here later.)
I know that drawing a border is possible with a BorderImage but I'd like to add simple borders with-out an image.
Here is how it looks at the moment:
You can find my source code here (the labels can be dragged just for testing purposes to see that the border is always correctly positioned):
https://gist.github.com/AWolf81/c6796dc2049d9872b2df
OK, I've found the fix. It was a naming conflict.
In the console log I saw that there is a problem at unpacking the border tuple in BorderImage of the button.
Of course, that's not working because my border is implemented differently. Maybe I can add the list (top, right, bottom, left) to my border implementation so I can keep the same name. But I haven't checked that yet.
Changing the naming of my border to borders in python and in kv fixed the problem:
class BorderBehavior(Widget):
borders = ObjectProperty(None)
Now it looks like I want it:
OK, now I'll check if it's working for other classes too (e.g. Scatter, Widget,...). If that's working I'm doing a pull request to Kivy.

How do I remove all background color in python tkinter

I think the background color is the issue, however, it might not be. I am trying to make the background of the frame and canvas image so that you can see the text before it is covered by the rounded side.
Here is an image of what I currently have:
http://imgur.com/FIujzHM
There are other spacing issues, but I am focusing on the color of the background needing to be transparent.
Thank you for any help.
You can't...
Configure tkinter/ttk widgets with transparent backgrounds, ttk frame background colors?
After a couple hours of looking stuff up I figured out it is impossible.

Categories

Resources