def init_popup_menu(self):
self.popup_menu_needs_rebuild = False
if self.popup_menu is not None:
self.popup_menu.Destroy()
menu = wx.Menu()
menu.Append(wx.NewId(), 'Cursor mode:').Enable(False)
self.cursor_mode_to_eventID = {}
cmd_num = 1
for cursor_mode in self.popup_menu_cursor_modes:
fxn = self.available_cursor_modes[cursor_mode]['set-to-mode']
wx_id = wx.NewId()
menu.AppendCheckItem(wx_id, ' ' + cursor_mode + '\tCtrl+' + str(cmd_num))
wx.EVT_MENU(menu, wx_id, fxn)
self.cursor_mode_to_eventID[cursor_mode] = wx_id
self.Bind(wx.EVT_MENU, fxn, id=wx_id)
self.accelerator_table.append((wx.ACCEL_CMD, ord(str(cmd_num)), wx_id))
cmd_num += 1
menu.AppendSeparator()
image_cmap_submenu = wx.Menu()
for cmap in self.ztv_frame.available_cmaps:
menu_item = image_cmap_submenu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap)
wx.EVT_MENU(image_cmap_submenu, self.cmap_to_eventID[cmap], self.on_change_cmap_event)
menu_item.SetBitmap(self.cmap_bitmaps[cmap])
menu.AppendMenu(-1, 'Color Maps', image_cmap_submenu)
wx_id = wx.NewId()
self.menu_item_invert_map = menu.AppendCheckItem(wx_id, 'Invert Color Map')
wx.EVT_MENU(menu, wx_id, self.ztv_frame.invert_cmap)
self.menu_item_invert_map.Check(self.ztv_frame.is_cmap_inverted)
image_scaling_submenu = wx.Menu()
for scaling in self.ztv_frame.available_scalings:
menu_item = image_scaling_submenu.AppendCheckItem(self.scaling_to_eventID[scaling], scaling)
wx.EVT_MENU(image_scaling_submenu, self.scaling_to_eventID[scaling], self.on_change_scaling_event)
menu.AppendMenu(-1, 'Scaling', image_scaling_submenu)
menu.AppendSeparator()
self.popup_menu_cur_fits_header_eventID = wx.NewId()
self._append_menu_item(menu, self.popup_menu_cur_fits_header_eventID, 'FITS Header',
self.on_display_cur_fits_header)
self.popup_menu = menu
self.SetAcceleratorTable(wx.AcceleratorTable(self.accelerator_table))
评论列表
文章目录