首页 > 其他分享 >IDL学习笔记(5)-IDL中菜单的创建方法

IDL学习笔记(5)-IDL中菜单的创建方法

时间:2023-09-04 15:32:49浏览次数:50  
标签:WIDGET 菜单 menu PRO 笔记 IDL base context event


作者:fbysss
关键字:IDL
一、下拉菜单

pro menutest
base = WIDGET_BASE(MBAR=bar) 
menu1 = WIDGET_BUTTON(bar, VALUE='MENU1', /MENU) 
button1 = WIDGET_BUTTON(menu1, VALUE='ONE') 
button2 = WIDGET_BUTTON(menu1, VALUE='TWO') 
button3 = WIDGET_BUTTON(menu1, VALUE='THREE') 
draw = WIDGET_DRAW(base, XSIZE=100, YSIZE=100) 
WIDGET_CONTROL, base, /REALIZE end


子菜单:

pro submenutest
desc = REPLICATE({ flags:0, name:'' }, 6) 
desc.flags = [ 1, 0, 1, 0, 2, 2 ] 
desc.name = [ 'Operations', 'Predefined', 'Interpolate', $ 
              'Linear', 'Spline', 'Quit' ] 
base = WIDGET_BASE() 
menu = CW_PDMENU(base, desc) 
WIDGET_CONTROL, base, /REALIZE 
end


二、右键菜单
IDL中右键菜单的例子,源码为IDL自带,在命令行中输入.EDIT ontext_tlbase_example.pro即可打开。

PRO CBE_FirstEvent, event
  COMPILE_OPT hidden
  PRINT, ' '
  PRINT, 'Selection 1 Pressed'
END; Event handler routine for the "Selection 2" button on the context menu.
PRO CBE_SecondEvent, event
  COMPILE_OPT hidden
  PRINT, ' '
  PRINT, 'Selection 2 Pressed'
END; Event handler routine for the "Done" button on the context menu.
PRO CBE_DoneEvent, event
  COMPILE_OPT hidden
  PRINT, ' '
  PRINT, 'Done Pressed'
  ; Destroy the top level base.
  WIDGET_CONTROL, event.TOP, /DESTROY
END; Event handler routine for the context menu itself. This routine
; is called when the user right-clicks on the base widget.
PRO context_tlbase_example_event, event  COMPILE_OPT hidden
  ; Obtain the widget ID of the context menu base.
  contextBase = WIDGET_INFO(event.ID, FIND_BY_UNAME = 'contextMenu')  ; Display the context menu and send its events to the
  ; other event handler routines.
  WIDGET_DISPLAYCONTEXTMENU, event.ID, event.X, event.Y, contextBase
END; Main Routine: create the GUI.
PRO context_tlbase_example  ; Initialize the top level (background) base. This base
  ; is configured to generate context events, allowing the user
  ; to right-click on the base to display a context menu.
  topLevelBase = WIDGET_BASE(/COLUMN, XSIZE = 100, YSIZE = 100, /CONTEXT_EVENTS)  ; Initialize the base for the context menu.
  contextBase = WIDGET_BASE(topLevelBase, /CONTEXT_MENU, UNAME = 'contextMenu')  ; Initialize the buttons of the context menu.
  firstButton = WIDGET_BUTTON(contextBase, $
    VALUE = 'Selection 1', EVENT_PRO = 'CBE_FirstEvent')
  secondButton = WIDGET_BUTTON(contextBase, $
    VALUE = 'Selection 2', EVENT_PRO = 'CBE_SecondEvent')
  doneButton = WIDGET_BUTTON(contextBase, VALUE = 'Done', $
    /SEPARATOR, EVENT_PRO = 'CBE_DoneEvent')  ; Display the GUI.
  WIDGET_CONTROL, topLevelBase, /REALIZE  ; Handle the events from the GUI.
  XMANAGER, 'context_tlbase_example', topLevelBaseEND


代码比较简单,跟按钮的处理类似,关键注意黑体部分。
三、其他控件创建LABEL:WIDGET_LABELTEXT:WIDGET_TEXT

标签:WIDGET,菜单,menu,PRO,笔记,IDL,base,context,event
From: https://blog.51cto.com/u_16245757/7351245

相关文章

  • IDL学习笔记(4)-字体设置
    作者:fbysss关键字:IDL   在WIDGET_系列方法中,字体可以使用FONT='宋体*12*bold*Italic'的形式来设置(Widget_Label和Widget_Button都有),但是字体颜色好像没法改变,对于Widget_Button,只能折衷使用BITMAP实现,而Widget_Label就无法了。   IDLgrFont实现方式:myFont=OBJ_NEW('ID......
  • 【学习笔记】AS3快速上手笔记
    作者:fbysss关键字:AS3,ActionScript引言:如果有java、javascript基础,AS语法很好理解,有一个上午足够。看了本文,基本可编写代码调试。1.      开发工具FlashBuilder。新建一个【ActionScript】项目,会自动生成一个as文件,可以直接在里面写代码测试。从结构上看,这个文件是一个类,......
  • Oracle sqlldr笔记
    需求:有两列0X开头的guid,需要合并并转换为10进制数值。控制文件如下:LOADDATAINFILE“/home/xxxdbfile/xxxdb/xxx.txt”truncateINTOTABLExxx_USER.TTTTTTABLEFIELDTERMINATEBY“”TRAILINGNULLCOLS—这个是指如果上面的列中,有空的列载入,不报错(IDsequence(max,1),......
  • java ClassLoader笔记(一)
    作者:fbysss关键字:ClassLoader一、SunJDKClassloader体系1.层次关系Bootstrap:加载rt.jar<-Extension:加载 jre/ext/*.jar <-System:加载CLASSPATH中的jar<-UserDefined加载用户自定义包类2.特殊点  BootstrapClassLoader为C++所写,ExtensionClassLoader的parent为null,其中......
  • Unity UGUI的Dropdown(下拉菜单)组件的介绍及使用
    UnityUGUI的Dropdown(下拉菜单)组件的介绍及使用1.什么是Dropdown组件?Dropdown(下拉菜单)是UnityUGUI中的一个常用组件,用于在用户点击或选择时显示一个下拉菜单,提供多个选项供用户选择。2.Dropdown组件的工作原理Dropdown组件由两部分组成:一个可点击的按钮和一个下拉菜单。当......
  • SpringCloud笔记
    微服务技术栈:                                              ......
  • 【刷题笔记】35. Search Insert Position
    题目Givenasortedarrayandatargetvalue,returntheindexifthetargetisfound.Ifnot,returntheindexwhereitwouldbeifitwereinsertedinorder.Youmayassumenoduplicatesinthearray.Example1:Input:[1,3,5,6],5Output:2Example2:I......
  • FFT & NTT 学习笔记
    FFTFFT是一种高效实现DFT和IDFT的方式,可以在\(O(n\logn)\)的时间内求多项式的乘法。多项式的点值表示不同于用每项的系数来表示一个多项式,我们知道对于给定的\(n+1\)个点值,可以确定唯一的\(n\)次多项式。这种用点值表示多项式的方法叫点值表示法。如果知道\(F(x......
  • c++ opencv 16bit tiff图像学习笔记
    1、读取图像基本信息:长、宽、通道数、灰度最大值、最小值、均值、方差值和灰度直方图#include<opencv2/opencv.hpp>usingnamespacecv;usingnamespacestd;intmain(intargc,char**argv){//读入图像Matsrc=imread("C:\\Users\\MingYi-LZQ\\Desktop\\1......
  • 多线程学习笔记
     1.进程和线程进程是指一个程序,例如QQ,打开会占用一定的内存和空间,会有产生和消亡。线程是由进程创造,一个进程可以有多个线程。单线程:在同一个时刻,只允许执行一个线程。多线程:在同一个时刻,允许执行多个线程。并发:同一时刻,多个任务交替执行,例如一台电脑同时运行qq和迅雷,看着貌似是有......