LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-03-2020, 02:20 PM   #1
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
Question Background color of QPushButton, in Python; Fedora vs. Ubuntu


Wondering what I might be dong wrong. I'm running Fedora 32 and 33, and Ubuntu 20.04 and 20.10, all updated. The code below properly colors the buttons under Fedora, but not under Ubuntu.
Code:
from PyQt5.QtWidgets import (QTableWidgetItem, QLabel, QLineEdit,
    QVBoxLayout, QWidget, QPushButton,QGridLayout, QTableWidget,
    QFileDialog, QApplication, QHBoxLayout, QButtonGroup)
from PyQt5.QtCore import Qt
...
for idx, img in enumerate(["←", "→", "↑", "↓"]):
            btn = QPushButton(img, self)
            btn.setMaximumWidth(20)
            btn.setStyleSheet("background-color: aqua")
            self.xlt_grp.addButton(btn, idx+1)
            hbox.addWidget(btn)
Coloring the background QTextEdit works properly in all cases.
 
Old 10-16-2020, 03:01 PM   #2
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Original Poster
Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
Work-around: set a border in the stylesheet; border:none works. However... this leads to the colored button being shorter than the uncolored button, which is worked around by
fixing the height of the button when it is created.
Code:
xx = self.btn_color_check.size().height()
self.btn_color_check.setFixedHeight(xx)
 
Old 11-21-2020, 08:53 AM   #3
pmv
Member
 
Registered: Apr 2018
Location: Germany
Distribution: OpenSuSE 15.4 Ubuntu 20.04 Archlinux 2022.08.05 Slackware 15.0 OpenSuSE 12.2
Posts: 97
Blog Entries: 5

Rep: Reputation: 31
Code:
btn.setAutoFillBackground ( true );
 
  


Reply

Tags
fedora, pyqt5, ubuntu



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
qt refresh program through qpushbutton dumdadum Programming 5 09-27-2017 06:21 PM
I want to run php file in background on fedora terminal in background. gauravwcities Linux - Newbie 8 01-18-2012 12:23 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
Screen App, Retain BG Color, Background color gets lost duerra Linux - Software 1 07-08-2009 03:01 PM
Eric Python Editor Background Color sadarax Programming 0 08-25-2008 07:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration