;idZddlZddlmZmZmZejdZe de Z e j dZe j dZd Zejed ZejeGd d ejZed Ze eedZeeeddededkrejdSdS)a Demonstrates adding a custom context menu to a GraphicsItem and extending the context menu of a ViewBox. PyQtGraph implements a system that allows each item in a scene to implement its own context menu, and for the menus of its parent items to be automatically displayed as well. N)QtCoreQtGui QtWidgetsT)showzpyqtgraph example: context menuz Zoom to box 1z Zoom to box 2cHttgdSN)items)view autoRangebox1RC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/examples/contextMenu.pyzoomTo1rNN$N     rcHttgdSr)r r box2r rrzoomTo2rrrcJeZdZdZdZdZdZdZdZd dZ d Z d Z d Z dS) MenuBoxz This class draws a rectangular area. Right-clicking inside the area will raise a custom context menu which also includes the context menus of its parents. c||_tjd|_d|_tj|dS)Nr)namepgmkPenpenmenuGraphicsObject__init__)selfrs rrzMenuBox.__init__,s@ 8C==  ""4(((((rc0tjddddS)Nr )rQRectFr s r boundingRectzMenuBox.boundingRect:s}Q2r***rc||j||dSN)setPenrdrawRectr%)r pargss rpaintz MenuBox.paint=s:  4$$&&'''''rc|tjjjkr+||r|dSdSdSr')buttonrQt MouseButton RightButtonraiseContextMenuaccept)r evs rmouseClickEventzMenuBox.mouseClickEventCsV 99;;&)/; ; ;$$R((   < ;  rc t|}||||}|}|t jt|t| dS)NT) getContextMenussceneaddParentContextMenus screenPospopuprQPointintxy)r r4rposs rr2zMenuBox.raiseContextMenuHs##%%zz||11$bAAllnn 6=SUUWWs35577||<<===trNc|jtj|_|j|jdzt jd|j}|j|j |j |||j_ t jd|j}|j|j |j |||j_ tj |j}tj}|t jjj|d|d|j|j|||j |||j_||j_|jS)Nz options..z Turn greenz Turn blue)rrQMenusetTitlerrQAction triggeredconnectsetGreen addActiongreensetBlue QWidgetActionQSlidersetOrientationrr/ Orientation Horizontal setMaximumsetValue valueChangedsetAlphasetDefaultWidgetalpha alphaSlider)r eventrJbluerVrWs rr7zMenuBox.getContextMenusUs 9 !))DI I  ty,6 7 7 7M, ::E O # #DM 2 2 2 I   & & &#DIO=di88D N " "4< 0 0 0 I   % % %"DIO+DI66E#+--K  & &vy'<'G H H H  " "3 ' ' '   % % %  $ , ,T] ; ; ;  " "; / / / I   & & &#DIO$/DI !yrc`tjd|_|dS)Ngrrrupdater$s rrHzMenuBox.setGreenqs"8C== rc`tjd|_|dS)Nbr\r$s rrKzMenuBox.setBluevs"8C== rc6||dz dS)Ngo@) setOpacity)r as rrTzMenuBox.setAlphazs $rr') __name__ __module__ __qualname____doc__rr%r,r5r2r7rHrKrTr rrrr&s ) ) )+++(((    8      rrz Menu Box #1z Menu Box #2g?__main__)rf pyqtgraphr pyqtgraph.QtrrrGraphicsLayoutWidgetwinsetWindowTitle addViewBoxr rrIzoom1zoom2rrFrGrrrr addItemr setParentItemsetPossetScalercexecr rrrvs1111111111b4(((4555 ~~ O,, O,,!!! !!! U U U U U bU U U rw} Tw}4 Aq c z BGIIIIIr