コード例 #1
0
ファイル: wx_main.py プロジェクト: flg8r96/pytesting
class Controller:

  def __init__(self):
    self.timerResetValue = 5
    self.model = Model()

    #set up the first frame which displays the current Model value
    self.view1 = View()
    self.view1.setTimerView(self.model.timerValue)

    #set up the second frame which allows the user to modify the Model's value
    self.view2 = ChangerWidget()
    self.view2.setTimerButtonText(self.timerResetValue)

    self.view1.Show()
    self.view2.Show()

    # Notify MODEL and persist data ...
    pub.subscribe(self.model.startTimer, 'timer_starting')  # when a timer is started
    pub.subscribe(self.model.stopTimer, 'timer_stopping')   # when a timer is stopped
    pub.subscribe(self.model.changeTimer, 'timer_changing') # when a timer changes it's value

  #  self.timerThread(amount=99)
    # Notify VIEW ...
  #  pub.subscribe(self.timerThread, 'timer_counting')   # when a timer changes it's value
    pub.subscribe(self.timerThread, 'timer_starting')   # when a timer starts

  def timerThread(self, amount):
      print "Controller: timerThread being initialized"
      rt = mythread.MyThread(self.timerResetValue, 1, self.model.changeTimer, 1) # it auto-starts, no need of rt.start()
      #rt = mythread.MyThread(5, 1, self.doNothing(), 1)

  def doNothing(self):
      print "Controller: I'm doing nothing"
コード例 #2
0
ファイル: wx_main.py プロジェクト: quanhua92/learning-notes
    def __init__(self):
        self.model = Model()
        self.view1 = View()
        self.view1.setMoney(self.model.myMoney)

        self.view2 = ChangerWidget()

        self.view1.Show()
        self.view2.Show()

        pub.subscribe(self.changeMoney, "money_changing")
コード例 #3
0
  def __init__(self):
    self.model = Model()

    #set up the first frame which displays the current Model value
    self.view1 = View()
    self.view1.setMoney(self.model.myMoney)

    #set up the second frame which allows the user to modify the Model's value
    self.view2 = ChangerWidget()

    self.view1.Show()
    self.view2.Show()

    pub.subscribe(self.changeMoney, 'money_changing')
コード例 #4
0
ファイル: wx_main.py プロジェクト: quanhua92/learning-notes
class Controller:
    def __init__(self):
        self.model = Model()
        self.view1 = View()
        self.view1.setMoney(self.model.myMoney)

        self.view2 = ChangerWidget()

        self.view1.Show()
        self.view2.Show()

        pub.subscribe(self.changeMoney, "money_changing")

    def changeMoney(self, amount):
        if amount > 0:
            self.model.addMoney(amount)
        else:
            self.model.removeMoney(-amount)
コード例 #5
0
class Controller:
    def __init__(self):
        self.model = Model()

        #set up the first frame which displays the current Model value
        self.view1 = View()
        self.view1.setMoney(self.model.myMoney)

        #set up the second frame which allows the user to modify the Model's value
        self.view2 = ChangerWidget()

        self.view1.Show()
        self.view2.Show()

        pub.subscribe(self.changeMoney, 'money_changing')

    def changeMoney(self, amount):
        if amount >= 0:
            self.model.addMoney(amount)
        else:
            self.model.removeMoney(-amount)
コード例 #6
0
ファイル: wx_main.py プロジェクト: schollii/pypubsub
class Controller:
    def __init__(self):
        self.model = Model()

        # set up the first frame which displays the current Model value
        self.view1 = View()
        self.view1.setMoney(self.model.myMoney)

        # set up the second frame which allows the user to modify the Model's value
        self.view2 = ChangerWidget()

        self.view1.Show()
        self.view2.Show()

        pub.subscribe(self.changeMoney, 'money_changing')

    def changeMoney(self, amount):
        if amount >= 0:
            self.model.addMoney(amount)
        else:
            self.model.removeMoney(-amount)
コード例 #7
0
ファイル: wx_main.py プロジェクト: flg8r96/pytesting
  def __init__(self):
    self.timerResetValue = 5
    self.model = Model()

    #set up the first frame which displays the current Model value
    self.view1 = View()
    self.view1.setTimerView(self.model.timerValue)

    #set up the second frame which allows the user to modify the Model's value
    self.view2 = ChangerWidget()
    self.view2.setTimerButtonText(self.timerResetValue)

    self.view1.Show()
    self.view2.Show()

    # Notify MODEL and persist data ...
    pub.subscribe(self.model.startTimer, 'timer_starting')  # when a timer is started
    pub.subscribe(self.model.stopTimer, 'timer_stopping')   # when a timer is stopped
    pub.subscribe(self.model.changeTimer, 'timer_changing') # when a timer changes it's value

  #  self.timerThread(amount=99)
    # Notify VIEW ...
  #  pub.subscribe(self.timerThread, 'timer_counting')   # when a timer changes it's value
    pub.subscribe(self.timerThread, 'timer_starting')   # when a timer starts