コード例 #1
0
ファイル: DataTool.py プロジェクト: sarkartanzil/admin4
    def __init__(self, parent, tableSpecs):
        Grid.__init__(self, parent)
        self.frame = parent
        self.table = None
        pt = parent.GetFont().GetPointSize()
        if wx.Platform != "__WXMSW__":
            pt *= 0.95  # a little smaller
        font = wx.Font(pt, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL)
        self.SetDefaultCellFont(font)
        self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnChangeColSize)

        self.tableSpecs = tableSpecs
        self.lastRow = -1
        #    self.node=node
        self.deferredChange = False
        self.dirty = False

        self.dataTypes = []

        for cd in self.tableSpecs.colSpecs.values():
            if cd.category == 'B':
                cd.type = self.RegisterDataType('bool:Null', None,
                                                wx.grid.GRID_VALUE_BOOL)
            elif cd.category == 'N':
                if cd.pgtype in ['real', 'double precision']:
                    cd.type = wx.grid.GRID_VALUE_FLOAT
                elif cd.pgtype in ['numeric']:
                    cd.type = wx.grid.GRID_VALUE_NUMBER
                else:
                    cd.type = wx.grid.GRID_VALUE_LONG
            elif cd.category == 'E':
                cd.type = "ENUM:%s" % cd.pgtype
                if not cd.notNull:
                    cd.type += ":Null"
                if cd.type not in self.dataTypes:
                    query = pgQuery("pg_enum", self.tableSpecs.GetCursor())
                    query.AddCol("enumlabel")
                    if self.tableSpecs.serverVersion > 9.1:
                        query.addOrder("enumsortorder")
                    query.AddWhere('enumtypid', cd.typoid)
                    enum = []
                    if not cd.notNull:
                        enum.append("")
                    for row in query.Select():
                        enum.append(row['enumlabel'])
                    editor = wx.grid.GridCellChoiceEditor(enum)
                    self.RegisterDataType(cd.type, wx.grid.GRID_VALUE_CHOICE,
                                          editor)
            else:
                cd.type = wx.grid.GRID_VALUE_STRING

        self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
        self.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
        self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
        self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
        self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelDclick)
        self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
        self.Bind(wx.grid.EVT_GRID_CELL_CHANGED, self.OnCellChanged)
コード例 #2
0
ファイル: DataTool.py プロジェクト: andreas-p/admin4
  def __init__(self, parent, tableSpecs):
    Grid.__init__(self, parent)
    self.frame=parent
    self.table=None
    pt=parent.GetFont().GetPointSize()
    if wx.Platform != "__WXMSW__":
      pt *= 0.95  # a little smaller
    font=wx.Font(pt, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL)
    self.SetDefaultCellFont(font)
    self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnChangeColSize)

    self.tableSpecs=tableSpecs
    self.lastRow=-1
#    self.node=node
    self.deferredChange=False
    self.dirty=False

    
    self.dataTypes=[]
    
    for cd in self.tableSpecs.colSpecs.values():
      if cd.category == 'B':
        cd.type = self.RegisterDataType('bool:Null', None, wx.grid.GRID_VALUE_BOOL)
      elif cd.category == 'N':
        if cd.pgtype in ['real', 'double precision']:
          cd.type=wx.grid.GRID_VALUE_FLOAT
        elif cd.pgtype in ['numeric']:
          cd.type=wx.grid.GRID_VALUE_NUMBER
        else:
          cd.type=wx.grid.GRID_VALUE_LONG
      elif cd.category == 'E':
        cd.type="ENUM:%s" % cd.pgtype
        if not cd.notNull:
          cd.type += ":Null"
        if cd.type not in self.dataTypes:
          query=pgQuery("pg_enum", self.tableSpecs.GetCursor())
          query.AddCol("enumlabel")
          if self.tableSpecs.serverVersion > 9.1:
            query.addOrder("enumsortorder")
          query.AddWhere('enumtypid', cd.typoid)
          enum=[]
          if not cd.notNull:
            enum.append("")
          for row in query.Select():
            enum.append(row['enumlabel'])
          editor=wx.grid.GridCellChoiceEditor(enum)
          self.RegisterDataType(cd.type, wx.grid.GRID_VALUE_CHOICE, editor)
      else:
        cd.type= wx.grid.GRID_VALUE_STRING

    self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
    self.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown)
    self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
    self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick)
    self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.OnLabelDclick)
    self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.OnLabelRightClick)
    self.Bind(wx.grid.EVT_GRID_CELL_CHANGED, self.OnCellChanged)
コード例 #3
0
ファイル: QueryTool.py プロジェクト: ed00m/admin4
 def __init__(self, parent):
   Grid.__init__(self, parent)
   self.CreateGrid(0,0)
   self.SetColLabelSize(0)
   self.SetRowLabelSize(0)
   pt=parent.GetFont().GetPointSize()
   if wx.Platform != "__WXMSW__":
     pt *= 0.95  # a little smaller
   font=wx.Font(pt, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL)
   self.SetDefaultCellFont(font)
   self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnChangeColSize)
   self.AutoSize()
コード例 #4
0
 def __init__(self, parent):
   Grid.__init__(self, parent)
   self.CreateGrid(0,0)
   self.SetColLabelSize(0)
   self.SetRowLabelSize(0)
   pt=parent.GetFont().GetPointSize()
   if wx.Platform != "__WXMSW__":
     pt *= 0.95  # a little smaller
   font=wx.Font(pt, wx.FONTFAMILY_TELETYPE, wx.NORMAL, wx.NORMAL)
   self.SetDefaultCellFont(font)
   self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnChangeColSize)
   self.AutoSize()