Skip to content

Commit cf3e4b4

Browse files
committed
Format files using Ruff
1 parent 2414a10 commit cf3e4b4

9 files changed

+162
-100
lines changed

examples/kivy-example.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
1-
import kivy
21
from kivy.app import App
32
from kivy.lang import Builder
43
from kivy.core.window import Window
5-
Window.clearcolor = (1, 0.5, 0, 0.0)
6-
74
from hPyT import title_bar_color
85

96

10-
root = Builder.load_string('''
7+
Window.clearcolor = (1, 0.5, 0, 0.0)
8+
9+
10+
root = Builder.load_string("""
1111
Label:
1212
markup: True
1313
text:
1414
('[b]Hello[/b] [color=94D000]World[/color]\\n'
1515
'[color=94D000]Hello[/color] [b]World[/b]')
1616
font_size: '64pt'
1717
18-
''')
18+
""")
1919

2020

2121
class TestApp(App):
22-
2322
def build(self):
2423
return root
2524

2625
def on_start(self):
27-
2826
# window parameter ---> self
2927
title_bar_color.set(self, "#ff8000")
30-
28+
3129
return super().on_start()
3230

3331

34-
if __name__ == '__main__':
32+
if __name__ == "__main__":
3533
TestApp().run()
36-

examples/pyQt-example.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
from hPyT import *
1+
from hPyT import (
2+
title_bar,
3+
maximize_button,
4+
minimize_button,
5+
window_flash,
6+
opacity,
7+
rainbow_title_bar,
8+
rainbow_border,
9+
)
210

311
# ---------- PyQT5 ----------
412

@@ -8,27 +16,27 @@
816
app = QtWidgets.QApplication(sys.argv)
917
window = QtWidgets.QWidget()
1018

11-
title_bar.hide(window) # hides title bar
19+
title_bar.hide(window) # hides title bar
1220
# title_bar.unhide(window)
1321

14-
maximize_button.disable(window) # disables maximize button
22+
maximize_button.disable(window) # disables maximize button
1523
# maximize_button.enable(window)
1624

17-
minimize_button.disable(window) # disables minimize button
25+
minimize_button.disable(window) # disables minimize button
1826
# minimize_button.enable(window)
1927

20-
window_flash.flash(window, 10) # flashes the window 10 times
28+
window_flash.flash(window, 10) # flashes the window 10 times
2129
# window_flash.stop(window) # stops flashing immediately
2230

23-
opacity.set(window, 0.5) # sets the opacity of the window to 50%
31+
opacity.set(window, 0.5) # sets the opacity of the window to 50%
2432

25-
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
33+
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
2634
# rainbow_title_bar.stop(window) # stops the rainbow effect on taskbar
2735

28-
rainbow_border.start(window) # starts the rainbow effect on border
36+
rainbow_border.start(window) # starts the rainbow effect on border
2937
# rainbow_border.stop(window) # stops the rainbow effect on border
3038

3139
# check out the readme.md file for other functions
3240

3341
window.show()
34-
sys.exit(app.exec_())
42+
sys.exit(app.exec_())

examples/pyside-example.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
from hPyT import *
1+
from hPyT import (
2+
title_bar,
3+
maximize_button,
4+
minimize_button,
5+
window_flash,
6+
opacity,
7+
rainbow_title_bar,
8+
rainbow_border,
9+
)
210

311
# ---------- PySide2 ----------
412

@@ -8,27 +16,27 @@
816
app = QApplication(sys.argv)
917
window = QWidget()
1018

11-
title_bar.hide(window) # hides title bar
19+
title_bar.hide(window) # hides title bar
1220
# title_bar.unhide(window)
1321

14-
maximize_button.disable(window) # disables maximize button
22+
maximize_button.disable(window) # disables maximize button
1523
# maximize_button.enable(window)
1624

17-
minimize_button.disable(window) # disables minimize button
25+
minimize_button.disable(window) # disables minimize button
1826
# minimize_button.enable(window)
1927

20-
window_flash.flash(window, 10) # flashes the window 10 times
28+
window_flash.flash(window, 10) # flashes the window 10 times
2129
# window_flash.stop(window) # stops flashing immediately
2230

23-
opacity.set(window, 0.5) # sets the opacity of the window to 50%
31+
opacity.set(window, 0.5) # sets the opacity of the window to 50%
2432

25-
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
33+
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
2634
# rainbow_title_bar.stop(window) # stops the rainbow effect on taskbar
2735

28-
rainbow_border.start(window) # starts the rainbow effect on border
36+
rainbow_border.start(window) # starts the rainbow effect on border
2937
# rainbow_border.stop(window) # stops the rainbow effect on border
3038

3139
# check out the readme.md file for other functions
3240

3341
window.show()
34-
app.exec_()
42+
app.exec_()

examples/rainbow-synchronization-example.py

+39-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import sys
22
import os
3+
34
try:
4-
from PyQt6.QtWidgets import QApplication, QProgressBar, QVBoxLayout, QWidget, QPushButton
5+
from PyQt6.QtWidgets import (
6+
QApplication,
7+
QProgressBar,
8+
QVBoxLayout,
9+
QWidget,
10+
QPushButton,
11+
)
512
from PyQt6.QtCore import Qt, QTimer
613
except ImportError:
714
os.system("pip install PyQt6")
8-
from PyQt6.QtWidgets import QApplication, QProgressBar, QVBoxLayout, QWidget, QPushButton
15+
from PyQt6.QtWidgets import (
16+
QApplication,
17+
QProgressBar,
18+
QVBoxLayout,
19+
QWidget,
20+
QPushButton,
21+
)
922
from PyQt6.QtCore import Qt, QTimer
1023
try:
1124
import qdarktheme
@@ -14,6 +27,7 @@
1427
import qdarktheme
1528
from hPyT import rainbow_title_bar
1629

30+
1731
class RainbowProgressBar(QProgressBar):
1832
def __init__(self, *args, interval=int, **kwargs):
1933
super().__init__(*args, **kwargs)
@@ -23,22 +37,27 @@ def __init__(self, *args, interval=int, **kwargs):
2337

2438
def update_color(self):
2539
# get current title bar color from the rainbow_title_bar
26-
r,g,b = rainbow_title_bar.get_current_color()
27-
40+
r, g, b = rainbow_title_bar.get_current_color()
41+
2842
# set the current title bar color as the current progressbar color
29-
self.setStyleSheet(f"QProgressBar::chunk {{ background-color: rgb({r}, {g}, {b}); }}")
43+
self.setStyleSheet(
44+
f"QProgressBar::chunk {{ background-color: rgb({r}, {g}, {b}); }}"
45+
)
46+
3047

3148
class MainWindow(QWidget):
3249
def __init__(self):
3350
super().__init__()
3451
# initialize the window
3552
self.setWindowTitle('"Rainbow ProgressBar" hPyT Sync Example')
3653
self.setGeometry(100, 100, 600, 400)
37-
qdarktheme.setup_theme(theme="dark", custom_colors={"[dark]": {"primary": "#FFFFFF"}})
54+
qdarktheme.setup_theme(
55+
theme="dark", custom_colors={"[dark]": {"primary": "#FFFFFF"}}
56+
)
57+
58+
self.interval = 30 # define the interval for color updates
59+
window = self.window() # define the window for the rainbow title bar
3860

39-
self.interval = 30 # define the interval for color updates
40-
window = self.window() # define the window for the rainbow title bar
41-
4261
# Start the rainbow title bar effect for the winow
4362
rainbow_title_bar.start(window, interval=self.interval)
4463

@@ -47,34 +66,37 @@ def __init__(self):
4766
self.setLayout(layout)
4867

4968
# initialize the custom color changing progress bar class
50-
self.progress_bar = RainbowProgressBar(self, interval=self.interval) # in order to synchronize the colors make sure the rainbow title bar and your custom color changing widget (here: a progressbar) use the same interval for color updates
69+
self.progress_bar = RainbowProgressBar(
70+
self, interval=self.interval
71+
) # in order to synchronize the colors make sure the rainbow title bar and your custom color changing widget (here: a progressbar) use the same interval for color updates
5172
self.progress_bar.setGeometry(50, 50, 500, 50)
5273
self.progress_bar.setRange(0, 100)
53-
74+
5475
# create a button which starts a progress simulation for the progressbar
5576
self.start_button = QPushButton("start")
5677
self.start_button.clicked.connect(self.start_progress_simulation)
57-
78+
5879
# define the layout
5980
layout.addStretch()
6081
layout.addWidget(self.progress_bar, alignment=Qt.AlignmentFlag.AlignVCenter)
6182
layout.addWidget(self.start_button, alignment=Qt.AlignmentFlag.AlignVCenter)
6283
layout.addStretch()
63-
84+
6485
# initialize a timer for the progressbar-progress simulation
6586
self.progress_timer = QTimer()
6687
self.progress_timer.timeout.connect(self.progress_simulation)
67-
88+
6889
def start_progress_simulation(self):
6990
self.pb_value = 0
7091
progress_update_interval = 500
71-
92+
7293
self.progress_timer.start(progress_update_interval)
73-
94+
7495
def progress_simulation(self):
7596
self.pb_value += 5
7697
self.progress_bar.setValue(self.pb_value)
77-
98+
99+
78100
if __name__ == "__main__":
79101
app = QApplication(sys.argv)
80102
window = MainWindow()

examples/tkinter-example.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
1-
from hPyT import *
1+
from hPyT import (
2+
title_bar,
3+
maximize_button,
4+
minimize_button,
5+
window_flash,
6+
opacity,
7+
rainbow_title_bar,
8+
rainbow_border,
9+
maximize_minimize_button,
10+
all_stuffs,
11+
)
212

313
# ---------- Tkinter ----------
414

5-
from customtkinter import *
15+
from customtkinter import CTk
616

717
window = CTk()
818
window.title("hPyT")
919
window.geometry("400x100")
1020

11-
maximize_minimize_button.hide(window) # hides both maximize and minimize button
21+
maximize_minimize_button.hide(window) # hides both maximize and minimize button
1222
# maximize_minimize_button.unhide(window)
1323

14-
all_stuffs.hide(window) # hides close button
24+
all_stuffs.hide(window) # hides close button
1525
# all_stuffs.unhide(window)
1626

17-
title_bar.hide(window) # hides title bar
27+
title_bar.hide(window) # hides title bar
1828
# title_bar.unhide(window)
1929

20-
maximize_button.disable(window) # disables maximize button
30+
maximize_button.disable(window) # disables maximize button
2131
# maximize_button.enable(window)
2232

23-
minimize_button.disable(window) # disables minimize button
33+
minimize_button.disable(window) # disables minimize button
2434
# minimize_button.enable(window)
2535

26-
window_flash.flash(window, 10) # flashes the window 10 times
36+
window_flash.flash(window, 10) # flashes the window 10 times
2737
# window_flash.stop(window) # stops flashing immediately
2838

29-
opacity.set(window, 0.5) # sets the opacity of the window to 50%
39+
opacity.set(window, 0.5) # sets the opacity of the window to 50%
3040

31-
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
41+
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
3242
# rainbow_title_bar.stop(window) # stops the rainbow effect on taskbar
3343

34-
rainbow_border.start(window) # starts the rainbow effect on border
44+
rainbow_border.start(window) # starts the rainbow effect on border
3545
# rainbow_border.stop(window) # stops the rainbow effect on border
3646

3747
# check out the readme.md file for other functions
3848

39-
window.mainloop()
49+
window.mainloop()

examples/wx-example.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
1-
from hPyT import *
1+
from hPyT import (
2+
title_bar,
3+
maximize_button,
4+
minimize_button,
5+
window_flash,
6+
opacity,
7+
rainbow_title_bar,
8+
rainbow_border,
9+
)
210

311
# ---------- wxPython ----------
412

513
import wx
614

715
app = wx.App()
816

9-
window = wx.Frame(parent=None, title='hPyT')
17+
window = wx.Frame(parent=None, title="hPyT")
1018

11-
title_bar.hide(window)
19+
title_bar.hide(window)
1220
# title_bar.unhide(window)
1321

14-
maximize_button.disable(window) # disables maximize button
22+
maximize_button.disable(window) # disables maximize button
1523
# maximize_button.enable(window)
1624

17-
minimize_button.disable(window) # disables minimize button
25+
minimize_button.disable(window) # disables minimize button
1826
# minimize_button.enable(window)
1927

20-
window_flash.flash(window, 10) # flashes the window 10 times
28+
window_flash.flash(window, 10) # flashes the window 10 times
2129
# window_flash.stop(window) # stops flashing immediately
2230

23-
opacity.set(window, 0.5) # sets the opacity of the window to 50%
31+
opacity.set(window, 0.5) # sets the opacity of the window to 50%
2432

25-
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
33+
rainbow_title_bar.start(window) # starts the rainbow effect on taskbar
2634
# rainbow_title_bar.stop(window) # stops the rainbow effect on taskbar
2735

28-
rainbow_border.start(window) # starts the rainbow effect on border
36+
rainbow_border.start(window) # starts the rainbow effect on border
2937
# rainbow_border.stop(window) # stops the rainbow effect on border
3038

3139
# check out the readme.md file for other functions
3240

3341
window.Show()
34-
app.MainLoop()
42+
app.MainLoop()

hPyT/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
"get_accent_color",
4545
]
4646

47-
__version__ = "1.3.3"
47+
__version__ = "1.3.4"

0 commit comments

Comments
 (0)