color_panel.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def init_cmap_popup_menu(self):
        cmap_button_bitmap_height = 10
        cmap_button_bitmap_width = 200
        cmap_menu_bitmap_height = 20
        cmap_menu_bitmap_width = 200
        self.cmap_button_bitmaps = {}
        self.cmap_menu_bitmaps = {}
        for cmap in self.ztv_frame.available_cmaps:
            temp = cm.ScalarMappable(cmap=cmap)
            rgba = temp.to_rgba(np.outer(np.ones(cmap_button_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_button_bitmap_width, dtype=np.uint8)))
            self.cmap_button_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_button_bitmap_width, cmap_button_bitmap_height,
                                                                     np.uint8(np.round(rgba*255)))
            rgba = temp.to_rgba(np.outer(np.ones(cmap_menu_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_menu_bitmap_width, dtype=np.uint8)))
            self.cmap_menu_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_menu_bitmap_width, cmap_menu_bitmap_height,
                                                                   np.uint8(np.round(rgba*255)))
        menu = wx.Menu()
        for cmap in self.ztv_frame.available_cmaps:
            menu_item = menu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap)
            wx.EVT_MENU(menu, self.cmap_to_eventID[cmap], self.on_change_cmap_event)
            if hasattr(menu_item, 'SetBitmap'):
                menu_item.SetBitmap(self.cmap_menu_bitmaps[cmap])
        self.cmap_popup_menu = menu
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号