I started pyforms
yesterday and it looks like many parts of the framework is not documented yet.
I write an application which requires a style change on demand. I insist on using ControlButton.style
and not a CSS
file. The documentation does not provide how to use style
property and my try failed. It does not make any effect.
from pyforms.basewidget import BaseWidget
from pyforms.controls import ControlText
from pyforms.controls import ControlButton
import os
class GUI(BaseWidget):
def __init__(self, *args, **kwargs):
super().__init__('A test')
self.set_margin(10)
self._directory = ControlText('Directory')
self._directory.value = 'C:\\'
self._directory.changed_event = self.referesh_check
self._ok = ControlButton('OK')
self._formset = [ ('_directory', ' ', '_ok') ]
self.referesh_check()
def referesh_check(self):
dirpath = self._directory.value
if os.path.exists(dirpath):
print('found: ', dirpath)
self._directory.style='color:green'
else:
print('not found: ', dirpath)
self._directory.style='color:red'
pass
if __name__ == '__main__':
from pyforms import start_app
start_app(GUI)
Note:
Using style as method fails with an error
self._directory.style('background-color:green')
AttributeError: 'ControlText' object has no attribute 'style'