예제 #1
0
    def _update_widget_properties(self, modified=None):
        # after initial creation, call with modified=None
        if not modified or "create_grid" in modified:
            # block/unblock other properties
            blocked = not self.create_grid
            for name in self._PROPERTIES[2:]:
                self.properties[name].set_blocked(blocked)

        if not self.widget: return

        if not modified or "enable_editing" in modified:
            if modified is None: self.widget.EnableEditing(self.enable_editing)  # set only initially

        def m(name):
            # returns True if an argument is modified and either active or has a default_value
            if modified and not name in modified:
                return False
            if not self.properties[name].is_active() and self.properties[name].default_value is np._DefaultArgument:
                return False
            return True

        # 'simple' properties ##########################################################################################
        if m("row_label_size"):     self.widget.SetRowLabelSize(self.row_label_size)
        if m("col_label_size"):     self.widget.SetColLabelSize(self.col_label_size)
        if m("enable_grid_lines"):  self.widget.EnableGridLines(self.enable_grid_lines)
        if m("enable_col_resize"):  self.widget.EnableDragColSize(self.enable_col_resize)
        if m("enable_row_resize"):  self.widget.EnableDragRowSize(self.enable_row_resize)
        if m("enable_grid_resize"): self.widget.EnableDragGridSize(self.enable_grid_resize)
        if m("lines_color"):        self.widget.SetGridLineColour(misc.string_to_color(self.lines_color))
        if m("label_bg_color"):     self.widget.SetLabelBackgroundColour( misc.string_to_color(self.label_bg_color) )
        if m("selection_mode"):     self.widget.SetSelectionMode(self.selection_mode)

        # columns and rows #############################################################################################
        if m("columns"):
            columns = self.columns
            # adjust number of columns
            delta = len(columns) - self.widget.GetNumberCols()
            if   delta>0: self.widget.AppendCols(delta)
            elif delta<0: self.widget.DeleteCols(0, -delta)
            # set column widths and labels
            for i, (label,size) in enumerate(columns):
                size = int(size or "0") 
                if size>0:
                    self.widget.SetColSize(i, size)
                self.widget.SetColLabelValue(i, label.replace('\\n', '\n'))
        if m("rows"):
            rows = self.rows
            # adjust number of rows
            delta = len(rows) - self.widget.GetNumberRows()
            if   delta>0: self.widget.AppendRows(delta)
            elif delta<0: self.widget.DeleteRows(0, -delta)
            # set row heights and labels
            for i, (label,size) in enumerate(rows):
                size = int(size or "0") 
                if size>0:
                    self.widget.SetRowSize(i, size)
                self.widget.SetRowLabelValue(i, label.replace('\\n', '\n'))

        self.widget.ForceRefresh()
예제 #2
0
 def set_value(self, value):
     value = value.strip()
     if value == "wxNullColour":
         self.use_null_color.SetValue(1)
         self.use_sys_color.SetValue(0)
         self.use_chooser.SetValue(0)
         self.sys_color.Enable(False)
         self.color_chooser.Enable(False)
     elif value in self.colors_dict:
         self.use_sys_color.SetValue(1)
         self.use_chooser.SetValue(0)
         self.use_null_color.SetValue(0)
         self.sys_color.SetValue(value)
         self.sys_color.Enable(True)
         self.color_chooser.Enable(False)
     else:
         self.use_chooser.SetValue(1)
         self.use_sys_color.SetValue(0)
         self.use_null_color.SetValue(0)
         try:
             self.color_chooser.SetValue(misc.string_to_color(value))
         except:
             pass
         self.sys_color.Enable(False)
         self.color_chooser.Enable(True)
예제 #3
0
파일: grid.py 프로젝트: dsqiu/qzystudy
    def create_widget(self):
        self.widget = Grid(self.parent.widget, self.id, (200, 200))
        self.widget.CreateGrid(self.rows_number, len(self.columns))
        if not self.properties['label_bg_color'].is_active():
            self.label_bg_color = misc.color_to_string(
                self.widget.GetLabelBackgroundColour())
            self.properties['label_bg_color'].set_value(self.label_bg_color)
        if not self.properties['lines_color'].is_active():
            self.lines_color = misc.color_to_string(
                self.widget.GetGridLineColour())
            self.properties['lines_color'].set_value(self.lines_color)
        self.widget.SetRowLabelSize(self.row_label_size)
        self.widget.SetColLabelSize(self.col_label_size)
        self.widget.EnableEditing(self.enable_editing)
        self.widget.EnableGridLines(self.enable_grid_lines)
        self.widget.EnableDragColSize(self.enable_col_resize)
        self.widget.EnableDragRowSize(self.enable_row_resize)
        self.widget.EnableDragGridSize(self.enable_grid_resize)
        self.widget.SetGridLineColour(misc.string_to_color(self.lines_color))
        self.widget.SetLabelBackgroundColour(misc.string_to_color(
            self.label_bg_color))
        i = 0
        for l, s in self.columns:
            try: s1 = int(s)
            except: s1 = 0
            self.widget.SetColLabelValue(i, l)
            if s1 > 0:
                self.widget.SetColSize(i, s1)
            i += 1

        self.set_selection_mode(self.selection_mode)
        # following two events are to permit select grid from designer frame
        EVT_GRID_CELL_LEFT_CLICK(self.widget, self.on_set_focus)  
        EVT_GRID_LABEL_LEFT_CLICK(self.widget, self.on_set_focus)
        # these are to show the popup menu on right click
        EVT_GRID_CELL_RIGHT_CLICK(self.widget, self.popup_menu)
        EVT_GRID_LABEL_RIGHT_CLICK(self.widget, self.popup_menu)
예제 #4
0
파일: grid.py 프로젝트: italomaia/spe
    def create_widget(self):
        self.widget = Grid(self.parent.widget, self.id,(200,200))
        self.widget.CreateGrid(self.rows_number, len(self.columns))
        if not self.properties['label_bg_color'].is_active():
            self.label_bg_color = misc.color_to_string(
                self.widget.GetLabelBackgroundColour())
            self.properties['label_bg_color'].set_value(self.label_bg_color)
        if not self.properties['lines_color'].is_active():
            self.lines_color = misc.color_to_string(
                self.widget.GetGridLineColour())
            self.properties['lines_color'].set_value(self.lines_color)
        self.widget.SetRowLabelSize(self.row_label_size)
        self.widget.SetColLabelSize(self.col_label_size)
        self.widget.EnableEditing(self.enable_editing)
        self.widget.EnableGridLines(self.enable_grid_lines)
        self.widget.EnableDragColSize(self.enable_col_resize)
        self.widget.EnableDragRowSize(self.enable_row_resize)
        self.widget.EnableDragGridSize(self.enable_grid_resize)
        self.widget.SetGridLineColour(misc.string_to_color(self.lines_color))
        self.widget.SetLabelBackgroundColour(misc.string_to_color(
            self.label_bg_color))
        i = 0
        for l, s in self.columns:
            try: s1 = int(s)
            except: s1 = 0
            self.widget.SetColLabelValue(i, l)
            if s1 > 0:
                self.widget.SetColSize(i, s1)
            i += 1

        self.set_selection_mode(self.selection_mode)
        # following two events are to permit select grid from designer frame
        EVT_GRID_CELL_LEFT_CLICK(self.widget, self.on_set_focus)  
        EVT_GRID_LABEL_LEFT_CLICK(self.widget, self.on_set_focus)
        # these are to show the popup menu on right click
        EVT_GRID_CELL_RIGHT_CLICK(self.widget, self.popup_menu)
        EVT_GRID_LABEL_RIGHT_CLICK(self.widget, self.popup_menu)
예제 #5
0
 def set_value(self, value):
     value = value.strip()
     if value in self.colors_dict:
         self.use_sys_color.SetValue(1)
         self.use_chooser.SetValue(0)
         self.sys_color.SetValue(value)
         self.sys_color.Enable(True)
         self.color_chooser.Enable(False)
     else:
         self.use_chooser.SetValue(1)
         self.use_sys_color.SetValue(0)
         try: self.color_chooser.SetValue(misc.string_to_color(value))
         except: pass
         self.sys_color.Enable(False)
         self.color_chooser.Enable(True)
예제 #6
0
 def set_background(self, value):
     oldval = self.background
     self.background = value        
     if not self.widget: return
     value = value.strip()
     if value in ColorDialogProperty.str_to_colors:
         self.widget.SetBackgroundColour(wx.SystemSettings_GetColour(
             ColorDialogProperty.str_to_colors[value]))
     else:
         try:
             color = misc.string_to_color(value)
             self.widget.SetBackgroundColour(color)
         except:
             self.background = oldval
             self.properties['background'].set_value(self.get_background())
             return
     self.widget.Refresh()
예제 #7
0
 def set_background(self, value):
     oldval = self.background
     self.background = value
     if not self.widget: return
     value = value.strip()
     if value in ColorDialogProperty.str_to_colors:
         self.widget.SetBackgroundColour(
             wx.SystemSettings_GetColour(
                 ColorDialogProperty.str_to_colors[value]))
     else:
         try:
             color = misc.string_to_color(value)
             self.widget.SetBackgroundColour(color)
         except:
             self.background = oldval
             self.properties['background'].set_value(self.get_background())
             return
     self.widget.Refresh()
예제 #8
0
파일: grid.py 프로젝트: dsqiu/qzystudy
 def set_label_bg_color(self, value):
     self.label_bg_color = str(value)
     if self.widget:
         self.widget.SetLabelBackgroundColour(misc.string_to_color(
             self.label_bg_color))
예제 #9
0
파일: grid.py 프로젝트: dsqiu/qzystudy
 def set_lines_color(self, value):
     self.lines_color = str(value)
     if self.widget:
         self.widget.SetGridLineColour(misc.string_to_color(
             self.lines_color))
예제 #10
0
파일: grid.py 프로젝트: italomaia/spe
 def set_label_bg_color(self, value):
     self.label_bg_color = str(value)
     if self.widget:
         self.widget.SetLabelBackgroundColour(misc.string_to_color(
             self.label_bg_color))
예제 #11
0
파일: grid.py 프로젝트: italomaia/spe
 def set_lines_color(self, value):
     self.lines_color = str(value)
     if self.widget:
         self.widget.SetGridLineColour(misc.string_to_color(
             self.lines_color))