How do I set a Gtk.StatusIcon as Text - python

I'd like to create a Gtk.StatusIcon with custom text. Ideally I'd like to append this to an existing image, but text-only is ok, too. How can I achieve this?
I've seen some posts about getting a Gtk.Label's pixbuf but those methods seem to be removed from Gtk3 (pixbuf_get_from_drawable)

I don't think that is possible. The status icon is not a widget and the icon is going to be scaled by the window manager. Even if you used Cairo or PIL to generate an image on the fly to use as the icon pixbuf, it wouldn't have the effect of an embedded label in the system tray. It would instead be tiny, unreadable text smushed into the size of the other icons.

Related

Using ttk theme azure-dark and Changing background color of ttk combobox widget

I am using the ttk azure theme dark Azure-ttk-theme. It sets the background color to nice modern looking UI. However, as seen in the images the background color of the tk window, Text widget and combobox widget is set as same. This looks bad when we are using all these together with some text in area(as seen on the right side of screenshot below).
I tried to modify the background of my combobox as below(pardon the full imports- just for replication):
from tkinter import *
from tkinter.ttk import *
root = Tk()
style = ttk.Style(root)
root.tk.call("source", SYSTEM_DIR / "azure.tcl")
root.tk.call("set_theme", "dark")
style.configure("TCombobox", fieldbackground= "orange", background= "white")
g_combo = Combobox(root, style="TCombobox")
But, the above code does not have any effect on my interface. If someone has any idea on how I can handle this. I might have to modify the tcl file for this theme. Since, I have limited knowledge on tcl I am looking for answers/suggestions here.
Ahh, well, I am answering this question because I also tried using this theme yesterday. My idea was too something similar to yours. I wanted to change the default colors and stuff to get a better UI. Before getting into the solution, I have to tell you that this theme overrides the default values and designs to a custom-created one as set by the author. So here's what you can do to achieve what you want.
As far as I know, the only way to do this is to edit the TCL file, which manages the colors of the widgets. It would help if you had some idea about TCL language before you get into it so deep. So I will tell you step by step:
Go to dark.tcl file, and then find the widget's code where you want to change the background color. Say you want to change the combo box's background color. So if you are on windows, you can search "Combobox" by pressing ctrl+f after opening that file (I suggest using Notepad to edit it, it's more accessible).
Ok, so here are the codes where you want to change. As you can see in the third part of the code (ttk::style element create Combobox.field), it is used to create the combo box widget. You can keep trying changing different statements and customize the whole Combobox and its effects (If you know how to). But now lets focus on background color
So in there, you see that the default background is set to an image known as box-basic.
So now you have to go to Azure-ttk-theme/theme/dark folder and find out where that box-basic file is. Once you find it, you have to edit the colors of that image with respecting the same size and then replace the old one and make sure you set the same name. I suggest you to use figma to replicate another image. Its easy. Change it to any color you wish.
And you are done!
With some other theme fieldbackground would work, but not with Azure (or with any of my themes).
Tk handles PNG images containing transparency very badly, especially on Microsoft Windows.
So to reduce lagging, I removed the transparent areas of the image elements, and therefore where you'd expect fieldbackground to be, there's actually the images' background, which looks like as if it were fieldbg.
So the solution is to edit the images, as TechieGeeke suggested.

How do I create something as shown below (volume change indicator) in linux?

I would like to show an image with transparent background to indicate something when a key combination is pressed.
Let's say I pressed ctrl+f3, I trigger a python script. Is there anyway I can make that happen?
What python library can I use to show an image without window border and background?
I have figured out how to trigger the file on key press. How to I deal with the (imshow) thing?
Thank you.
show an image without window border and background
This sound like task for some GUI library. There are many available but you would need test them in order to find which one can do it. First feature is generally known as frameless or borderless window. tkinter which ships with python has ability to work this way, see for example tutorialspoint.com tutorial, though I do not know how it will work with alpha channel of your image.

Is it possible to use pango markup text on a Gtk+ 3 toolbutton label using Glade and PyDev?

I have put together a Gtk+ interface in Glade and part of the UI is a tool palette with several toolbuttons using utf-8 characters as labels. They work fine in the default font, but I would like to change font details using pango markup. This is straightforward when dealing with a label as such, as one can apply
label.set_markup(pangoMarkupString)
but the label in a toolbutton can not, as far as I can tell, be addressed directly in this way. A naive
button.label.set_markup(pangoMarkupString)
naturally doesn't work and returns an error saying that toolbuttons do not have the label property. Is there any way to use pango parsed text in a toolbutton, and what depth of python trickery would be required at the application end?
To save any others from hours of fruitless head-scratching and searching, and to open the eyes of other newbies to the powers of Gtk+ 3 and Glade, I present the solution I found.
Right click on your tool palette in the outliner and select edit
Choose the hierarchy tab in the editor
Select your button in the hierarchy outliner
Under Label properties choose widget rather than text
Click on the selector icon at the right of the widget entry box
Add a new widget
Leave the tool palette editor
Select label1, the new widget you created in the outliner
You can now edit its id, label text and attributes
I don't need it yet, but I wonder how to do this with a regular button...

wxpython balloonframe overlays all windows

I am using BalloonTip and BalloonFrame from wxpython in order to generate pop up notifications. Unfortunately the generated elements are overlapping all windows: Not only the window of my application but also all windows of the other applications.
I would like to suppress this behavior and display the notification only on top of my own application and not on top of all windows.
Is there any possibility to specify the "z-index" like in CSS or something similar?
You should probably just create your own frame then as I don't believe the Balloon widgets support that behavior. When you do create your own frame, you can tell it to center on parent. If you want it to disappear on it's own, you can use a wx.Timer. You could also look at this:
http://wxpython.org/Phoenix/docs/html/adv.NotificationMessage.html

How to create a window with alpha-channel transparency, using wxPython?

Hey there, first time asking.
I have been trying to use wxPython to create an overlay windows to be displayed over other programs, however I can't seem to figure out how to make an image appear with an alpha-channel transparency over my desktop.
In the future I will be planning to have buttons on top of the image also.
Something like this, but with an image that has an alpha so that you can see the window behind it.
To make a wxPython application transparent, you need to make the Frame itself transparent. Which you found out in that tutorial I wrote a while back. Images are a little different. There are examples in the demo and in the wxPython mailing list archives though. See also wxPython - drawing on transparent/alpha background (for custom widgets/panels) and http://wiki.wxpython.org/WorkingWithImages

Categories