wxPython Transparent Frame - Display Text - python

I have followed the tutorial here: Transparent Frames
How can I make it so only the text from TextCtrl has 100% opacity while the rest of the window is invisible? What i mean is, I want an invisible window except for the text in TextCtrl.
I am on Windows 7, using python 2.7.

According to the tutorial you linked:
Only top-level controls can be transparent; no other controls can
A textctrl or statictxt, of course, is not a top level control.
There is this option, which I believe only works ontop of other opaque objects not on a transparent panel.
This shows how to draw an arbitrarily shaped window. If you combine (somehow) the above two, you should be able to get text against a transparent background. Other than that, good luck.

Related

Qt QScrollBar change background Color

I was working on Qt Designer and I wanted to edit the background color (if possible a gradient) of QScrollBar but I don't know how to do it properly.
When I add any background color the whole widget changes color uniformly and becomes solid.
I was trying to change the color of the area behind the bar and arrow buttons only.
Unfortunately, with many complex widgets you can't just change a property with stylesheet without all the necessary implementation.
QScrollBar is one of those widgets, and in order to achieve background customization through stylesheets, at least all the following have to be provided too:
overall background color
add/sub-page color
handle color
add/sub-line ("arrow buttons") colors
To make the widget more visually responsive, borders (with pseudo-states for pressed/enabled/hover states) should also be provided, and adding images for arrow buttons is usually suggested (small arrows can be obtained through css border tricks, though).
The starting point is the official Qt stylesheet example documentation, which has a section for customizing QScrollBar.
Note that using a QProxyStyle is not an option, as many styles draw scrollbars in different ways, and sometimes they even ignore some "official" style functions like drawControl, because they take care of the whole painting within the drawComplexControl, using private functions.

wxPython Frame Background transparent

Another question to wxpython.
I have a Frame with (at the moment) 3 Panels. All of them contain *.png pictures with transparent parts.
But behind these transparent parts there is the grey from the Frame background.
What I want is just a transparent background, that I can see for example my Desktop or whatever is behind the programm in that moment.
All I found was SetTransparent(0) but this made the full programm transparent and the other thing was to change the shape, but that dosen't made anything, except change width/heigth, if the shape has not the same properties.

Get the background color of a widget - really

I'm having trouble getting the actual background color of widgets.
In my special case I'm having trouble with widgets within a QTabWidget.
This is on Windows7.
So classic widgets have some greyish background, whereas widgets within a tab are generally drawn with a white background.
I tried:
def bgcolor(widget):
color = widget.palette().color(widget.backgroundRole()) # version 1
color = widget.palette().color(QtGui.QPalette.Background) # version 2
rgba = color.red(), color.green(), color.blue(), color.alpha()
return rgba
which is pretty much what I could figure out myself from the Qt documentation and what google and SO give.
But, this just doesn't work.
I'm testing widgets inside and outside of a TabWidget and the function above returns identical colors for obviously differently colored widgets.
Namely it always returns the greyish color, even for the plain white colored widgets within the tab.
Am I missing something here?
EDIT:
My problem is when using matplotlib, matplotlib draws figures with a "none" facecolor with the wrong background color when embedded in a QTabWidget: grey, even though the parent widget is white.
To fix this I wanted to get the background color of the widget and set it as background color for the figure.
Though this may be a matplotlib issue, I guessed this would be the quickest workaround.
As I noticed I couldn't get the proper color, I became insistent :)
The palette is returning the correct colours.
The mistake you're probably making is that you're assuming "background" always means the same thing for all widgets. Let's take an unmodified QListWidget as an example. On a desktop with a traditional light-coloured scheme, this will probably appear as a white viewport inside a 3D sunken panel. But if you query the "background" for this widget, you will see something like this:
>>> widget = QtGui.QListWidget()
>>> widget.palette().color(QtGui.QPalette.Background).name()
'#edecec'
which is obviously not white. So Background is the wrong color role to query for this widget. Instead, it looks like Base might be more appropriate:
>>> widget.palette().color(QtGui.QPalette.Base).name()
'#ffffff'
It's worth noting that the documentation for color roles states that Background and Foreground are obsolete values, with Window and WindowText being recommended instead. Perhaps this is because the former terms are now considered to be misleading.
UPDATE:
On platforms which use pixmap-based styling, some of the reported palette colours will not match the visual appearance of a widget. This issue specifically affects Windows and OSX, and so may explain why you are not able to get the apparent background colour of tabs. This issue is documented in a Qt FAQ, which also gives some possible solutions (although the QProxyStyle option is supported in PyQt5 but not PyQt4).

Achieving a facebook-like modal dialog in GTK+ (linux)

Ideally, the transparent border.
Here's an example of what i'd like to achieve:
Notice the transparent border.
Now i suppose I could use cairo to create a rectangle with transparency, and put a borderless non-transparent window inside, mimic'ing that effect - which I would if i knew the window would have a fixed dimension. However, if the inner window grows, it'll grow out of the transparent rectangle.
How should one approach such task?
Making window frames is really the job of the window manager (at least under X11, don't know how it works on windows).
But have a look at the GtkBin, GtkBox or GtkMisc widgets. Pack the dialog inside it as a single widget, and use padding to give it a size. Read up on GTK+ drawing model. You will probably need to set a flag and define your own expose-event handler to re-draw your frame.

movable and resizable text edit control like in mspaint using wxpython

Hi I am trying to add some text to an image, and want adjust font, size, etc.
Is there any way to implement a mspaint style text input control in wxpython?
It have a rectangle area you can input text in it, and with 8 handler in 4 corner and 4 border to adjust size. I see many control like it in photoshop and other image process software.
Check out Whyteboard. I think it has one of those widgets and it's written in wxPython:
http://whyteboard.org/

Categories