0

こんにちは、私は GUI プログラミングに慣れていないので、PyQt を短時間試した後、生産をより簡単にする Enaml を見つけました。

datetime.datetime オブジェクトまたは datetime.time オブジェクトの値を変更できるウィジェットを作成しようとしていますが、読み取り専用であることがわかりました。では、どうすればそれを行うことができますか?変数を読み書き属性に変更したり、setter が必要になったりすることはありますか?

私の最小の実用的な解決策は次のとおりです。

from __future__ import print_function
import datetime
import os

from atom.api import Atom, Unicode, Range, Typed, observe, Value, Bool

class SimulationCase(Atom):

    startDateTime = datetime.datetime.strptime('05.03.2015-5','%d.%m.%Y-%H')
    currentDateTime = startDateTime
    endDateTime = startDateTime+ datetime.timedelta(days=int(5))
    incrementTime = datetime.time(1,0,0)

def main():
    case = SimulationCase()

    print(case.currentDateTime)

    a = datetime.time(1,0,0)
    print(a)

    #This is where the problem occures, comment out the line under for a working solution.
    case.incrementTime = a


if __name__ == '__main__':
    main()
4

2 に答える 2