blob: f3d068a5e670692d032035cc6e2e4804fda2d381 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import os
import random
from paths import Paths
import color_engine
from rich import print
def colorPickerUI(img_path: str) -> tuple:
#display the selected color scheme and ask user if they like it or want to generate a new color scheme
confirmed = False
while not confirmed:
print()
popularColors = color_engine.grabColors(img_path, 3)
hex_colors = color_engine.rgbToHex(popularColors)
hex_compliments = color_engine.compColors(hex_colors)
main_colors = ''
complimentary_colors = ''
for color in hex_colors:
main_colors += f'[on {color}] [/on {color}]'
print(main_colors)
for color in hex_compliments:
complimentary_colors += f'[on {color}] [/on {color}]'
print(complimentary_colors)
print()
count = 0
for i in range(len(hex_colors)):
print(f'[{hex_compliments[i]} on {hex_colors[i]}]\tGenerated Color Scheme\t\t ({count})')
count += 1
print('[bold](a)ccept (r)etry')
response = input('> ')
if response == 'r':
continue
else:
confirmed = True
return hex_colors, hex_compliments
def pickRandomWallpaper() -> str:
confirmed = False
history = []
num_wallpapers = len(os.listdir(Paths['wallpapers']))
while not confirmed:
if len(history) == num_wallpapers:
print('[bold blue] Wallpapers exhausted. Resetting history...')
history.clear()
wallpaper = Paths['wallpapers'] + random.choice(os.listdir(Paths['wallpapers']))
if wallpaper in history:
continue
history.append(wallpaper)
# TODO: Replace image preview with something native to python
# (Currently borrowing viu module from Rust)
os.system(f'viu {wallpaper}')
print(f'picked wallpaper: {wallpaper}')
print('[bold](a)ccept (r)etry')
response = input('>')
if response == 'a':
confirmed = True
return wallpaper
|