-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrename_interactor.py
54 lines (45 loc) · 1.84 KB
/
rename_interactor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Name rename_interactor.py
Author David Edmondson, adapted from sample by Peter Damoc
Interactor binds event handlers to the View, and calls methods in the Presenter,
which strips nearly all logic from the visual part of the UI.
"""
import wx
class Interactor(object):
def install(self, presenter, view):
self.presenter = presenter
self.view = view
self.view.Bind(wx.EVT_CLOSE, self.onQuit)
self.view.Bind(wx.EVT_MENU, self.onQuit, self.view.menuFileQuit)
self.view.Bind(wx.EVT_MENU, self.onOpenDir, self.view.menuFileOpen)
# TODO: Get me some help!
#self.view.Bind(wx.EVT_MENU, self.onOpenHelp, self.view.menuHelpHelp)
self.view.Bind(wx.EVT_MENU, self.onOpenAbout, self.view.menuHelpAbout)
self.view._comboBoxDelimiter.Bind(
wx.EVT_COMBOBOX, self.onSettingChanged)
self.view._checkboxFlickr.Bind(
wx.EVT_CHECKBOX, self.onSettingChanged)
self.view._checkboxCapital.Bind(
wx.EVT_CHECKBOX, self.onSettingChanged)
self.view.buttonOpen.Bind(
wx.EVT_BUTTON, self.onOpenDir)
self.view.buttonRename.Bind(
wx.EVT_BUTTON, self.onRenameClicked)
def onQuit(self, e):
"""Open a close program confirmation"""
self.presenter.quit()
def onOpenDir(self, e):
"""Open the Select Folder dialog."""
self.presenter.openPath()
def onRenameClicked(self, e):
"""Renames all displayed files."""
self.presenter.renameFiles()
def onSettingChanged(self, e):
"""Update model whenever settings are changed"""
self.presenter.settingsChanged()
def onOpenAbout(self, e):
"""Opens the About box."""
self.presenter.openAbout()
def onOpenHelp(self, e):
"""Opens the Help window."""
self.presenter.openHelp()