How to hide a widget with pyuic5 - python

Is there a way to hide a widget(in pyuic5).
I've tried:
self.playBtn.hide()
which doesn't cause an error, but doesn't hide the widget. That was kind of a shot in the dark, and the documentation isn't providing too much info. Any help is appreciated.

If you have a solid color background:
you can draw or create a sprite that is the same color of the background and position it on top of the button
Or
you can delete the element and re-create it when you want to show it

Related

Black boxes around slider in wxpython GUI

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:

PyQt - Draw rectangle behind a widget

I have a QStackedWidget with a QLineEdit and a couple other widgets inside of it. This QStackedWidget is fairly dynamic - you can move it within its layout by clicking/dragging, change its current widget by right clicking it, etc.
I'd like to draw a simple, gray rectangle or a gray rounded rectangle around the QStackedWidget to let people know that the QLineEdit they're looking at is important. This drawn rectangle has to be able to follow the QStackedWidget so that it follows properly with the widget when I move it to other locations on-screen.
I've tried several approaches so far but they've all fallen short in some regard or another or it just wouldn't move with the widget. Can anyone show me how?
Depending on how your clicking/dragging is implemented, you should just be able to place the QStackedWidget inside another QFrame, or put a QFrame inside your QStackedWidget and put all the other controls inside the QFrame. QFrame's support drawing borders around them.
frame = QFrame()
frame.setFrameStyle(QFrame.StyledPanel)
frame.setLineWidth(2)

PyQt4: How to make Icon bigger than QPushButton? (Pixmap Buttons)

I am struggling on making a Pixmap button, since there was no other option (That i knew) i tried using QIcon.
The picture that i wanted as button, was not fully square, i wanted to only show the pixmap, but with it still having a button function (Signals connecting to slots, etc.).
When i tried to make the Icons size equal to button, Icon would go up and it wouldn't fit in at all, and button would show outside of icon.
So the Question is:
How can i make icon greater than a QPushButton? so only icon would show and it would still have icon functions.
If this is over Icon borders, then is it any other way making Pixmap buttons?
You can simply use css to achieve that with the background-image property like this and also set the border to 0
btn.setStyleSheet("background-image: url('image.jpg'); border: none;")
I use PySide. Maybe the codes are similar
btn = QPushButton('')
btn.setIcon(QPixmap(image path))
# adjust width and height to fit the size of button.
btn.setIconSize(QSize(width, height))
# set zero border.
btn.setStyleSheet('QPushButton{border: 0px solid;}')

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.

Categories

Resources