I am using Busy indicator to show intermediate progress and i want to change the color of the circles. I referred Customizing Busy indicator link but this is changing the default animation and other things. Also, It is difficult to understand because there is no explanation for the same.
I just want to change the color and the animations should be the same as default. please suggest.
Since the BusyIndicator actually just uses the palette.dark color, you can easily change it using the following code:
BusyIndicator {
palette.dark: "red"
}
Note that if you use the Material theme, you have to set the Material.accent color Material.accent: "red". And perhaps similar changes apply to other themes.
Fun fact: I found this by looking at the QML files in the Qt folder, for me: Qt/5.12.3/gcc_64/qml/QtQuick/Controls.2
Related
I'd like to create a context menu looking similar to this one:
I read suggestions on the web that QWidget::setMask() should be used to create a shape. But how can it fit the variable number of items then? Moreover, the same menu item may take more or less screen space on different machines.
Another question is how to create a shadow around this custom shape? As far as I understand, the mask allows to crop the widget, but not to make it semi-transparent.
I don’t found an easy way to do that! But here goes a way!
Instead of using the Qt mask API, I've used a frame-less widget with transparency enabled!
To draw the shadow, I've used radial gradient!
You can change the size of the menu before opening it, however you can’t resize it after opened (for example resize with mouse).
It’s quite easy add or remove widgets, just respect the layout margin to not draw outside the bounds destined to widgets. To simplify your life I created an inherited class of QPushButton with colors you can easily customize with style sheet.
See the result:
You can browse the source
Hope that helps!
I am looking to change the background color of a button in my GUI application to default.After searching online, i saw that
button1.SetBackgroundColour(wx.NullColor) does not seem to work. I am using python 2.7.
Is there any other way I could set it to default color with out using system colors
A little late, but maybe someone else has the same problem.
Did you try
button1.SetBackgroundColour(wx.NullColour)
So, write "Colour" instead of "Color", the non-American writing. This worked for me.
If wx.NullColour doesn't work, a solution is to decode the RGB code for the colour you seek and apply it to your background.
E.g. the background color on my wx GUI is the light grey from Windows, its RGB code is R=240, G=240, B=240 (you can measure this using Paint for instance).
Then this should work:
button1.SetBackgroundColour(wx.Colour(240, 240, 240))
Of course if you want your GUI to be portable on other systems this isn't the best option since this light grey is only the default colour in Windows.
With Python 2.7.17 and wxPython 3.0.2.0 the following seems to work:
button1.SetBackgroundColour('')
I think that the solutions do not work because wxPython works with a style system. I was able to change foreground & background colours with the SetStyle method.
I was styling a wx.TextCtrl where I needed to highlight the text I search for.
First, I stored the existing colours to variables.
bc = self.te.GetBackgroundColour()
fc = self.te.GetForegroundColour()
self.bcol = wx.Colour(bc[0], bc[1], bc[2], bc[3])
self.fcol = wx.Colour(fc[0], fc[1], fc[2], fc[3])
Change the colours with SetStyle
self.te.SetStyle(x, y, wx.TextAttr(wx.BLACK, wx.LIGHT_GREY))
And reset it back to the original colours:
self.te.SetStyle(0, -1, wx.TextAttr(self.fcol, self.bcol))
I inherited a code project and am tasked with redesigning the GUI with Qt's Style Sheets.
There is a subclassed QtTreePropertyBrowser which I've styled to change the background colors/font color, but I can't for the life of me figure out how to change the appearance of the branch indicator icons. They're almost invisible on the new dark background, like such:
Doing some googling, I found this example.
But from my experimenting so far, it hasn't worked. Reading the documentation, it seems that QtTreePropertyBrowser inherits from QTreeView, but I don't know why it's not working. Any insights?
I have a multi-platform Qt application with a custom palette that we have already set up to produce the look that we want. The palette was set on the top level widget and so this was inherited by all of the child widgets.
I then wanted to dynamically change the text colour of some QPushButtons. Searching around for the best way to do this, I began reading about Style Sheets which I didn't know that much about previously. These seemed to be a good option for changing the look of the push buttons and they did this. However, as soon as I set the text colour using a style sheet, the widget palette jumped to the default. It soon became obvious that style sheets are not compatible with custom palettes and it wasn't possible to mix the two. Most of the info that I found suggested that style sheets should be used rather than custom palettes because, among other things, style sheets offer guarantees across platforms and looks which palette fiddling does not.
From this, it seemed like a good idea to convert my custom palette into a style sheet and set it on the top level widget. Then I would easily be able to change just some parameters of certain child widgets using sub-style-sheets. The problem is that the palette contains many colours that we have set that do not appear to have a style sheet equivalent. Eg, Light, Midlight and Dark. Without being able to set these colours I wasn't able to produce the same look using style sheets as I previously had with the customised palette.
I would like to know if there is a simple way to convert a customised palette into a style sheet or whether there is some documentation to describe the equivalent style sheet settings for each palette colour. I have done searches on google, stackoverflow and the Qt reference docs but have come up short.
Thanks for any info.
ps. I solved my original problem by dynamically modifying the ButtonText attribute of the palette for the QPushButtons. But I would still rather use style sheets instead if possible without changing the main look of my application.
QColor.name() is the hex string for that color. If you want to convert to a stylesheet, just run through all the roles in your palette and print the .name() of that color. You can then find the corresponding stylesheet properties and pseudo states to set the hex colors to.
One thing you may find frustrating from switching from palettes to stylesheets is that CSS
does not allow the use of variables, so you'll have to use the hex string everywhere, rather than just defining named colors and using those.
Context
I'm working on an application with PyGtk that would more or less work as a panel, much like gnome-panel. Ideally, on the panel i am making, i want a button without border (NB: i am in the process of learning GUI coding with PyGtk).
Problem
I have understood from another thread as well as documentation that the gtk_button_set_relief(GtkButton, GTK_RELIEF_NONE) cancels the button relief on GTK_STATE_NORMAL only. Hence when hovering the button, relief appears again (side note: this is frankly annoying that such options are partially worked out really).
An alternative to the problem is to use a GtkLabel and make a GtkEventBox its parent and make it function as a button. There is an issue however: while a GtkButton font has a relief, the GtkLabel's has none. See screenshot here below:
From left to right: GtkLabel without font relief and GtkButton with font relief
Questions
Now perhaps you can help me to solve the above with your suggestions. What i am thinking of is:
What is causing the relief of the font on these GtkWidgets: the theme or the Gtk base itself?
How can i add relief to the font of the label? OR
How can i remove the border relief of the button in all states?
More generally, how can can i create my own widget (subclassing either GtkLabel or GtkButton) using PyGtk? (I have seen an example on this thread, but that's C i believe)
Is there any alternative i haven't thought of?
Should i use another GUI library altogether?
Thanks.
Benjamin :)
Edit: the former resize-grip handle issue with GtkEventBox appears to be the effect of a Gtk+ bug.