Forum Archive

Dark keyboard for ui.textfield/TextView

Webmaster4o

Sorry if I'm missing something, but is this possible? If not, it should be.

omz

If not, it should be.

Agreed. For now:

```python
import ui
from objc_util import ObjCInstance, on_main_thread

@on_main_thread
def set_kb_apperance(view, appearance='dark'):
a = 1 if appearance == 'dark' else 0
if isinstance(view, ui.TextView):
ObjCInstance(tv).setKeyboardAppearance_(a)
elif isinstance(view, ui.TextField):
ObjCInstance(view).subviews()[0].setKeyboardAppearance_(a)
else:
raise TypeError('Expected ui.TextView or ui.TextField')

Webmaster4o

@omz As a follow up, I can't find a way to set the color of the background of a TextField either. The background_color attribute seems to affect the tiny areas behind the rounded corners, but leaves the text entry a glaring white. If you're wondering why I'm asking these questions, I'm trying to bulild a dark-looking UI and having problems.

omz

@Webmaster4o You can set the bordered attribute to False to make the background_color have an effect. You can then use border_width, border_color and corner_radius to emulate the default (rounded rect) style.

Alternatively, you could put a view behind the text field for the background – you might want to do this to customize the padding.

Webmaster4o

Thanks a lot, works like a charm ;)