我阅读了Kivy教程,但无法找到如何禁用窗口小部件(例如,按钮).
def foo(self, instance, *args):
#... main business logic, and then
instance.disable = False
# type(instance) = kivy.uix.Button
Run Code Online (Sandbox Code Playgroud)
我结合foo使用functools.partial.
什么是正确的参数?
我想用Delphi实现观察者模式.这是一个接口ISubject和一个TWeatherData实现观察者的类.
ISubject = interface
procedure notifyObservers;
procedure removeObserver(o: IObserver);
procedure registerObserver(o: IObserver);
end;
TWeatherData = class(TInterfacedObject, ISubject)
private
observers: TList;
FTemperature: Double;
FHumidity: Double;
FPressure: Double;
public
// ...
procedure notifyObservers;
procedure setMeasurements(ATemperature, AHumidity, APressure: Double);
end;
Run Code Online (Sandbox Code Playgroud)
我得到一个访问冲突有关的读取地址的时候TWeatherData.notifyObservers执行
procedure TWeatherData.notifyObservers;
var
observer: ^IObserver;
begin
for observer in observers do
observer.Update(FTemperature, FHumidity, FPressure); //oops -> there raised AV.
end;
procedure TWeatherData.setMeasurements(ATemperature, AHumidity,
APressure: Double);
begin
measurementsChanged; // and this one calls …Run Code Online (Sandbox Code Playgroud) 再会,
我第一次出现这种错误。
// another.h
struct Item {
QString name = QString();
QString description = QString();
QVariant value = QVariant();
struct Interface {
uint id = 0;
uint pos = 0;
} mkio, uks;
struct Element {
float weight = 0;
struct Range {
uint from = 0;
uint to = 0;
} range;
int index = 0;
} element;
};
Run Code Online (Sandbox Code Playgroud)
我想将此嵌套结构存储在流中。所以,
// another.h
QDataStream &operator<<(QDataStream &out, const Item::Interface &interface)
{
return out << interface.id
<< interface.pos;
}
// and another …Run Code Online (Sandbox Code Playgroud) 美好的一天,
我有课
TMn2Adapter = class(TPersistent)
private
FGrid: TStringGridPointer;
FList: TList<string>;
// ...
public
constructor Create(AGrid: TStringGridPointer);
destructor Destroy();
end;
constructor TMn2Adapter.Create(AGrid: TStringGridPointer);
begin
FGrid := AGrid;
FList := TList<string>.Create();
end;
destructor TMn2Adapter.Destroy;
begin
Dispose(FGrid);
FList.Free;
FList := nil;
inherited;
end;
Run Code Online (Sandbox Code Playgroud)
还有一个
TMn2Worker = class(TPersistent)
private
FMn2Adapter: TMn2Adapter;
public
constructor Create(AGrid: TStringGridPointer);
destructor Destroy();
end;
constructor TMn2Worker.Create(AGrid: TStringGridPointer);
begin
FMn2Adapter := TMn2Adapter.Create(AGrid);
end;
destructor TMn2Worker.Destroy;
begin
SysUtils.FreeAndNil(FMn2Adapter);
inherited;
end;
procedure TMn2Adapter.Parse;
begin
FList.Clear();
for I := 1 to FLenght do FList.Add((FGrid)^.Cells[2, …Run Code Online (Sandbox Code Playgroud)