Skip to content

Commit f425ebd

Browse files
committed
Updated to v0.2.3 - Added dark theme
1 parent 18c682c commit f425ebd

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

docs/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This file contains changes made to `Python Password` program.
44

5+
## [0.2.3] - 2020-05-18
6+
### Added
7+
- Dark theme. (optional)
8+
## Fixed
9+
- Rewrote most methods to increase stability.
10+
511
## [0.2.2] - 2020-05-16
612
### Added
713
- Tips for new users.
@@ -45,7 +51,8 @@ First usable pre-release.
4551
- Set password option.
4652
- Get password option.
4753

48-
[0.2.2]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.1-alpha
54+
[0.2.3]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.2.3-alpha
55+
[0.2.2]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.2.2-alpha
4956
[0.2.1]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.2.1-alpha
5057
[0.2.0]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.2.0-alpha
5158
[0.1.2]: https://github.com/AnonymousX86/Python-Password/releases/tag/v0.1.2-alpha

python_password/PyPassword.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from cryptography.fernet import InvalidToken
77
from kivy import Config, require as kivy_require
88
from kivy.lang import Builder
9-
from kivy.properties import ObjectProperty, StringProperty
9+
from kivy.properties import ObjectProperty, StringProperty, ListProperty
1010
from kivy.uix.boxlayout import BoxLayout
1111
from kivymd.app import MDApp
1212
from kivymd.uix.button import MDRectangleFlatIconButton, MDRaisedButton, MDFillRoundFlatIconButton, \
@@ -22,6 +22,7 @@
2222

2323
class SimpleDialog:
2424
"""Simple dialogs."""
25+
2526
def __init__(self, title, text, alert_text='OK', **kwargs):
2627
super().__init__(**kwargs)
2728
self.title = title
@@ -62,14 +63,16 @@ def change_screen(self, name):
6263

6364
class PyPassword(MDApp):
6465
"""Main application wrapper."""
66+
6567
def __init__(self, **kwargs):
6668
super().__init__(**kwargs)
67-
69+
self.theme_cls.primary_palette = 'Indigo'
70+
self.theme_cls.theme_style = 'Dark'
71+
self.text_color_hex = 'ffffff'
6872
self.passwords = []
69-
7073
self.info = {
7174
'name': 'Python Password',
72-
'version': '0.2.2',
75+
'version': '0.2.3',
7376
'author': 'Jakub Suchenek',
7477
'github': 'https://github.com/AnonymousX86/Python-Password',
7578
'faq': 'https://github.com/AnonymousX86/Python-Password/blob/master/docs/FAQ.md',
@@ -78,16 +81,18 @@ def __init__(self, **kwargs):
7881
'rd_party': 'UPX, Kivy and KivyMD'
7982
}
8083

84+
# It has to be outside ``__init__``
85+
text_color_hsl = ListProperty([1, 1, 1, 1])
86+
8187
def build(self):
82-
self.theme_cls.primary_palette = 'Indigo'
83-
self.theme_cls.theme_style = 'Light'
8488
with open(f'kv_templates{sep}PyPassword.kv', encoding='utf8') as fd:
8589
kv = Builder.load_string(fd.read())
8690
return kv
8791

8892
def on_start(self):
8993
self.update_passwords_list()
9094
self.masters_ok()
95+
# self.switch_theme()
9196

9297
# ================================
9398
# Information
@@ -96,7 +101,7 @@ def on_start(self):
96101
def ctx_password(self, instance):
97102
"""Shows dialog with options what to do with password."""
98103
ctx_dialog = MDDialog(
99-
title=instance.text.capitalize(),
104+
title=f'[color=#{self.text_color_hex}]{instance.text.capitalize()}[/color]',
100105
text='Choose what do you want to do wth this password.',
101106
auto_dismiss=False,
102107
buttons=[
@@ -128,7 +133,8 @@ def ctx_password(self, instance):
128133
def detailed_info(self, name):
129134
"""Opens dialog about specific info about program in ``info`` screen."""
130135
info_dialog = MDDialog(
131-
title=name.capitalize() if name != 'rd_party' else '3rd party software',
136+
title=f'[color={self.text_color_hex}]' +
137+
(name.capitalize() if name != 'rd_party' else '3rd party software') + '[/color]',
132138
text=self.info[name],
133139
auto_dismiss=False,
134140
buttons=[
@@ -138,8 +144,8 @@ def detailed_info(self, name):
138144
text='Freepik', icon='web',
139145
on_release=lambda x:
140146
self.open_url('https://www.freepik.com/')
141-
) if name == 'icon' else None,
142-
]
147+
) if name == 'icon' else None
148+
]
143149
)
144150
info_dialog.open()
145151

@@ -488,13 +494,22 @@ def update_passwords_list(self):
488494
# Misc
489495
# ================================
490496

491-
def switch_theme(self):
492-
current = self.theme_cls.theme_style
493-
if current == 'Light':
494-
set_to = 'Dark'
497+
def switch_theme(self, force=None):
498+
if force is not None:
499+
self.theme_cls.theme_style = force
500+
501+
elif self.theme_cls.theme_style == 'Light':
502+
self.theme_cls.theme_style = 'Dark'
503+
self.text_color_hex = 'ffffff'
504+
self.text_color_hsl = (1, 1, 1, 1)
505+
506+
elif self.theme_cls.theme_style == 'Dark':
507+
self.theme_cls.theme_style = 'Light'
508+
self.text_color_hex = '111111'
509+
self.text_color_hsl = (.06, .06, .06, 1)
510+
495511
else:
496-
set_to = 'Light'
497-
self.theme_cls.theme_style = set_to
512+
raise NameError('No theme found')
498513

499514
def open_url(self, url):
500515
open_new_tab(url)
@@ -523,7 +538,7 @@ def validate_input(self, instance, length):
523538

524539
Config.set('kivy', 'log_dir', appdata(f'.{sep}logs{sep}'))
525540
Config.set('kivy', 'log_enable', 1)
526-
Config.set('kivy', 'log_level', 'debug')
541+
Config.set('kivy', 'log_level', 'warning')
527542
Config.set('kivy', 'log_maxfiles', 10)
528543

529544
Config.write()

python_password/kv_templates/PyPassword.kv

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
MDLabel:
77
text: 'Python Password'
88
font_style: 'Button'
9+
theme_text_color: 'Primary'
910
size_hint_y: None
1011
height: self.texture_size[1]
1112

1213
MDLabel:
1314
text: 'v{0}'.format(app.info['version'])
1415
font_style: 'Caption'
16+
theme_text_color: 'Primary'
1517
size_hint_y: None
1618
height: self.texture_size[1]
1719

@@ -40,6 +42,13 @@
4042
IconLeftWidget:
4143
icon: 'information-outline'
4244

45+
MDRoundFlatIconButton:
46+
text: 'Switch theme'
47+
background_palette: 'Primary'
48+
text_color: app.text_color_hsl
49+
icon: 'theme-light-dark'
50+
on_release: app.switch_theme()
51+
4352
<NewbieTip>:
4453
IconLeftWidget:
4554
icon: root.icon
@@ -132,6 +141,7 @@ Screen:
132141
MDLabel:
133142
id: passwords_count
134143
text: ''
144+
theme_text_color: 'Primary'
135145
halign: 'center'
136146
valign: 'middle'
137147

@@ -158,6 +168,7 @@ Screen:
158168

159169
MDLabel:
160170
text: 'Change alpha password'
171+
theme_text_color: 'Primary'
161172
halign: 'center'
162173

163174
BoxLayout:
@@ -197,6 +208,7 @@ Screen:
197208

198209
MDLabel:
199210
text: 'Change beta password'
211+
theme_text_color: 'Primary'
200212
halign: 'center'
201213

202214
BoxLayout:
@@ -265,6 +277,7 @@ Screen:
265277

266278
MDLabel:
267279
text: 'About the program'
280+
theme_text_color: 'Primary'
268281
size_hint: (1, None)
269282
height: '30dp'
270283
valign: 'middle'
@@ -302,6 +315,7 @@ Screen:
302315

303316
MDLabel:
304317
text: 'Useful links'
318+
theme_text_color: 'Primary'
305319
size_hint: (1, None)
306320
height: '30dp'
307321

0 commit comments

Comments
 (0)