示例#1
0
	def script_addTextButton(self, r_text, g_text, b_text, r_button, g_button, b_button, button_text, command, data):
		x_text, y_text, w_text, h_text = self._getColoredRect(r_text, g_text, b_text)
		if x_text < 0:
			return
		x_button, y_button, w_button, h_button = self._getColoredRect(r_button, g_button, b_button)
		if x_button < 0:
			return
		from wx.lib.intctrl import IntCtrl
		text = IntCtrl(self, -1)
		text.SetBounds(0, 300)
		text.SetPosition((x_text, y_text))
		text.SetSize((w_text, h_text))
		
		button = wx.Button(self, -1, _(button_text))
		button.SetPosition((x_button, y_button))
		button.SetSize((w_button, h_button))
		button.command = command
		button.data = data
		self._buttonList.append(button)
		self.Bind(wx.EVT_BUTTON, lambda e: command(data % text.GetValue()), button)
class TemperatureField(wx.Panel):
	def __init__(self, parent, callback):
		super(TemperatureField, self).__init__(parent)
		self.callback = callback

		self.SetBackgroundColour(wx.WHITE)

		self.text = IntCtrl(self, -1)
		self.text.SetBounds(0, 300)
		self.text.SetSize((60, 28))

		self.unit = wx.StaticBitmap(self, -1, wx.BitmapFromImage(wx.Image(
				resources.getPathForImage('print-window-temperature-unit.png'))), (0, 0))

		self.button = wx.Button(self, -1, _("Set"))
		self.button.SetSize((35, 25))
		self.Bind(wx.EVT_BUTTON, lambda e: self.callback(self.text.GetValue()), self.button)

		self.text.SetPosition((0, 0))
		self.unit.SetPosition((60, 0))
		self.button.SetPosition((90, 0))