Adjust width of Focus Rectangle around QLineEdit on Mac - pyqt5

When a QLineEdit has focus on a Mac, the Mac automatically puts what seems like a 3px-4px wide Focus Rectangle around it. I read
Qt4 Stylesheets and Focus Rect but I only want to adjust the width of the Focus Rectangle (to maybe 1px-2 px), not remove it.
using a for loop for all of my widgets, I also tried
if isinstance(widget, QLineEdit):
widget.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 1)
thinking that the "1" would set the width of the rectangle to 1px, but the code did nothing (my syntax may also be wrong).
Is it possible to set the width in pixels of the focus rectangle on a Mac.

Related

How to center objects in parent with Dock Fill VB.NET

I'm trying to make a RichTextBox have fixed size and blank space flexible (like Word, WordPad), I made this:
Set Dock to Fill
Set MaximumSize to 600,0 (0 is wildcard for sizes) (Width=600 and Height=0 -wildcard)
I got this: blank spaces are flexible and RichTextBox size is fixed, but RichTextBox is not positioned at center.
I have some options:
Set padding to auto (I suppose that it's not possible)
Set margin to auto (I suppose that it's not possible AND margins not works in winforms)
What do I have to do to position RichTextBox to center?
Use anchor instead of dock.
Dock is designed for Size, Anchor is designed for Location
Your problem is based on location, locate your box to center instead of make Dock margins.

SpriteKit visual Editor bounding box not changing size

In the SpriteKit visual editor for sks files when changing the size of scale of a Color Sprite the bounding box size doesn't appear to change with it.
The green rectangle appears to be correct when resizing an the sprite but when switching between edit mode and simulate mode the green box updates to what is happening when playing the game (in the attached image).
Objects are colliding with the bounding box that doesn't match the sprite shape. The sprite is pinned and is not dynamic or affected by gravity or rotatable.
This is happening in Xcode 6.4 but didn't seem to happen in previous versions of Xcode.

How to handle Segoe UI in pixel perfect layout (glyph "margin")

i am fighting with the layout of my windows store app. My problem is with the segoe ui font that I am using for the labels of some textboxes.
I have a borderless label above a textbox with a border like this:
LABEL
_____________
|__TEXTBOX___|
My problem is, that the font of the label does not align perfectly with the left border of the textbox.
First I though that it must be the label padding or something, maybe a padding or margin in the control template. But this is not the case. The true reason is the space around the glyphs within the font itself. Depending on the first letter or the size of the font the gap is bigger or smaller.
Is there a way to perfectly align the label text and the textbox independant of the first letter or the font size? Or do I really have to place every label in a different position to reduce this problem?

Picture Box and Form Transparency

Maybe I am missing something, but is it the case that when you set a pictureboxes background to transparent, all it really does is set it to the same color as the forms background?
What I am trying to do is draw an animation for the benefit of this, a bouncing ball - which I paint on the form, then overlay that with a picture frame. End result should be a bouncing ball in a picture frame, I should mention that the picture frame does not have a straight edge, so it is not possible to arrange 4 picture boxes in a frame. The ball needs to vanish behind the frame to change color and then magically bounce back out.
I have tried:
1.Setting the picture box background to pink and then key out the same pink, this basically cuts away everything, including that which is behind the picture box
2.Setting the picture box to transparent, this just displays the picture box background as the same color as the forms background.
3.I have tried painting the image in a rectangle, this had the same effect as drawing it in a picture box.
I am not sure what I am doing wrong, I am wondering if there is any other ways I could try or if someone has made a custom control or library that supports transparency?
Try using a Panel with the background image set. This is because; as you said: the transparent option only takes the backcolour of the parent.
After doing some more in depth research I solved this by drawing both the images to the form using PaintEventArgs and me.paint
Making each image transparent using:
Dim TestImage as Bitmap
TestImage.MakeTransparent(<Transparency Color>)
Thank you to both of you for your replies though.
Hmm... If You want to use Picturebox and get a transparent image,
Try to set picturebox's background as your 'Ball' (probably you need an image editor).
and set picturebox transparent. It worked for me (VS Express 2010) once.

How Can I use Graphics.CopyFromScreen to enable alpha transparent controls?

I am trying to use (and this may be my problem already) e.Graphics.CopyFromScreen() in the OnPaint() method of my control to prepare a background onto which I can draw the content of the control. The goal is a tool-tip with rounded corners and other specific features to replace the default Windows tool tip.
Ideally the tool tip could be antialiased and blended into the backdrop, however at a pinch I could tolerate an aliased boundary. This may also be necessary as the control will often be covering a control with an OpenGL overlay and the whole blending procedure may end up a nightmare.
I have created a custom user control, a persistent instance of which belonds to my applications's main form, overriding the OnPaint and OnPaintBackground methods. The application of transparency however is challenging. As I understand, the graphics object passed to the paint method starts with a copy of the current VisibleClipBounds, where generally the first move is to clear the control with a solid colour and start drawing the main features. My first thought was to bypass the fill and start drawing on the captured background. For the first redraw this works fine, but subsequent redraws keep the previous content instead of re-capturing the backdrop. I hoped that CopyFromScreen would specifically eliminate the currently drawing control from its capture so as to start from a clean base but this is not the case, it captures the rectangle of the new location including the image of the previous location if it is in the bounds.
Other solutions and permutations thereof such as
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent
e.Graphics.Clear(Color.FromArgb(0,0,0,0))
have to-date yielded no appropriate results.
I started with a transparent form using the transparent key colour. This worked with aliasing but using a form as a tool tip seemed excessive and caused annoying artifacts (some of which could be overcome) such as the temporary presence of the taskbar button, focus loss of underlying form with subsequent visual feedback in the host form's title bar colour. The control is much lighter weight but I am struggling to make it work even as well as the form.
At this point I simply ask how to achieve the desired result and whether CopyFromScreen is a part of that solution.
That's a lot of text to read - but addressing transparency to achieve a custom-shaped form/control... Control.Region can do the same thing:
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
private void CreateRegion()
{
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 40, 40));
}
If your control is set as a top-level window and you're running it on Windows 7 or 8, check into DwmEnableBlurBehindWindow. In the parameter structure, I set enable to true and I create a region 1x1 pixels for the blur. With BackColor and TransparencyKey set to Black, this gives me a entirely transparent window (complete with mouse pass-through) that I can paint 32-bit images to with full alpha transparency (using Graphics.FromHwnd). A bonus to this method is that if the window moves or the background changes, Windows DWM does all the work--I don't have to update a thing.