5yutan5 / pyqtdarktheme Goto Github PK
View Code? Open in Web Editor NEWA flat dark theme for PySide and PyQt.
Home Page: https://pyqtdarktheme.readthedocs.io
License: MIT License
A flat dark theme for PySide and PyQt.
Home Page: https://pyqtdarktheme.readthedocs.io
License: MIT License
Normally my table should look like this:
But with the stylesheet enabled it looks like this:
If I comment out the line that sets those header labels, it works, but I can't use my labels.
For reference, this is what I use to set those labels : self.table_tableview.setVerticalHeaderLabels(tabledata[1:, 0])
, table_tableview
is a QTableWidget, and I use the dates from this file: https://gist.githubusercontent.com/Benibla124/7afd02650845c5e6addf4924cfbf8e02/raw/fbf5ff94d9b036a9a3adcd9d0a657ffc4474ec00/Data.txt
Hello, so I'm encountering a problem, I have an project that uses qdarktheme and if I run py main.py
the theme works and it's nice but when I build to exe using PyInstaller and run the executable, it fails with this message:
File "main.py", line 12, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\__init__.py", line 45, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\_main.py", line 9, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\_style_loader.py", line 9, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\_template\filter.py", line 10, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\qtpy\__init__.py", line 3, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "qdarktheme\qtpy\qt_version.py", line 8, in <module>
ImportError: DLL load failed while importing QtCore: The specified module could not be found.
also note that if I build the exe without qdarktheme the exe works, so I really wanna use your theme, so I hope I get a quick response. thank you
This package doesn't seem to adjust the 2d and 3d chart/plot themes in dark mode.
This works well for 3d plots:
.activeTheme().setType(Q3DTheme.ThemeEbony)
And this is good for 2d plot:
.setTheme(QChart.ChartThemeDark)
Hello and thank you for the awesome work.
I've faced the issue;
I cannot change the background colors of individual headerItem in TableWidget.
I'd like to change the background color of the first column header.
hi = QTableWidgetItem()
hi.setText("Header1")
hi.setBackground(QColor('red'))
table.setHorizontalHeaderItem(0, hi)
but nothing happens.
Is there any solution?
Thanks in advance.
This is the Dark mode drop down failing (it is not consistent):
Switching to Light and back to Dark gives the correct results (always):
Is there some other programmatic way to refresh the combos that I can run on start up ?
I have only seen this on QComboBoxes
I am also running this
# set the ComboBox dropdown width.
self.combo_Bandits.view().setMinimumWidth(
self.combo_Bandits.minimumSizeHint().width()
)
Poetry show gives
pyqtdarktheme 1.1.0 Flat dark theme for PySide and PyQt.
pyside6 6.3.1 Python bindings for the Qt cross-platform application and UI framework
X
我该如何设置某个窗口采用此主题,其子窗口不受主题影响
How do I set a mainwindow to apply this theme and its child windows are not affected by the theme
The radio button does not appear in Windows whether in the light and dark modes. I tried PySide2 and 6. It works fine in MacOS though.
When setting the theme to 'auto' to switch automatically, how do I know in the application whether the current theme used by the application is light or dark?
I don't see any property or method that can be called directly.
Thanks.
I like this theme because it's simpler and lighter, but is or will there be a way to easily customize it? Perhaps the generated stylesheets can still have placeholders which are formatted on load after the user of the library passes the wanted customizations.
Mainly the default accent color and maybe the borders and padding of widgets. QFrame
and QGroupBox
for example have border and padding even with the frame set to NoFrame
which makes grouping widgets a bit cluttered. Otherwise manually applying a stylesheet after qdarktheme creates issues with spacing and borders near scrollbars.
With both Light & Dark themes, the header text for sections and 'menu groups' disappears.
A section is a menu item separator with a header text (set in QT, for instance, via addSection).
Menu groups are groups of menu items preceded by a separator with a header text (set in QT, for instance, via QActionGroup).
Attached are screenshots. The "none" color theme shows the normal rendering of a menu with Windows 10's default color theme. "light" and "dark" show what happens when using these color themes
.
So, this is what the GUI looks like normally without any themes:
And this is what it looks like in dark theme:
I like it alot, but at the second checkbox "Make it so that you answer a question incorrectly ever----", the theme just cuts it out the 'y'
The checkbox, spinbox and label are all in a QGridLayout if that helps and I'm also using PyQt5.
Hi, I really like this project and use it to build my UI. However, I found that appearance behavior of buttons is different on mainwindow and dialog window. Here is a demo code to show this:
import qdarktheme
from qdarktheme.qtpy.QtWidgets import (QPushButton,
QApplication, QVBoxLayout, QHBoxLayout, QLabel, QDialogButtonBox,
QDialog,QWidget, )
import sys
class Demo_Dialog(QDialog):
def __init__(self):
super(Demo_Dialog, self).__init__()
self.btn_name = ['a', 'b', 'c', 'd'] # demo for debug
self.btn_ls = []
# # ===== setup IU items
for i in self.btn_name:
btn = QPushButton()
btn.setText(i)
btn.setCheckable(True)
btn.setChecked(False)
self.btn_ls.append(btn)
self.decision_btn = QDialogButtonBox(self)
self.decision_btn.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
self.decision_btn.accepted.connect(self.on_decision_btn_accepted)
self.decision_btn.rejected.connect(self.on_buttonBox_rejected)
# ==== setup UI layout
self.setup_ui_layout()
@classmethod
def _make_h_layout(cls, widget_ls, space=0, margins=(0, 0, 0, 0)):
temp_hbox = QHBoxLayout()
temp_container = QWidget()
temp_hbox.setSpacing(space)
temp_hbox.setContentsMargins(margins[0], margins[1], margins[2], margins[3])
for i_widget in widget_ls:
temp_hbox.addWidget(i_widget)
temp_container.setLayout(temp_hbox)
return temp_container
def setup_ui_layout(self):
btn_ls_container = self._make_h_layout(self.btn_ls, space=5)
global_v_layout = QVBoxLayout(self)
global_v_layout.addWidget(btn_ls_container)
global_v_layout.addWidget(self.decision_btn)
self.resize(300, 300)
def on_decision_btn_accepted(self):
print('ok')
self.done(1)
def on_buttonBox_rejected(self):
print('cancel')
self.done(-1)
class Example(QWidget):
def __init__(self):
super().__init__()
self.btn = QPushButton()
self.btn.setText('get dialog')
self.btn.clicked.connect(self.button_click)
#
self.demo_btn = QPushButton('demo checkable btn')
self.demo_btn.setCheckable(True)
self.demo_btn.setChecked(False)
self.demo_btn2 = QPushButton('demo checkable btn2')
self.demo_btn2.setCheckable(True)
self.demo_btn2.setChecked(False)
self.initUI()
def initUI(self):
hbox = QHBoxLayout()
hbox.setSpacing(5)
hbox.addWidget(self.btn)
hbox.addWidget(self.demo_btn)
hbox.addWidget(self.demo_btn2)
self.setLayout(hbox)
self.setGeometry(300, 300, 600, 600)
self.setWindowTitle('demo dialog')
self.show()
def button_click(self):
print('get dialog')
dialog = Demo_Dialog()
r = dialog.exec_()
if r > 0:
print('')
app = QApplication(sys.argv)
ex = Example()
app.setStyleSheet(qdarktheme.load_stylesheet('dark'))
sys.exit(app.exec_())
when adding calendar is not "add color " to selected date
simple code with only calendar widget
from PyQt5 import QtCore, QtGui, QtWidgets
import qdarktheme
from qdarktheme.qtpy.QtWidgets import QApplication
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
# add calendar to centralwidget
self.calendar = QtWidgets.QCalendarWidget(self.centralwidget)
self.calendar.setObjectName("calendar")
self.verticalLayout.addWidget(self.calendar)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
if __name__ == "__main__":
import sys
qdarktheme.enable_hi_dpi()
app = QApplication(sys.argv)
qdarktheme.setup_theme("auto")
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Hi!
I just noticed that when using the function "setBackground" on table view (looks like also for qtable widget) doesn't seem to work in dark and light theme. Is this expected? Is there something that could be done to render the color?
Thanks for your work!
Hi, I'm using PyQt5 for the first time and I'm having a problem displaying button borders.
Those buttons are not flat, so borders should be visualized (i think?)
Here's an image of the result:
Here's the code which I'm using:
https://github.com/ginop-1/msp_app/blob/main/msp_app/ui/generated/main_window_ui.py
Hi, thanks for the dark theme! It's nice.
I wonder, however, is there a way to change the color of links? For buttons and tabs etc.
The line 'font-size:13px' under the QHeaderView section forces a text size that overrides the application or object font size. It's the only place in both the dark & light stylesheet.py files that font-size is set. Does not seem to belong. I had to remove it in both files for my QTableWidget to properly display the header text.
Btw, qdarktheme is great, thanks for sharing !
I'm running Raspbian Buster, and I have PySide2 installed.
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
import qdarktheme
app = QApplication(sys.argv)
# Apply the complete dark theme to your Qt App.
qdarktheme.setup_theme()
main_win = QMainWindow()
push_button = QPushButton("PyQtDarkTheme!!")
main_win.setCentralWidget(push_button)
main_win.show()
app.exec()
I executed this code line by line, but I crash with a Segmentation Fault when I get to the qdarktheme.setup_theme()
line. Any ideas?
Windows 10, Python 3.11, PySide 6.4.1, pyqtdarktheme 2.1.0
Problem: Enabling a theme with qdarktheme.setup_theme()
enables mouseTracking for QTabBars.
Steps to reproduce:
MoveEvent mouseTracking:True
PressEvent mouseTracking:False
Expected behaviour:
Mouse tracking in QTabBar should be disabled when a theme is enabled.
Here's the example app.
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QTabWidget, QTabBar, QVBoxLayout, QWidget, QLabel
import qdarktheme
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setFixedSize(400, 300)
tab_widget = QTabWidget(self)
tab_bar = CustomTabBar(self)
tab_widget.setTabBar(tab_bar)
push_button = QPushButton("PyQtDarkTheme!!")
tab1 = QLabel("abc")
tab2 = QLabel("def")
tab_widget.addTab(tab1, "label1")
tab_widget.addTab(tab2, "label2")
self.layout = QVBoxLayout()
self.layout.addWidget(tab_widget)
self.layout.addWidget(push_button)
self.container = QWidget()
self.container.setLayout(self.layout)
self.setCentralWidget(self.container)
class CustomTabBar(QTabBar):
def __init__(self, parent):
super().__init__(parent)
def mousePressEvent(self, event):
print(f"PressEvent mouseTracking:{self.hasMouseTracking()}")
super().mousePressEvent(event)
def mouseMoveEvent(self, event):
print(f"MoveEvent mouseTracking:{self.hasMouseTracking()}")
super().mouseMoveEvent(event)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
# Apply dark theme.
qdarktheme.setup_theme() # Comment this line
app.exec()
I have setup qdarktheme according to the guide. I do use it with pyqt6.
When debugging in pycharm, the debugger process does not terminate if the theme is used. As soon as I comment out the
qdarktheme.setup_theme("auto")
, the debugger closes correctly.
Any advice?
Has anyone implemented pyqtdarktheme in C++ version?
There seems to be an issue where it would prefer PyQt6/PySide6 over PyQt5. This means that if my program uses PyQt5 and PyQt6/PySide6 is installed, then it won't work because it will try using PyQt6/PySide6. This results in it not detecting QApplication being instantiated.
Hi there!
I found these themes are pretty nice.
It almost completely satisfies all my needs.
Thank you!
Unfortunately it seems there are a couple of small but looking weird issues.
There is a too big gap between checkboxes and text.
And the checkboxes itself look a little bit stretched horizontally when used in menu items
(In other places they look properly)
Stretched checkboxes in menu + big gap between them and text
I really like this theme. To make my layout consistent I need to reduce the height of all QComboBoxes.
Before qdarktheme.setup_theme this can be done by setting maximumHeight or stylesheets, but after qdarktheme.setup_theme these no longer work.
Is there a way to change the height or to not apply the style to QComboBoxes so they can be styled individually?
Below is a simple example. After you click on qdarktheme, reduceHeight is ineffective.
import sys
import qdarktheme
from PyQt6.QtWidgets import QApplication,QWidget,QPushButton,QVBoxLayout,QLabel,QComboBox
class Foo(QWidget):
def __init__(self):
super().__init__()
lay = QVBoxLayout(self)
b = QPushButton('qdarktheme')
b.clicked.connect(self.setupTheme)
lay.addWidget(b)
b = QPushButton('reduceHeight')
b.clicked.connect(self.reduceHeight)
lay.addWidget(b)
qcb = QComboBox()
lay.addWidget(QLabel('Test'))
lay.addWidget(qcb)
self.qcb = QComboBox()
lay.addWidget(QLabel('Test'))
lay.addWidget(self.qcb)
def reduceHeight(self):
self.qcb.setMaximumHeight(10) # only moves combobox when qdarktheme applied
# self.qcb.setStyleSheet('QComboBox {padding: 0px;margin: 0px;}') # no effect when qdarktheme applied
def setupTheme(self):
qdarktheme.setup_theme(theme='light', corner_shape="sharp")
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle('Fusion')
mainWindow = Foo()
mainWindow.show()
sys.exit(app.exec())
On my Win10 system when using the dark theme, the title bar still shows "light". I found that setting the WindowText to pure white will force the titlebar to be dark.
palette.setColor(QPalette.WindowText, Qt.white)
Please add Python 3.12 support to https://github.com/5yutan5/PyQtDarkTheme/blob/main/pyproject.toml
In using the examples provided I am able to change the background color to black "background":"#000000" however I cannot get the input color on a QLineEdit to change no matter what I do. I'm not getting any errors, it's just not changing. How does one change multiple colors at once?
I'm using this theme for my PyQt5 application and I'm trying to build the app using PyInstaller but I get this error message:
Traceback (most recent call last):
File "qdarktheme/compile.py", line 18, in compile_stylesheet
File "pathlib.py", line 1242, in open
File "pathlib.py", line 1110, in _opener
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEIYRoBwg/qdarktheme/template.qss'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 1166, in <module>
File "main.py", line 1161, in init_app
File "main.py", line 218, in __init__
File "main.py", line 230, in init_window
File "qdarktheme/resource_manager.py", line 39, in load_stylesheet
File "qdarktheme/compile.py", line 25, in compile_stylesheet
FileNotFoundError:
=======================================================================
Unable to load the QSS file.
QSS file path: /tmp/_MEIYRoBwg/qdarktheme/template.qss
The qss file may be crushed or not installed properly.
Try reinstalling the module again.[pip install qdarktheme]
Also, this module has only been tested on mac and windows.
Operation on other operating systems, such as Linux, is not guaranteed.
=======================================================================
And I want to know if there is a way you could test it and fix it, or guide me to be able to fix it.
(Maybe should I add qdarktheme/templace.qss
as a data in my .spec
file?).
Here's my .spec
file.
I really like this theme and I don't want to change it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.