我昨天开始pyforms
,看起来框架的许多部分还没有文档化。你知道吗
我编写了一个应用程序,需要根据需要更改样式。我坚持使用ControlButton.style
而不是CSS
文件。documentation没有提供如何使用style
属性,因此我的尝试失败。它没有任何效果。你知道吗
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)
注意:
将样式用作方法失败,并出现错误
self._directory.style('background-color:green')
AttributeError: 'ControlText' object has no attribute 'style'
目前没有回答
相关问题 更多 >
编程相关推荐