def close(self): if self.is_shown(): log.debug('Destroying alarm id: {}'.format(self.alarmid)) self.panel.Destroy() # It's necessary to explicitly unbind the handler, otherwise this # object will not be garbage-collected core_api.bind_to_update_item_text(self._update_info, False)
def close(self): if self.is_shown(): log.debug("Destroying alarm id: {}".format(self.alarmid)) self.panel.Destroy() # It's necessary to explicitly unbind the handler, otherwise this # object will not be garbage-collected core_api.bind_to_update_item_text(self._update_info, False)
def main(): create_copy_table() core_api.bind_to_open_database_dirty(handle_open_database_dirty) core_api.bind_to_open_database(handle_open_database) core_api.bind_to_close_database(handle_close_database) core_api.bind_to_deleting_item(handle_delete_item) core_api.bind_to_history(handle_history) if coreaux_api.get_extension_configuration('links').get_bool('sync_text'): core_api.bind_to_update_item_text(handle_update_item_text) if copypaste_api: copypaste_api.bind_to_copy_items(handle_copy_items) copypaste_api.bind_to_copy_item(handle_copy_item) copypaste_api.bind_to_paste_item(handle_paste_item) copypaste_api.bind_to_safe_paste_check(handle_safe_paste_check)
def main(): create_copy_table() core_api.bind_to_open_database_dirty(handle_open_database_dirty) core_api.bind_to_open_database(handle_open_database) core_api.bind_to_close_database(handle_close_database) core_api.bind_to_deleting_item(handle_delete_item) core_api.bind_to_history(handle_history) if coreaux_api.get_extension_configuration("links").get_bool("sync_text"): core_api.bind_to_update_item_text(handle_update_item_text) if copypaste_api: copypaste_api.bind_to_copy_items(handle_copy_items) copypaste_api.bind_to_copy_item(handle_copy_item) copypaste_api.bind_to_paste_item(handle_paste_item) copypaste_api.bind_to_safe_paste_check(handle_safe_paste_check)
def _init_widgets(self, parent): hbox = wx.BoxSizer(wx.HORIZONTAL) self.pbox.Add(hbox, flag=wx.EXPAND | wx.ALL, border=4) startdate = wx.StaticText(parent, label=_time.strftime( '%Y.%m.%d %H:%M', _time.localtime(self.start))) hbox.Add(startdate, 1, flag=wx.ALIGN_CENTER_VERTICAL) button_s = wx.Button(parent, label='Snooze', style=wx.BU_EXACTFIT) hbox.Add(button_s) button_d = wx.Button(parent, label='Dismiss', style=wx.BU_EXACTFIT) hbox.Add(button_d, flag=wx.LEFT, border=4) button_e = wx.Button(parent, label='Open', style=wx.BU_EXACTFIT) hbox.Add(button_e, flag=wx.LEFT, border=4) # wx.CP_NO_TLW_RESIZE in conjunction with # self.panel.GetParent().SendSizeEvent() on EVT_COLLAPSIBLEPANE_CHANGED # are necessary for the correct functioning self.pane = wx.CollapsiblePane(parent, style=wx.CP_NO_TLW_RESIZE) # Setting the label directly when instantiating CollapsiblePane through # the 'label' parameter would make it parse '&' characters to form # mnemonic shortcuts, like in menus self._set_pane_label(core_api.get_item_text(self.filename, self.id_)) self.pbox.Add(self.pane, flag=wx.EXPAND | wx.BOTTOM, border=4) self.cpane = self.pane.GetPane() self.cbox = wx.BoxSizer(wx.VERTICAL) self.cpane.SetSizer(self.cbox) line = wx.StaticLine(parent, style=wx.LI_HORIZONTAL) self.pbox.Add(line, flag=wx.EXPAND) core_api.bind_to_update_item_text(self._update_info) self.panel.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self._update_pane_ancestors) self.panel.Bind(wx.EVT_BUTTON, self.snooze, button_s) self.panel.Bind(wx.EVT_BUTTON, self.dismiss, button_d) self.panel.Bind(wx.EVT_BUTTON, self._open, button_e)
def _post_init(self): # The native GTK widget used by DataViewCtrl would have an internal # "live" search feature which steals some keyboard shortcuts: Ctrl+n, # Ctrl+p, Ctrl+f, Ctrl+a, Ctrl+Shift+a # https://groups.google.com/d/msg/wxpython-users/1sUPp766uXU/0J22mUrkzoAJ # Ctrl+f can be recovered with by not overriding the Model's # GetColumnType method # See also bug #349 # See bug #260 for generic issues about DataViewCtrl self.treec = dv.DataViewCtrl(self, style=dv.DV_MULTIPLE | dv.DV_NO_HEADER) self.cmenu = ContextMenu(self) self.ctabmenu = TabContextMenu(self.filename) self.logspanel = logs.LogsPanel(self, self.filename) self.dbhistory = logs.DatabaseHistory(self, self.logspanel, self.logspanel.get_panel(), self.filename, self.treec.GetBackgroundColour()) self.properties = Properties(self.treec) self.base_properties = DBProperties(self.properties) self.accelerators = {} creating_tree_event.signal(filename=self.filename) # Initialize the icons only *after* the various plugins have added # their properties self.properties.post_init() # Initialize the tree only *after* instantiating the class (and # initilizing the icons), because actions like the creation of item # images rely on the filename to be in the dictionary for row in core_api.get_all_items(self.filename): self._init_item_data(row["I_id"], row["I_text"]) self.dvmodel = Model(self.data, self.filename) self.treec.AssociateModel(self.dvmodel) # According to DataViewModel's documentation (as of September 2014) # its reference count must be decreased explicitly to avoid memory # leaks; the wxPython demo, however, doesn't do it, and if done here, # the application crashes with a segfault when closing all databases # See also bug #104 #self.dvmodel.DecRef() dvrenderer = Renderer(self, self.treec) dvcolumn = dv.DataViewColumn("Item", dvrenderer, 0, align=wx.ALIGN_LEFT) self.treec.AppendColumn(dvcolumn) self._init_accelerators() self.Initialize(self.treec) # Initialize the logs panel *after* signalling creating_tree_event, # which is used to add plugin logs self.logspanel.initialize() nb_left = wx.GetApp().nb_left nb_left.add_page(self, os.path.basename(self.filename), select=True) # The logs panel must be shown only *after* adding the page to the # notebook, otherwise *for*some*reason* the databases opened # automatically by the sessions manager (those opened manually aren't # affected) will have the sash of the SplitterWindow not correctly # positioned (only if using SetSashGravity) if wx.GetApp().logs_configuration.is_shown(): self.show_logs() self.history_item_update_requests = [] self.history_tree_reset_request = False # Explicitly set focus on the tree, otherwise after opening a database # no window has focus, and this e.g. prevents F10 from showing the menu # if set on autohide, until a window is manually focused (note that # this would happen only when opening a database manually, it wouldn't # happen when a database is opened automatically by the session # manager) self.treec.SetFocus() self.treec.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU, self._popup_item_menu) core_api.bind_to_insert_item(self._handle_insert_item) core_api.bind_to_update_item_text(self._handle_update_item_text) core_api.bind_to_deleting_item(self._handle_deleting_item) core_api.bind_to_deleted_item_2(self._handle_deleted_item) core_api.bind_to_history_insert(self._handle_history_insert) core_api.bind_to_history_update_simple( self._handle_history_update_simple) core_api.bind_to_history_update_deep(self._handle_history_update_deep) core_api.bind_to_history_update_text(self._handle_history_update_text) core_api.bind_to_history_remove(self._handle_history_remove) core_api.bind_to_history(self._handle_history)