PyQt - Transparent background - background

I try to make the background of my window transparent. But under widgets which are on it i see parts of my desktop-image.
Now i have this in constructor:
self.setFocusPolicy(Qt.StrongFocus)
self.setAttribute(Qt.WA_QuitOnClose,True)
self.setBackgroundRole(QtGui.QPalette.Base)
self.setAttribute(Qt.WA_NoSystemBackground)

I've just found this:
Creating Translucent Windows
Since Qt 4.5, it has been possible to
create windows with translucent
regions on window systems that support
compositing.
To enable this feature in a top-level
widget, set its
Qt::WA_TranslucentBackground attribute
with setAttribute() and ensure that
its background is painted with
non-opaque colors in the regions you
want to be partially transparent.
PyQt is still Qt 4.4, maybe that is the problem.

Further to gs's answer, this faq explains why (before Qt 4.5) you cannot achieve this:
FAQ Link:
There is no direct support for partial
transparency, where the window is
transparent and the widgets on it are
not in Qt.
Remember, PyQt's most recent version was created against Qt 4.4, and so does not support the semi-transparent window you desire. gs's other answer, about setAutoFillBackground(True) would work if you were setting the background colour of your main window to anything other than transparent.
Also, see the documentation for Qt.WA_NoSystemBackground, it says you can't depend on the transparent effect that you have so far had:
Qt::WA_NoSystemBackground
Indicates that the widget has no
background, i.e. when the widget
receives paint events, the background
is not automatically repainted. Note:
Unlike WA_OpaquePaintEvent, newly
exposed areas are never filled with
the background (e.g after showing a
window for the first time the user can
see "through" it until the application
processes the paint events). This is
set/cleared by the widget's author.

Try this for your widgets:
widget.setAutoFillBackground(True)
I think you could also set it in the Qt Designer.

Related

Windows Forms/Controls Resized on Wide Screen Monitor

Here at work I have been relegated to working on an old 4:3 monitor. The application I am working on in VB.NET (VS 2008) has several forms and controls that are sized to a specific height and width. They look fine on my monitor, but when I recently released a Beta for Users to try, the users that had widescreen monitors had stretched dialog forms and stretched controls on those forms. Is there a form property to set, or a programming technique to use, in order for the form and all of it's controls to display EXACTLY to the width and height specified?
I ended up fixing the problem myself by setting the .AutoScaleMode of the form to "None", and setting all my fonts to use pixels instead of points.
Unfortunately, this was not an issue of code, but rather of design. Sure, it's easy enough to post code snippets, but if I need to post a whole windows form application that's another story altogether.

how to set form border thickness

I am writing an app using VB.net in VB2013. The Sizeable border is too thick in when displayed on PC's with later versions of Windows7, Windows 8(.1).
Does anyone know how to change the thickness of the window?
You don't get to control that. That's part of the user theme, and users can set any theme they want. You'll find it's also a problem on older versions of Windows if users have a theme with a wider border. You'll need to adjust your program's layout to allow for a little less space.
The border is drawn by the operating system, but you can create your own custom form, there is a library on CodePlex may help you to do what you need easily.
Drawing Custom Borders in Windows Forms

NSPopover color invert in Yosemite dark color

I'm using NSPopover, and when I change the system dock color to dark (Yosemite new feature) some elements in my view invert their color.
For example some labels changes from black to grey, or text fields background changes from white to black. And if I have a view with white background it is now changes to the blurred dark effect.
So two questions:
Can I cancel this behaviour and force the UI to act like in regular mode?
Is there any rules here which element invert their color?
Because it seems that some element changes and some not.
This is my app in Yosemite regular mode:
And this is in Yosemite dark mode:
It might be a library you're using that's causing this behavior. I just tested on a new project and I couldn't make the NSPopover black no matter how hard I tried.
What libraries are you using ? How did you set up your NSPopover ?
Maybe you could try changing the appearance property of the view ?
view.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
NSView has the property appearance because it conforms to NSAppearanceCustomization.
Also see NSAppearance.
————————————————————————
Found the solution:
self.popover.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
the result:
There are ways to do this, though I would recommend embracing it.
It's not concretely documented what will change and how.
But observation will show you what to do.
Primarily it requires you do the opposite of opting in.
Opting in is using Appkit interface elements as is as well as using the NSColor names provided as system colors and using the NSVisualEffectView.
That means to explicitly opt out you need to go around and basically customize views and that mostly means setting explicit colors and occasionally subclassing.
Out of the box HUD style popovers and panels would be opting in.

Gradient button bar like the one found in Xcode 4

The bar I’m looking for is the separator bar between the editor area and the debug area:
Specifically, I want the buttons to have no borders and I want to have the vertical separator (to the left of ‘No Selection’).
I haven’t done any AppKit stuff in Mountain Lion yet, so before I start implementing my own custom control, I was wondering if I have overlooked a new control (or options for existing controls), or otherwise if somebody has already implemented a custom control that does this?
Its just NSButtons with a custom background image (which is the silver effect) and the "Image" which is the control image.
A quick look inside Xcode.app/Contents/OtherFrameworks/DevToolsInterface.framework/Versions/A/Resources will show you the relevant images.

What's the best way to get around the lack of transparency in WixUI background images?

I'm using the Feature Tree UI, with a couple of custom dialogs. One of these has checkboxes on it. These checkboxes cannot be made to have transparent backgrounds, meaning I've had to colour in my background image the default background colour so that there aren't visible boxes around the checkboxes.
However, different versions of Windows have different default colouring! If I match the colour on Windows 7, it looks bad on XP, etc. Since the background images are Bitmaps, I can't make them transparent. What can I do to get around this problem?
From the WiX tutorial UI revisited chapter:
And a common complaint: no, the checkbox can't have a transparent
background. If you have a bitmap in the background, it will be ugly,
just like in our example above. The only workaround is to reduce the
width of the checkbox to the actual box itself and to place an
additional static text (these can be made transparent) adjacent to it.
This workaround has a side effect, although: in order to turn the checkbox on and off, you should click exactly in the box area, not the text. Comparing to the rest of Windows Installer UI limitations, it's slightly annoying :-)
Windows installer supports 32-bit bitmaps (ARGB), which means that the bitmap can be made transparent to show the default windows background color. This means, once your (not transparent) check-box is placed on top, you won't see the ugly box around the text, because it's the same color.
Note that windows photo viewer and the thumbnail preview in explorer DONT support transparencies, so you'll have to build and run your installer to see it working =D.
I used gimp to export to BMP with a transparency and it worked just fine with WIX.