def on_frame_closed(self, e = None): if hasattr(profile, 'localprefs'): profile.localprefs['advanced_prefs.filter'] = self.filter_txt.Value self.prefs.remove_observer(self.pref_changed) if getattr(self, '_did_change_pref', False): profile.save('prefs') e.Skip(True)
def on_frame_closed(self, e=None): if hasattr(profile, 'localprefs'): profile.localprefs['advanced_prefs.filter'] = self.filter_txt.Value self.prefs.remove_observer(self.pref_changed) if getattr(self, '_did_change_pref', False): profile.save('prefs') e.Skip(True)
def construct_gui(self): # create and setup the fiter text box if hasattr(profile, 'localprefs'): filter = profile.localprefs.get('advanced_prefs.filter', u'') else: filter = u'' self.filter_txt = wx.TextCtrl(self, -1, filter) [ self.filter_txt.Bind(e, m) for e, m in [( wx.EVT_TEXT, self.on_filter_txt), (wx.EVT_KEY_DOWN, self.on_filter_text_key)] ] # create and setup the preferences list control self.prefs_list = PrefsListCtrl(self) for e, m in [(wx.EVT_LIST_ITEM_ACTIVATED, self.on_dclick), (wx.EVT_LIST_COL_CLICK, self.on_col_click), (wx.EVT_RIGHT_UP, self.on_right_up), (wx.EVT_RIGHT_DOWN, self.on_right_down)]: self.prefs_list.Bind(e, m) # insert columns for i in xrange(len(self.columns)): self.prefs_list.InsertColumn(i, self.columns[i]) self.show_all = wx.Button(self, -1, "Sho&w All") self.show_all.Bind( wx.EVT_BUTTON, lambda e: self.filter_txt.SetValue('') if self.filter_txt.GetValue() != '' else None) self.add_new = wx.Button(self, -1, '&Add') self.add_new.Bind(wx.EVT_BUTTON, self.add_new_pref) self.push_now = wx.Button(self, -1, '&Push Now') self.push_now.Bind(wx.EVT_BUTTON, lambda e: profile.save('prefs')) # layout components hbox = wx.BoxSizer(HORIZONTAL) hbox.AddMany([(wx.StaticText(self, -1, "Filter:", style=ALIGN_CENTER), 0, TOP | LEFT | BOTTOM | ALIGN_CENTER, 8), (self.filter_txt, 100, EXPAND | ALL, 8), (self.show_all, 0, TOP | BOTTOM, 8), (self.add_new, 0, TOP | BOTTOM | RIGHT, 8)]) vbox = wx.BoxSizer(VERTICAL) vbox.AddMany([(hbox, 0, EXPAND), (self.prefs_list, 1, EXPAND), (self.push_now, 0, ALL | ALIGN_RIGHT, 8)]) self.SetSizer(vbox) def foo(e): print e self.Bind(wx.EVT_BUTTON, foo)
def on_close(self, e): self.Hide() e.Skip() # will Destroy the dialog from common import profile profile.prefs.remove_observer(self.incoming_network_prefs) self.exithooks() for panel in self.loaded_panels.itervalues(): if hasattr(panel, 'on_close'): with traceguard: panel.on_close() profile.save('prefs') profile.save('notifications') from gui.native import memory_event memory_event()
def construct_gui(self): # create and setup the fiter text box if hasattr(profile, 'localprefs'): filter = profile.localprefs.get('advanced_prefs.filter', u'') else: filter = u'' self.filter_txt = wx.TextCtrl(self, -1, filter) [self.filter_txt.Bind(e,m) for e,m in [ (wx.EVT_TEXT, self.on_filter_txt), (wx.EVT_KEY_DOWN, self.on_filter_text_key) ]] # create and setup the preferences list control self.prefs_list = PrefsListCtrl(self) for e, m in [(wx.EVT_LIST_ITEM_ACTIVATED, self.on_dclick), (wx.EVT_LIST_COL_CLICK, self.on_col_click), (wx.EVT_RIGHT_UP, self.on_right_up), (wx.EVT_RIGHT_DOWN, self.on_right_down)]: self.prefs_list.Bind(e, m) # insert columns for i in xrange(len(self.columns)): self.prefs_list.InsertColumn(i, self.columns[i]) self.show_all = wx.Button(self, -1, "Sho&w All") self.show_all.Bind(wx.EVT_BUTTON, lambda e: self.filter_txt.SetValue('') if self.filter_txt.GetValue() != '' else None) self.add_new = wx.Button(self, -1, '&Add') self.add_new.Bind(wx.EVT_BUTTON, self.add_new_pref) self.push_now = wx.Button(self, -1, '&Push Now') self.push_now.Bind(wx.EVT_BUTTON, lambda e: profile.save('prefs')) # layout components hbox = wx.BoxSizer(HORIZONTAL) hbox.AddMany([(wx.StaticText(self, -1, "Filter:", style=ALIGN_CENTER), 0, TOP | LEFT | BOTTOM | ALIGN_CENTER, 8), (self.filter_txt, 100, EXPAND | ALL, 8), (self.show_all, 0, TOP | BOTTOM, 8), (self.add_new, 0, TOP | BOTTOM | RIGHT, 8)]) vbox = wx.BoxSizer(VERTICAL) vbox.AddMany([(hbox, 0, EXPAND), (self.prefs_list, 1, EXPAND), (self.push_now, 0, ALL | ALIGN_RIGHT, 8)]) self.SetSizer(vbox) def foo(e): print e self.Bind(wx.EVT_BUTTON, foo)
def _on_timer(self, timer_name): t = getattr(self, timer_name, None) if t is not None: t.stop() if timer_name == 'network_timer': log.info('timer fired. saving buddylist blob...') netcall(lambda: profile.save('buddylist')) elif timer_name == 'tofrom_timer': log.info('local timer fired. saving tofrom to disk') wx.CallAfter(self.save_local_data) else: assert False, 'invalid timer name'