Python ObserverToolbar Example

说明

python observertoolbar示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Python

命名空间/包名称: plane_widgets_observer_toolbar

示例#1
文件: controller.py项目: nipy/PyLocator

 def __add_observer_widgets_to_window(self,win,hbox):
     win.observers = []
     for orientation, pw in zip(range(3),win.pwxyz.get_plane_widgets_xyz()):
         vboxObs = gtk.VBox()
         vboxObs.show()
         observer = PlaneWidgetObserver(pw, owner=win, orientation=orientation)
         observer.show()
         win.observers.append(observer)
         vboxObs.pack_start(observer, True, True)
         toolbar = ObserverToolbar(observer)
         toolbar.show()
         vboxObs.pack_start(toolbar, False, False)
         hbox.pack_start(vboxObs, True, True)
         observer.observer.AddObserver('InteractionEvent', win.surf_ren_props.interaction_event)

示例#2
文件: plane_widgets.py项目: ashwinashok9111993/pbrain

    def __init__(self, mainWindow, imageData=None):
        gtk.VBox.__init__(self, spacing=3)
        self.mainWindow = mainWindow
        border = 5
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetsXYZ()"
        self.pwxyz = PlaneWidgetsXYZ() #at init, put main data display window behind loading dialog
        self.pwxyz.show()


        print "PlaneWidgetsWithObservers.__init__(): SurfRenderWindow()"
        self.surfRenWin = SurfRenderWindow()
        self.surfRenWin.show()
        
        toolbar = MainToolbar(owner=self)
        toolbar.show() #now show the main toolbar for loading data
        toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL)

        # add MainToolbar to window
        self.pack_start(toolbar, False, False)
        self.mainToolbar = toolbar
        
        toolbarInteractor = InteractorToolbar()
        toolbarInteractor.show()
        toolbarInteractor.set_orientation(gtk.ORIENTATION_VERTICAL)        



        self.dlgSurf = SurfRendererProps(self.surfRenWin, self.pwxyz)

        vboxTools = gtk.VBox()
        vboxTools.show()
        
        hbox = gtk.HBox(spacing=border)
        #hbox.set_border_width(border)
        hbox.show()

        # add InteractorToolbar to vboxTools
        vboxTools.pack_start(toolbarInteractor, True, True)
        # add vboxTools to hbox
        # xxx: mcc
        #self.pack_start(vboxTools, False, False)
        hbox.pack_start(vboxTools, False, True)
        # add hbox to window
        self.pack_start(hbox, True, True)


        # also add a table of x y z translation and dx dy dz rotation values
        """
        hack_table = gtk.VBox()
        
        entry_x = gtk.Entry()
        entry_x.connect("activate", self.translation_changed, 'x')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        entry_x = gtk.Entry()
        entry_x.connect("activate", self.translation_changed, 'y')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        entry_x = gtk.Entry()
        entry_x.connect("activate", self.translation_changed, 'z')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        entry_x = gtk.Entry()
        entry_x.connect("activate", self.rotation_changed, 'x')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        entry_x = gtk.Entry()
        entry_x.connect("activate", self.rotation_changed, 'y')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        entry_x = gtk.Entry()
        entry_x.connect("activate", self.rotation_changed, 'z')
        entry_x.set_text('0')
        entry_x.set_width_chars(6)
        hack_table.pack_start(entry_x, False, False)

        hack_table.show_all()

        hbox.pack_start(hack_table, False, False)
        """

        vbox = gtk.VBox(spacing=border)
        #vbox.set_border_width(border)
        vbox.show()
        # add vbox to hbox
        hbox.pack_start(vbox, True, True)


        hboxUpper = gtk.HBox(spacing=border)
        hboxUpper.show()
        # add PlaneWidgetsXYZ to hboxUpper
        hboxUpper.pack_start(self.pwxyz, True, True)
        # add surfRenderWindow to hboxUpper
        ######################################################################
        ######################################################################
        ######################################################################
        hboxUpper.pack_start(self.surfRenWin, True, True)
        ######################################################################
        ######################################################################
        ######################################################################
        # add hboxUpper to vbox
        vbox.pack_start(hboxUpper, True, True)

        pwx, pwy, pwz = self.pwxyz.get_plane_widgets_xyz()


        hbox = gtk.HBox(spacing=border)
        #hbox.set_border_width(border)
        hbox.show()
        # add hbox to vbox

        ######################################################################
        ######################################################################
        ######################################################################
        vbox.pack_start(hbox, True, True)
        ######################################################################
        ######################################################################
        ######################################################################

        vboxObs = gtk.VBox()
        vboxObs.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwx)"
        self.observerX = PlaneWidgetObserver(pwx, owner=self, orientation=0)
        self.observerX.show()

        # add observerX to vboxObs
        vboxObs.pack_start(self.observerX, True, True)
        toolbarX = ObserverToolbar(self.observerX)
        toolbarX.show()
        # add vboxObs to hbox
        vboxObs.pack_start(toolbarX, False, False)
        hbox.pack_start(vboxObs, True, True)

        vboxObs = gtk.VBox()
        vboxObs.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwy)"
        self.observerY = PlaneWidgetObserver(pwy, owner=self, orientation=1)
        self.observerY.show()
        vboxObs.pack_start(self.observerY, True, True)
        toolbarY = ObserverToolbar(self.observerY)
        toolbarY.show()
        vboxObs.pack_start(toolbarY, False, False)
        # add vboxObs to hbox
        hbox.pack_start(vboxObs, True, True)

        vboxObs = gtk.VBox()
        vboxObs.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwz)"
        self.observerZ = PlaneWidgetObserver(pwz, owner=self, orientation=2)
        self.observerZ.show()
        vboxObs.pack_start(self.observerZ, True, True)
        toolbarZ = ObserverToolbar(self.observerZ)
        toolbarZ.show()
        vboxObs.pack_start(toolbarZ, False, False)
        hbox.pack_start(vboxObs, True, True)


        ### XXX mcc
        """        
        hbox = gtk.HBox(spacing=border)
        hbox.show()
        vbox.pack_start(hbox, True, True)
        vboxObsMRI = gtk.VBox()
        vboxObsMRI.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwx)"
        self.observerX = PlaneWidgetObserverMRI(pwx, owner=self, orientation=0)
        self.observerX.show()
        vboxObsMRI.pack_start(self.observerX, True, True)
        toolbarX = ObserverToolbar(self.observerX)
        toolbarX.show()
        vboxObsMRI.pack_start(toolbarX, False, False)
        hbox.pack_start(vboxObsMRI, True, True)

        vboxObsMRI = gtk.VBox()
        vboxObsMRI.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwy)"
        self.observerY = PlaneWidgetObserverMRI(pwy, owner=self, orientation=1)
        self.observerY.show()
        vboxObsMRI.pack_start(self.observerY, True, True)
        toolbarY = ObserverToolbar(self.observerY)
        toolbarY.show()
        vboxObsMRI.pack_start(toolbarY, False, False)
        hbox.pack_start(vboxObsMRI, True, True)

        vboxObsMRI = gtk.VBox()
        vboxObsMRI.show()
        print "PlaneWidgetsWithObservers.__init__(): PlaneWidgetObserver(pwz)"
        self.observerZ = PlaneWidgetObserverMRI(pwz, owner=self, orientation=2)
        self.observerZ.show()
        vboxObsMRI.pack_start(self.observerZ, True, True)
        toolbarZ = ObserverToolbar(self.observerZ)
        toolbarZ.show()
        vboxObsMRI.pack_start(toolbarZ, False, False)
        hbox.pack_start(vboxObsMRI, True, True)

        ### XXX mcc

        #self.pwxyz.set_size_request(450, 150)
        #self.observerX.set_size_request(150, 150)
        #self.observerY.set_size_request(150, 150)
        #self.observerZ.set_size_request(150, 150)

        # render all observers on interaction events with plane
        # widgets to allow common window level settings
        pwx.AddObserver('InteractionEvent', self.render_observers)
        pwy.AddObserver('InteractionEvent', self.render_observers)
        pwz.AddObserver('InteractionEvent', self.render_observers)
        #self.set_image_data(imageData)
        """
        
        self.observerX.observer.AddObserver('InteractionEvent', self.dlgSurf.interaction_event)
        self.observerY.observer.AddObserver('InteractionEvent', self.dlgSurf.interaction_event)
        self.observerZ.observer.AddObserver('InteractionEvent', self.dlgSurf.interaction_event)

展开阅读全文