コード例 #1
0
 def __init__( self, items, row_spacing = 5, column_spacing = 10,
         align = 'l', equalize = '', expand_row = None, expand_column = None,
         padding = ( 0, 0 ), **kwds ):
    Frame.__init__( self )
    self._hpad, self._vpad = padding
    self._num_rows = len( items )
    
    self._num_cols = 0
    
    #make sure we have rows to show
    if self._num_rows > 0:
    
       self._num_cols = max( [len( row ) for row in items] )
       
    #end make sure there are rows to show
    self._col_widths = [0] * self._num_cols
    self._row_heights = [0] * self._num_rows
    
    self._items = items
    self._row_spacing = row_spacing
    self._column_spacing = column_spacing
    self._align = align
    self._equalize = equalize
    self._expand_row = expand_row
    self._expand_column = expand_column
    
    for i, row in enumerate( items ):
       for j, item in enumerate( row ):
          if item:
             self._row_heights[i] = max( self._row_heights[i], item.height )
             self._col_widths[j] = max( self._col_widths[j], item.width )
    self._reset_grid()
    self.set( **kwds )
コード例 #2
0
   def __init__( self,
                 display_team,
                 player_keys,
                 **kwds ):
      """This is the constructor for the team frame."""
      ##
      # @param display_team: The object containing the team to be displayed's
      #                      information.
      #  
      # @param receiver: The object to receive the function calls.
      # 
      # @param function_to_call: The action function to invoke in the 
      #                          receiver when it's time to do something. Since
      #                          this is displaying the contents of a single
      #                          team, the action that needs to be invoked is
      #                          the same for each team.
      # 
      # @param kwds: List of common arguments to pass in to the parent class.
      # 
      
      
      #call the parent init
      Frame.__init__( self, **kwds )
      
      self._display_team = display_team
      
      #pull out the list of players
      self._player_list = display_team.Get_Player_List( )

      #create the frame to contain the manager information
      self._manager_frame = self._Create_Manager_Frame( )

      self._bottom_frame = Frame( container = self,
                                  top = self._manager_frame.height,
                                  anchor = "ltrb",
                                  height = self.height - self._manager_frame.height,
                                  width = self.width )

      self.place( self._manager_frame )
      self.place( self._bottom_frame )

      #the player frame will be the bottom two thirds of the team frame
      self._player_frame = \
         player_frame.Player_Frame( self._player_list,
                                    player_keys,
                                    #container = self._bottom_frame,
                                    container = self,
                                    top = self._manager_frame.height,
                                    #top = 0,
                                    anchor = "ltrb",
                                    #scrolling = "v",
                                    scrolling = "hv",
                                    height = (self.height * 2 / 3),
                                    #height = (50 * len(self._player_list)),
                                    #height = self._bottom_frame.height,
                                    #width = self.width )
                                    #extent = (0, (100 * len(self._player_list))) )
                                    width = self.width,
                                    extent = (750, 500) ) # TODO programatically determine what the scrolling extent needs to be. 
コード例 #3
0
 def __init__( self, title, item, width=None ):
     Frame.__init__( self )
     self.title_label = Label(text=title)
     self.item = item
     self.place_row([self.title_label, self.item],left=0,top=0)
     self.shrink_wrap()
     if width is not None:
         self.width = width
コード例 #4
0
    def __init__( self, directory, callback ):
        Frame.__init__( self )
        self.directory = directory
        self.callback = callback
        self.refs = []
        self.channels = []

        label = Label(text='-----', width=SelectionFrame.width)
        self.label_frame = LabeledItemFrame( "Files:", label )
        self.select_button = Button(title='Select', action=self.select,
                                        width=100)
        field = TextField(text='', width=SelectionFrame.width)
        self.channel_frame = LabeledItemFrame( "Channels:", field )

        self.place_column([self.label_frame, self.select_button,
                           self.channel_frame], left=0, top=0)
        self.shrink_wrap()
コード例 #5
0
 def __init__(self,
              items,
              spacing=10,
              align='l',
              equalize='',
              expand=None,
              padding=(0, 0),
              **kwds):
     Frame.__init__(self)
     hpad, vpad = padding
     if expand is not None and not isinstance(expand, int):
         expand = items.index(expand)
     equalize_components(items, equalize)
     width = 0
     for item in items:
         if item:
             width = max(width, item.width)
     y = vpad
     gap = 0
     vanchor = 't'
     hanchor = align
     for i, item in enumerate(items):
         if item:
             y += gap
             if 'l' in align:
                 x = 0
                 if 'r' in align:
                     item.width = width
             elif align == 'r':
                 x = width - item.width
             else:
                 x = (width - item.width) // 2
             item.position = (x + hpad, y)
             if i == expand:
                 item.anchor = 'tb' + hanchor
                 vanchor = 'b'
             else:
                 item.anchor = vanchor + hanchor
             y += item.height
         if i == expand:
             vanchor = 'b'
         gap = spacing
     self.size = (width + 2 * hpad, y + vpad)
     self.add(items)
     self.set(**kwds)
コード例 #6
0
 def __init__(self,
              items,
              spacing=10,
              align='c',
              equalize='',
              expand=None,
              padding=(0, 0),
              **kwds):
     Frame.__init__(self)
     hpad, vpad = padding
     if expand is not None and not isinstance(expand, int):
         expand = items.index(expand)
     equalize_components(items, equalize)
     height = 0
     for item in items:
         if item:
             height = max(height, item.height)
     x = hpad
     gap = 0
     hanchor = 'l'
     vanchor = align
     for i, item in enumerate(items):
         x += gap
         if item:
             if 't' in align:
                 y = 0
                 if 'b' in align:
                     item.height = height
             elif align == 'b':
                 y = height - item.height
             else:
                 y = (height - item.height) // 2
             item.position = (x, y + vpad)
             if i == expand:
                 item.anchor = 'lr' + vanchor
             else:
                 item.anchor = hanchor + vanchor
             x += item.width
         if i == expand:
             hanchor = 'r'
         gap = spacing
     self.size = (x + hpad, height + 2 * vpad)
     self.add(items)
     self.set(**kwds)
コード例 #7
0
 def __init__(self, items, spacing = 10, align = 'l', equalize = '',
         expand = None, padding = (0, 0), **kwds):
     Frame.__init__(self)
     hpad, vpad = padding
     if expand is not None and not isinstance(expand, int):
         expand = items.index(expand)
     equalize_components(items, equalize)
     width = 0
     for item in items:
         if item:
             width = max(width, item.width)
     y = vpad
     gap = 0
     vanchor = 't'
     hanchor = align
     for i, item in enumerate(items):
         if item:
             y += gap
             if 'l' in align:
                 x = 0
                 if 'r' in align:
                     item.width = width
             elif align == 'r':
                 x = width - item.width
             else:
                 x = (width - item.width) // 2
             item.position = (x + hpad, y)
             if i == expand:
                 item.anchor = 'tb' + hanchor
                 vanchor = 'b'
             else:
                 item.anchor = vanchor + hanchor
             y += item.height
         if i == expand:
             vanchor = 'b'
         gap = spacing
     self.size = (width + 2 * hpad, y + vpad)
     self.add(items)
     self.set(**kwds)
コード例 #8
0
   def __init__( self,
                 offering_team,
                 receiving_team,
                 initial_player = None,
                 **kwds ):
      """This is the constructor for the trade frame."""

      self._offering_team = offering_team
      self._receiving_team = receiving_team
      
      #create defaulted list of players being offered or received
      self._offering_players = {}
      self._receiving_players = {}
      
      #call the parent constructor
      Frame.__init__( self, **kwds )
      
      #if we were given an initial player to be involved in the trade
      if None <> initial_player:
      
         #add this player to the list of receiving players
         self._receiving_players[initial_player.Get_Name( )] = \
            initial_player
コード例 #9
0
ファイル: Row.py プロジェクト: rceballos98/hapticJacket
 def __init__(self, items, spacing=10, align="c", equalize="", expand=None, padding=(0, 0), **kwds):
     Frame.__init__(self)
     hpad, vpad = padding
     if expand is not None and not isinstance(expand, int):
         expand = items.index(expand)
     equalize_components(items, equalize)
     height = 0
     for item in items:
         if item:
             height = max(height, item.height)
     x = hpad
     gap = 0
     hanchor = "l"
     vanchor = align
     for i, item in enumerate(items):
         x += gap
         if item:
             if "t" in align:
                 y = 0
                 if "b" in align:
                     item.height = height
             elif align == "b":
                 y = height - item.height
             else:
                 y = (height - item.height) // 2
             item.position = (x, y + vpad)
             if i == expand:
                 item.anchor = "lr" + vanchor
             else:
                 item.anchor = hanchor + vanchor
             x += item.width
         if i == expand:
             hanchor = "r"
         gap = spacing
     self.size = (x + hpad, height + 2 * vpad)
     self.add(items)
     self.set(**kwds)
コード例 #10
0
ファイル: Grid.py プロジェクト: tomihasa/pygui
 def __init__(self,
              items,
              row_spacing=5,
              column_spacing=10,
              align='l',
              equalize='',
              expand_row=None,
              expand_column=None,
              padding=(0, 0),
              **kwds):
     Frame.__init__(self)
     hpad, vpad = padding
     num_rows = len(items)
     num_cols = max([len(row) for row in items])
     col_widths = [0] * num_cols
     row_heights = [0] * num_rows
     for i, row in enumerate(items):
         for j, item in enumerate(row):
             if item:
                 row_heights[i] = max(row_heights[i], item.height)
                 col_widths[j] = max(col_widths[j], item.width)
     tot_width = 0
     row_top = 0
     row_gap = 0
     vanchor = 't'
     for i, row in enumerate(items):
         row_height = row_heights[i]
         row_top += row_gap
         col_left = 0
         col_gap = 0
         hanchor = 'l'
         if i == expand_row:
             vanchor = 'tb'
         for j, item in enumerate(row):
             col_width = col_widths[j]
             col_left += col_gap
             if item:
                 if 'l' in align:
                     x = 0
                 elif 'r' in align:
                     x = col_width - item.width
                 else:
                     x = (col_width - item.width) // 2
                 if 't' in align:
                     y = 0
                 elif 'b' in align:
                     y = row_height - item.height
                 else:
                     y = (row_height - item.height) // 2
                 item.position = (hpad + col_left + x, vpad + row_top + y)
                 if j == expand_column:
                     item.anchor = 'lr' + vanchor
                 else:
                     item.anchor = hanchor + vanchor
                 self.add(item)
             if j == expand_column:
                 hanchor = 'r'
             col_left += col_width
             col_gap = column_spacing
             tot_width = max(tot_width, col_left)
         if i == expand_row:
             vanchor = 'b'
         row_top += row_height
         row_gap = row_spacing
     tot_height = row_top
     self.size = (tot_width + 2 * hpad, tot_height + 2 * vpad)
     self.set(**kwds)
コード例 #11
0
ファイル: Grid.py プロジェクト: rceballos98/hapticJacket
 def __init__(
     self,
     items,
     row_spacing=5,
     column_spacing=10,
     align="l",
     equalize="",
     expand_row=None,
     expand_column=None,
     padding=(0, 0),
     **kwds
 ):
     Frame.__init__(self)
     hpad, vpad = padding
     num_rows = len(items)
     num_cols = max([len(row) for row in items])
     col_widths = [0] * num_cols
     row_heights = [0] * num_rows
     for i, row in enumerate(items):
         for j, item in enumerate(row):
             if item:
                 row_heights[i] = max(row_heights[i], item.height)
                 col_widths[j] = max(col_widths[j], item.width)
     tot_width = 0
     row_top = 0
     row_gap = 0
     vanchor = "t"
     for i, row in enumerate(items):
         row_height = row_heights[i]
         row_top += row_gap
         col_left = 0
         col_gap = 0
         hanchor = "l"
         if i == expand_row:
             vanchor = "tb"
         for j, item in enumerate(row):
             col_width = col_widths[j]
             col_left += col_gap
             if item:
                 if "l" in align:
                     x = 0
                 elif "r" in align:
                     x = col_width - item.width
                 else:
                     x = (col_width - item.width) // 2
                 if "t" in align:
                     y = 0
                 elif "b" in align:
                     y = row_height - item.height
                 else:
                     y = (row_height - item.height) // 2
                 item.position = (hpad + col_left + x, vpad + row_top + y)
                 if j == expand_column:
                     item.anchor = "lr" + vanchor
                 else:
                     item.anchor = hanchor + vanchor
                 self.add(item)
             if j == expand_column:
                 hanchor = "r"
             col_left += col_width
             col_gap = column_spacing
             tot_width = max(tot_width, col_left)
         if i == expand_row:
             vanchor = "b"
         row_top += row_height
         row_gap = row_spacing
     tot_height = row_top
     self.size = (tot_width + 2 * hpad, tot_height + 2 * vpad)
     self.set(**kwds)