Пример #1
0
	def __init__(self, parent, id, model):
		""" Constructor.
		"""
		wx.Frame.__init__(self, \
						parent, \
						id, \
						size=(120, 30), \
						style=wx.CLIP_CHILDREN|\
								wx.STAY_ON_TOP|\
								wx.FRAME_NO_TASKBAR|\
								wx.NO_BORDER|\
								wx.FRAME_SHAPED)
		Subject.__init__(self)

		### Subject init
		self.canvas = self.GetParent()
		self.__state = {}
		self.attach(model)
		self.attach(self.canvas.GetDiagram())

		#spinCtrl for input and output port numbers
		self._sb_input = wx.SpinCtrl(self, wx.ID_ANY, size=(60,-1), min=0, max=100)
		self._sb_output = wx.SpinCtrl(self, wx.ID_ANY, size=(60,-1), min=0, max=100)

		# mouse positions
		xwindow, ywindow = wx.GetMousePosition()
		xm,ym = self.ScreenToClientXY(xwindow, ywindow)
		self.SetPosition((xm,ym))

		#default value for spinCtrl
		self._sb_input.SetValue(model.input)
		self._sb_output.SetValue(model.output)

		self.__do_layout()
		self.__set_binding()
Пример #2
0
    def __init__(self, parent):
        """ Constructor
		"""

        gridlib.Grid.__init__(self, parent, wx.ID_ANY)
        Subject.__init__(self)

        # local copy
        self.parent = parent

        ### subject init
        self.canvas = self.parent.canvas
        self.__state = {}
        self.attach(self.parent.model)

        # Table setting
        table = CustomDataTable()
        table.Populate(self.parent.model)
        self.SetTable(table, False)

        ### number of row and column from table
        nb_cols = table.GetNumberCols()
        nb_rows = table.GetNumberRows()

        self.SetRowLabelSize(0)
        self.SetMargins(0, 0)
        self.EnableDragRowSize(False)

        ### based on OnSize of AttributeEditor frame
        ### define width of columns from column table number.
        width, height = self.parent.GetSize()
        width /= nb_cols
        for col in range(nb_cols):
            self.SetColSize(col, width)

        for i in xrange(nb_rows):
            self.SetReadOnly(i, 0, True)
            self.SetReadOnly(i, 2, True)
            self.SetCellBackgroundColour(i, 0, "#f1f1f1")

        ### Custom render for display short path name and allows multiline for info
        self.SetDefaultRenderer(CutomGridCellAutoWrapStringRenderer())

        self.Bind(
            gridlib.EVT_GRID_CELL_CHANGE if wx.VERSION_STRING < '4.0' else
            gridlib.EVT_GRID_CELL_CHANGED, self.OnAcceptProp)
        self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectProp)
        self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick)

        # put a tooltip on a column label
        self.GetGridColLabelWindow().Bind(wx.EVT_MOTION,
                                          self.onMouseOverColLabel)
        # put a tooltip on a row label
        self.InstallGridHint(self, table.GetInformation)
	def __init__(self, parent):
		""" Constructor
		"""

		gridlib.Grid.__init__(self, parent, wx.ID_ANY)
		Subject.__init__(self)

		# local copy
		self.parent = parent

		### subject init
		self.canvas = self.parent.canvas
		self.__state = {}
		self.attach(self.parent.model)

		# Table setting
		table = CustomDataTable()
		table.Populate(self.parent.model)
		self.SetTable(table, False)

		### number of row and column from table
		nb_cols = table.GetNumberCols()
		nb_rows = table.GetNumberRows()

		self.SetRowLabelSize(0)
		self.SetMargins(0,0)
		self.EnableDragRowSize(False)

		### based on OnSize of AttributeEditor frame
		### define width of columns from column table number.
		width, height = self.parent.GetSize()
		width /= nb_cols
		for col in range(nb_cols):
			self.SetColSize(col, width)

		for i in xrange(nb_rows):
			self.SetReadOnly(i, 0, True)
			self.SetReadOnly(i, 2, True)
			self.SetCellBackgroundColour(i, 0, "#f1f1f1")

		### Custom render for display short path name and allows multiline for info
		self.SetDefaultRenderer(CutomGridCellAutoWrapStringRenderer())

		self.Bind(gridlib.EVT_GRID_CELL_CHANGE, self.OnAcceptProp)
		self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectProp)
		self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
		self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick)

		# put a tooltip on a column label
		self.GetGridColLabelWindow().Bind(wx.EVT_MOTION,self.onMouseOverColLabel)
		# put a tooltip on a row label
		self.InstallGridHint(self, table.GetInformation)