當前位置: 首頁>>代碼示例>>Python>>正文


Python VPlotContainer.get_preferred_size方法代碼示例

本文整理匯總了Python中chaco.api.VPlotContainer.get_preferred_size方法的典型用法代碼示例。如果您正苦於以下問題:Python VPlotContainer.get_preferred_size方法的具體用法?Python VPlotContainer.get_preferred_size怎麽用?Python VPlotContainer.get_preferred_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chaco.api.VPlotContainer的用法示例。


在下文中一共展示了VPlotContainer.get_preferred_size方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_fit_components

# 需要導入模塊: from chaco.api import VPlotContainer [as 別名]
# 或者: from chaco.api.VPlotContainer import get_preferred_size [as 別名]
    def test_fit_components(self):
        container = VPlotContainer(bounds=[200,300], resizable="v", fit_components="v")
        comp1 = StaticPlotComponent([50,100], padding=5)
        comp2 = StaticPlotComponent([50,120], padding=5)
        container.add(comp1)
        container.add(comp2)
        self.assert_tuple(container.get_preferred_size(), (200,240))
        # The container should not change its size as a result of its fit_components
        # being set.
        self.assert_tuple(container.bounds, (200,300))
        container.bounds = container.get_preferred_size()
        container.do_layout()

        container.padding = 8
        self.assert_tuple(container.get_preferred_size(), (216,256))
        container.do_layout()
        self.assert_tuple(comp1.outer_position, (0,0))
        self.assert_tuple(comp2.outer_position, (0,110))
開發者ID:enthought,項目名稱:chaco,代碼行數:20,代碼來源:plotcontainer_test_case.py

示例2: test_stack_nonresize

# 需要導入模塊: from chaco.api import VPlotContainer [as 別名]
# 或者: from chaco.api.VPlotContainer import get_preferred_size [as 別名]
 def test_stack_nonresize(self):
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80])
     container.add(comp1, comp2, comp3)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (90, 270))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     return
開發者ID:enthought,項目名稱:chaco,代碼行數:15,代碼來源:plotcontainer_test_case.py

示例3: test_stack_one_resize

# 需要導入模塊: from chaco.api import VPlotContainer [as 別名]
# 或者: from chaco.api.VPlotContainer import get_preferred_size [as 別名]
 def test_stack_one_resize(self):
     "Checks stacking with 1 resizable component thrown in"
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80], resizable='hv')
     comp4 = StaticPlotComponent([50,40])
     container.add(comp1, comp2, comp3, comp4)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (80,230))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     self.assert_tuple(comp4.position, (0,260))
     return
開發者ID:enthought,項目名稱:chaco,代碼行數:18,代碼來源:plotcontainer_test_case.py

示例4: UserInterface

# 需要導入模塊: from chaco.api import VPlotContainer [as 別名]
# 或者: from chaco.api.VPlotContainer import get_preferred_size [as 別名]
class UserInterface(HasTraits):
    '''UserInterface Class
    
    GUI for SrXes. Uses traits to watch for user interaction and then adds
    jobs to a queue for processing. 
    '''

    def __init__(self, **kwargs):
        '''Constructor for UserInterface object
        
        Adds panels and plots to a userinterface window.
        '''
        
        super(UserInterface, self).__init__()
        self.add_trait('rawviewer', RawViewer())
        self.add_trait('cpanel', ControlPanel())
        self.add_trait('mdpanel', MetadataPanel())
        self.add_trait('messagelog', MessageLog())

        self.rawviewer.startProcessJob()
        self.cpanel.sync_trait('datalistlength', self.rawviewer)

        self.imagepanel = Instance(Component)
        self.createImagePanel()
        self.rrpanel = Instance(Component)
        self.rrpanel = VPlotContainer(stack_order = 'top_to_bottom',
                                        resizeable='', use_backbuffer=True,
                                        bgcolor='transparent')
        self.rrpanel.get_preferred_size()
    
    

    # TODO: Adjust view
    view = View(
             HSplit(
               VSplit(
                    UItem('imagepanel', editor=ComponentEditor(), padding=0),
                    UItem('mdpanel', style="custom", padding=5, height=85, width=700)
                     ),
               VGroup(
                    UItem('cpanel', style="custom", width=-430, padding=10),
                    UItem('messagelog', style ="custom", width=-430, padding =10),
                    UItem('rrpanel', editor=ComponentEditor(), style='custom')
                     ),
                show_labels=False,
                  ),
            resizable = True,
            height = 0.96, width = 1.0,
            handler = PyXDAHandler(),
            buttons = NoButtons,
            title = 'SrXes',
            icon = LOGO)

    #############################
    # UI Action Handling
    #############################
    @on_trait_change('cpanel.left_arrow', post_init=True)
    def _left_arrow_fired(self):
        '''Left arrow has been pushed
        
        Changes the image display to the left one over if it exists.
        '''
        
        self.rawviewer.jobqueue.put(['updatecache', ['left']])
        return
    
    @on_trait_change('cpanel.right_arrow', post_init=True)
    def _right_arrow_fired(self):
        '''Right arrow has been pushed
        
        Changes the image display to the right one over if it exists.
        '''
        
        self.rawviewer.jobqueue.put(['updatecache', ['right']])
        return
    
    @on_trait_change('cpanel.generate', post_init=True)
    def _generate_fired(self):
        '''Generate Intensity button has been pushed
        
        Creates a reduced representation plot in the GUI.
        '''
        
        self.rawviewer.jobqueue.put(['plotrr', [self.cpanel.rrchoice]])
        time.sleep(0.5)
        self.updateRRPanel(self.cpanel.rrchoice)
        return
    
    @on_trait_change('cpanel.dirpath', post_init=True)
    def _dirpath_changed(self):
        '''Directory path has changed
        
        If there are tiff images in the folder path, they will be loaded and 
        the first image will be plotted to the screen. If there are no tiff
        images or the path is invalid, rawviewer.message will be changed to a
        string explaining the error.
        '''
        
        self.rawviewer.jobqueue.put(['startload', [self.cpanel.dirpath]])
    
#.........這裏部分代碼省略.........
開發者ID:mlange806,項目名稱:pyxda,代碼行數:103,代碼來源:userinterface.py

示例5: UserInterface

# 需要導入模塊: from chaco.api import VPlotContainer [as 別名]
# 或者: from chaco.api.VPlotContainer import get_preferred_size [as 別名]
class UserInterface(HasTraits):
    '''A user interface that handles interactions with the images/data.
    
    |  control -- JobControl object that handles the internal functionality
    |  cpanel -- contains tools to interact with the data, shown in upper right
    |  mdpanel -- contains the metadata for the image, shown in lower left
    |  imagepanel -- contains all of the image related plots, shown on left
    |  rrpanel -- contains the RR plots that have been created, shown on right
    '''

    def __init__(self, **kwargs):
        super(UserInterface, self).__init__()
        self.add_trait('process', ProcessCenter())
        self.add_trait('cpanel', ControlPanel())
        self.add_trait('mdpanel', MetadataPanel())

        self.process.startProcessJob()
        self.cpanel.sync_trait('datalistlength', self.process)
        self.cpanel.sync_trait('message', self.process)

        self.imagepanel = Instance(Component)
        self.createImagePanel()
        self.rrpanel = Instance(Component)
        self.rrpanel = VPlotContainer(stack_order = 'top_to_bottom',
                                        resizeable='', use_backbuffer=True,
                                        bgcolor='transparent')
        self.rrpanel.get_preferred_size()
        return

    view = View(
             HSplit(
               VSplit(
                    UItem('imagepanel', editor=ComponentEditor(), 
                                            padding=0, height=0.825),
                    UItem('mdpanel', style="custom", height=127, width=700,
                                            resizable=True),
                     ),
               VGroup(
                    UItem('cpanel', style="custom", width=-430, padding=10),
                    UItem('rrpanel', editor=ComponentEditor(), style='custom')
                     ),
                show_labels=False,
                  ),
            resizable = True,
            height = 0.95*800, width = 1.0*1280,
            title = 'SrXes',
            icon = ICON
            )

    #############################
    # UI Action Handling
    #############################
    @on_trait_change('cpanel.left_arrow', post_init=True)
    def _left_arrow_fired(self):
        '''Left arrow/key pressed. Sends request to load previous image.'''
        self.process.jobqueue.put(['updatecache', ['left']])
        return
    
    @on_trait_change('cpanel.right_arrow', post_init=True)
    def _right_arrow_fired(self):
        '''Right arrow/key pressed. Sends request to load next image.'''
        self.process.jobqueue.put(['updatecache', ['right']])
        return
    
    @on_trait_change('cpanel.generate', post_init=True)
    def _generate_fired(self):
        '''Generate pressed. Sends request to create specified RR plot.'''
        self.process.jobqueue.put(['plotrr', [self.cpanel.rrchoice]])
        time.sleep(0.5)
        self.updateRRPanel(self.cpanel.rrchoice)
        return
    
    @on_trait_change('cpanel.dirpath', post_init=True)
    def _dirpath_changed(self):
        '''A directory has been chosen. Sends request to start load thread.'''
        self.process.jobqueue.put(['startload', [self.cpanel.dirpath]])
        return
    
    @on_trait_change('process.pic', post_init=True)
    def _pic_changed(self):
        '''Updates the index and metadata when the current image changes.'''
        pic =  self.process.pic
        self.cpanel.index = pic.n + 1
        self.mdpanel.name = pic.name
        if pic.metadata:
            for key in pic.metadata.keys():
                setattr(self.mdpanel, key, pic.metadata[key])
        else:
            for key in self.mdpanel.editable_traits():
                if key != 'name':
                    setattr(self.mdpanel, key, '')
        
        self.imagepanel.invalidate_and_redraw()
        return

    @on_trait_change('process.display.filenum', post_init=True)
    def _filenum_changed(self):
        '''Handles interactions with the RR plots. When a point is hovered
        over, its filename is displayed in the control panel.
        '''
#.........這裏部分代碼省略.........
開發者ID:ericdill,項目名稱:pyxda,代碼行數:103,代碼來源:userinterface.py


注:本文中的chaco.api.VPlotContainer.get_preferred_size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。