def _handle_close(self, kwargs): if kwargs['filename'] == self.filename and kwargs['id_'] == self.id_: # It's necessary to explicitly unbind the handlers, otherwise this # object will never be garbage-collected due to circular # references, and the automatic unbinding won't work wxgui_api.bind_to_apply_editor(self._handle_apply, False) wxgui_api.bind_to_check_editor_modified_state( self._handle_check_editor_modified, False) wxgui_api.bind_to_close_editor(self._handle_close, False)
def handle_close(self, kwargs): if kwargs['filename'] == self.filename and kwargs['id_'] == self.id_: # It's necessary to explicitly unbind the handlers, otherwise this # object will never be garbage-collected due to circular # references, and the automatic unbinding won't work wxgui_api.bind_to_apply_editor(self.handle_apply, False) wxgui_api.bind_to_check_editor_modified_state( self.handle_check_editor_modified, False) wxgui_api.bind_to_close_editor(self.handle_close, False)
def post_init(self): self.target = links_api.find_link_target(self.filename, self.id_) self._init_buttons() self._refresh_mod_state() self.lpanel.Fit() wxgui_api.expand_panel(self.filename, self.id_, self.fpanel) if not self.target: wxgui_api.collapse_panel(self.filename, self.id_, self.fpanel) wxgui_api.bind_to_apply_editor(self._handle_apply) wxgui_api.bind_to_check_editor_modified_state( self._handle_check_editor_modified) wxgui_api.bind_to_close_editor(self._handle_close)
def __init__(self, parent, filename, id_): self.parent = parent self.filename = filename self.id_ = id_ self.panel = wx.Panel(parent.panel) hbox = wx.BoxSizer(wx.HORIZONTAL) self.panel.SetSizer(hbox) # Do not allow multiple selections, so that it's possible to move rules # up and down # Initialize with a small size so that it will expand properly in the # sizer # The list doesn't seem to support TAB traversal if there's only one # rule (but Home/End and PgUp/PgDown do select it) (bug #336) self.listview = wx.ListView(self.panel, size=(1, 1), style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL) self.listview.InsertColumn(0, 'Rules') hbox.Add(self.listview, 1, flag=wx.EXPAND | wx.RIGHT, border=4) self.rules = [] self.mmode = 'append' pbox = wx.BoxSizer(wx.VERTICAL) self.button_add = wx.Button(self.panel, label='&Add...', style=wx.BU_EXACTFIT) pbox.Add(self.button_add, flag=wx.EXPAND | wx.BOTTOM, border=4) self.button_edit = wx.Button(self.panel, label='&Edit...', style=wx.BU_EXACTFIT) pbox.Add(self.button_edit, flag=wx.EXPAND | wx.BOTTOM, border=4) self.button_up = wx.Button(self.panel, label='Move &up', style=wx.BU_EXACTFIT) pbox.Add(self.button_up, flag=wx.EXPAND | wx.BOTTOM, border=4) self.button_down = wx.Button(self.panel, label='Move &down', style=wx.BU_EXACTFIT) pbox.Add(self.button_down, flag=wx.EXPAND | wx.BOTTOM, border=4) self.button_remove = wx.Button(self.panel, label='&Remove', style=wx.BU_EXACTFIT) pbox.Add(self.button_remove, flag=wx.EXPAND) self.update_buttons() hbox.Add(pbox, flag=wx.EXPAND) self.panel.Bind(wx.EVT_BUTTON, self.add_rule, self.button_add) self.panel.Bind(wx.EVT_BUTTON, self.edit_rule, self.button_edit) self.panel.Bind(wx.EVT_BUTTON, self.remove_rule, self.button_remove) self.panel.Bind(wx.EVT_BUTTON, self.move_rule_up, self.button_up) self.panel.Bind(wx.EVT_BUTTON, self.move_rule_down, self.button_down) self.listview.Bind(wx.EVT_LIST_ITEM_SELECTED, self._update_buttons) self.listview.Bind(wx.EVT_LIST_ITEM_DESELECTED, self._update_buttons) wxgui_api.bind_to_apply_editor(self.handle_apply) wxgui_api.bind_to_check_editor_modified_state( self.handle_check_editor_modified) wxgui_api.bind_to_close_editor(self.handle_close)