How to set color for one button in GTK+
GtkButton button8 {
border-radius: 20;
border-width: 1 1 1 1;
font: Sans 16;
color: black;
background-image: -gtk-gradient (linear,
left top,
left bottom,
color-stop(0.0,rgba(34,97,170,1)),
color-stop(0.50,rgba(56,145,218,1)),
color-stop(0.51,rgba(34,131,216,1)),
color-stop(1.00,rgba(134,191,234,1)));
}
This css changes the color of al buttons in glade file.How should i change the css so that it affects only one button?
gtk_widget_set_name (widget, "fooname"); or do the same in glade:
then use something like
GtkButton#fooname {
border-radius: 20;
...
}
See https://developer.gnome.org/gtk3/stable/GtkCssProvider.html
Related
I'm styling my E4 application using css. Now when I change my MPart tab color and gradient it will also color the backgroud of the tab.
My css looks like:
.MPartStack {
swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
swt-selected-tab-fill: #F0F0F0;
swt-unselected-tabs-color: #F0F0F0;
swt-outer-keyline-color: #A0A0A0;
swt-tab-outline: #A0A0A0;
padding: 0px 2px 2px;
swt-shadow-visible: false;
swt-mru-visible: false;
color: black;
swt-tab-height: 22px;
}
.MPartStack.active {
swt-selected-tab-fill: #F0F0F0 #99B4D1 100%;
swt-unselected-tabs-color: #F0F0F0;
swt-outer-keyline-color: #A0A0A0;
swt-tab-outline: #A0A0A0;
swt-shadow-visible: false;
}
.MPartStack, .MPart {
font-family: '#org-eclipse-ui-workbench-TAB_TEXT_FONT';
swt-corner-radius: 6;
swt-simple: true;
}
Now it looks like:
And the color in the red square need to be changed.
When I change the swt-selected-tab-fill to only use one color it works correctly. But when adding the gradient (swt-selected-tab-fill: #F0F0F0 #99B4D1 100%;) it will color the background of the tab. How can I place a gradient on the tab but without changing the backgroud color?
I am using vis.js to display some items on a timeline.
Some items have a clear start and end date which allows me to simply use the vis.js timeline features.
By default a div box is drawn which I can overwrite with my custom CSS.
This is a running example how this looks like with some ugly custom styling:
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');
// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
{id: 1, content: 'item 1', start: '2014-04-16', end: '2014-04-19'},
]);
// Configuration for the Timeline
var options = {};
// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
body {
font-family: purisa, 'comic sans', cursive;
}
.vis-timeline {
border: 2px solid purple;
font-family: purisa, 'comic sans', cursive;
font-size: 12pt;
background: #ffecea;
}
.vis-item {
border-color: #F991A3;
background-color: pink;
font-size: 15pt;
color: purple;
box-shadow: 5px 5px 20px rgba(128,128,128, 0.5);
}
.vis-item,
.vis-item.vis-line {
border-width: 3px;
}
.vis-item.vis-dot {
border-width: 10px;
border-radius: 10px;
}
.vis-item.vis-selected {
border-color: green;
background-color: lightgreen;
}
.vis-time-axis .vis-text {
color: purple;
padding-top: 10px;
padding-left: 10px;
}
.vis-time-axis .vis-text.vis-major {
font-weight: bold;
}
.vis-time-axis .vis-grid.vis-minor {
border-width: 2px;
border-color: pink;
}
.vis-time-axis .vis-grid.vis-major {
border-width: 2px;
border-color: #F991A3;
}
<link href="http://visjs.org/dist/vis.css" rel="stylesheet"/>
<script src="http://visjs.org/dist/vis.js"></script>
<div id="visualization"></div>
</body>
</html>
This is basically creating a blue box with a solid border. So far so good.
In my case I have some items which don't have a defined start and/or end date, so there might be open ends (from ever to ever).
To be honest I am struggling with both the 'conceptual' and the 'technical' solution how to display that within the timeline.
Currently I am just setting some very early/late date for open starts/ends but ideally it would be somehow visible to the user.
First idea that I had was to draw some infinite icon in the background of my item's div at the left for open start and/or at the right for open end.
Another idea would be to somehow fade out the endings of my div (some color grading from blue to alpha and get rid of the solid borders left and right).
Does anyone have a better idea (I guess so) and how would I have to overwrite the given CSS to reach that goal?
Yet I hope the question is clear and precise enough, if not please give me some chance to explain it into more detail.
I need your advices. (Sorry for my eng. I hope than you'll understand me)
1) I want to create custom TabWidget and use QSS. Now it's look like this:
I want fill background under tabs (I accept property called autoFillBackground). It's need look like this:
2) When I start drag and drop tab this tab is filled with white color. And when I drop the tab this tab set custom qss.
I want to change the style when I drag and drop the tab.
Thx
(I was reading qss manual)
some code
QTabWidget::tab-bar {
background-color: black;
}
QTabBar::tab {
background-color: #4094da;
border-color:white;
font: bold 12px 'Arial';
color: white;
height:60px;
}
QTabBar::tab:!selected {
background-color: #9E9E9E;
color: white;
}
QTabBar::close-button {
background-position: center;
background-image: url(":/Appearance/close_chat_item");
}
QTabWidget::pane {
position: absolute;
}
QTabBar::tab:selected {
border-color:#4094da;
background-color: #4094da;
color: white;
}
The QTabWidget does not paint the background, you need to set the background of the parent widget of the QTabWidget.
As I understand, you willing the background color to change in any drag & drop situation(or it is my assumption). If it's like I understand, you should define hover option on your qss. For more info on Qt documentation.
Example code:
QTabBar::tab:selected, QTabBar::tab:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #fafafa, stop: 0.4 #f4f4f4,
stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
}
Your priority should be forcing to cost on qss, logic structure consider to second plan or you can use for some kind of workaround.
While digging through mixins.less file of bootstrap 3 I found the following:
// CSS image replacement
//
// Heads up! v3 launched with with only `.hide-text()`, but per our pattern for
// mixins being reused as classes with the same name, this doesn't hold up. As
// of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. Note
// that we cannot chain the mixins together in Less, so they are repeated.
//
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
// Deprecated as of v3.0.1 (will be removed in v4)
.hide-text() {
font: ~"0/0" a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
// New mixin to use as of v3.0.1
.text-hide() {
font: ~"0/0" a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
Has anyone been using this? Where do I specify the image that I want to replace the text? Am I right to assume that all this does is to hide text and not replacing it with an image?
Yes, this does not include an image, it only hides text. You will need to do your own image replacement, perhaps in a custom CSS rule:
.my-image-replacement {
background-image:url('myImage.jpg');
.text-hide();
}
I use the following for convenience:
.image-replacement( #url, #width, #height ) {
display: block;
width: #width;
height: #height;
background: url(#url) no-repeat left top;
.text-hide();
}
.logo {
.image-replacement( "images/logo.png", 100px, 50px );
}
Note this version is not retina - use bootstrap's .img-retina() from mixins.less instead of the background line above when you're serving hdpi images…
I want to style my tabs in my Qt app as follows:
I used following style sheet:
QTabBar{background-color: #fff; border-top: 0px;}
QTabBar::tab {
border-image: url(:/New_UI/tab_inactive.png) 7 17 7 2;
margin-left: 2px;
border-right: 17px;
border-top: 5px;
border-bottom: 5px;
font: 400 9.2pt "Segoe UI";
color: #ccc;
padding: 0px 13px 0px 5px;
max-height: 26px;
}
QTabBar::tab:selected, QTabBar::tab:hover {
border-image: url(:/New_UI/tab_active.png) 6 17 6 2;
}
QTabBar::close-button {
image: url(:/New_UI/tab_close.png);
subcontrol-origin: padding;
subcontrol-position: right;
width: 13px;
height: 13px;
}
The result is as follows (close button position is not as I wanted):
What am I doing wrong & how could I get my desired result ?
EDIT : I know this post is old, but I hope it could help someone else.
After a couple of tests, I think there is one way to do this, but it does not use Qt style sheets :
Subclass your QTabWidget to have complete access to the protected features
Create your own QWidget or QPushButton as your close button
Manage the position of your button with the stylesheet property (margin-right for example)
Add your button to the tab tabBar()->setTabButton(index, QTabBar::RightSide, closeButton);
The code I used for the test :
MyTab::MyTab(QWidget *parent) : QTabWidget(parent)
{
/// Create your button
QPushButton *close = new QPushButton(this);
// Add a tab
addTab(new QWidget(), QIcon(), "Tab 1");
setStyleSheet("QTabBar::tab { width : 150px;}");
// Size and move your button
close->setStyleSheet("max-height: 14px; max-width: 15px; margin-right: 50px;");
// Add your button to the tab
tabBar()->setTabButton(0, QTabBar::RightSide, close);
}
Finally, in the MainWindow, I added my own TabWidget to a layout :
ui->layout->addWidget(new MyTab(this));
The result :
But now you will have to handle the close action manually by connecting the button and get the index for a removeTab(index) call.
I am doing the same thing as you do, here is my stylesheet:
QTabBar::close-button{
image:url(:tabclose.png);
margin-right:4px;
}
Do not use "width" and "height" property, those two doesn't work here, setting a "image:url()" on sub controls implicitly sets the width and height of the sub-control (unless the image in a SVG).
Use "margin-right" property to control the distance from the right edge of the tab;
Add a custom button is a good answer.but if you use margin to decide close-button's position,the close-button's mouse area will be abnormal,so I add a SpacerItem and button in a widget,finally add this widget to TabWidget.
void TabBarCloseable::tabInserted(int index)
{
QWidget *widget = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(this);
widget->setLayout(layout);
QToolButton *closeBtn = new QToolButton(this);
layout->addWidget(closeBtn);
layout->insertSpacing(1, 15);
closeBtn->setStyleSheet("max-height: 16px; max-width: 16px;");
this->setTabButton(index, QTabBar::RightSide, widget);
QTabBar::tabInserted(index);
}
You have wrong padding
Top
QTabBar::tab {
min-width: 25ex;
padding: 10px 50px 10px 10px;
}
buttom
QTabBar::tab {
min-width: 25ex;
padding: 10px 0px 10px 10px;
}
This is a pure stylesheet solution, without creating the buttons manually:
QTabBar::close-button {
image: url(:/tab-close.png);
padding-left: -13px;
}
If you check the Qt source, the image painting code uses only the padding values, not the margin values.