I am using wxPython's DataViewCtrl to display some data. On the first column I am displaying an icon using AppendIconTextColumn. The problem is that the icon is shifted to the right and the right portion of the icon is cut off. I have tried using the flag align=ALIGN_LEFT, but that has no affect.
It seems that there should be more options for configuring a cell. Like changing the background color or aligning images.
Can someone please show me how I can move the icon in the cell?
Thank you so much.
Related
I would like to create a button where the title is left aligned and then a value with units that is right aligned.
I need to be able to press it in ordre to open a new frame for changing the value.
I haven't been able to find a solution..
I have also tried to create two labels and then placing them inside the button but with no luck.
Any good solution is more than welcome.
Picture
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:
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) )
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.
I have an image that has a white background, how can I make this background invisible?
Its in a wx.StaticBitmap
wx.StaticBitmap(self, bitmap=wx.Bitmap('images/myimage.png'),pos=(0,0))
By invisible, I assume you mean transparent so that whatever is behind the image shines through.
This is not a function of widgets, but whatever you use to edit your image. You don't say!
I use microsoft visual studio. Here's a screenshot. Notice how the background, shown in a sort of blue-green in the editor - this will show up as transparent, which you can see happening in the column showing the fianl appearances.