From: Justin Nesselrotte Date: Tue, 30 Dec 2014 06:32:26 +0000 (-0600) Subject: Converting temperature spinner to button X-Git-Tag: 14.09-1.18~5^2~11 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=dfc2d00e39f4b7888e26ac0b2c8d0dd63b6c0f2f;p=cura.git Converting temperature spinner to button --- diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 13ac87f5..947f6643 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -53,6 +53,7 @@ class printWindowPlugin(wx.Frame): 'addProgressbar': self.script_addProgressbar, 'addButton': self.script_addButton, 'addSpinner': self.script_addSpinner, + 'addTextButton': self.script_addTextButton, 'sendGCode': self.script_sendGCode, 'connect': self.script_connect, @@ -139,21 +140,43 @@ class printWindowPlugin(wx.Frame): def run_command(spinner): value = spinner.GetValue() - if spinner.last_value != value: - if spinner.last_value != '' and value != 0: - spinner.command(spinner.data % value) + print "Value (%s) and (%s)" % (spinner.last_value, value) + if spinner.last_value != '' and value != 0: + spinner.command(spinner.data % value) spinner.last_value = value spinner = wx.SpinCtrl(self, -1, style=wx.TE_PROCESS_ENTER) spinner.SetRange(0, 300) spinner.SetPosition((x, y)) spinner.SetSize((w, h)) + spinner.SetValue(0) spinner.command = command spinner.data = data spinner.last_value = '' self._buttonList.append(spinner) self.Bind(wx.EVT_SPINCTRL, lambda e: run_command(spinner), spinner) + def script_addTextButton(self, r_text, g_text, b_text, r_button, g_button, b_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, _(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) + def _getColoredRect(self, r, g, b): for x in xrange(0, self._mapImage.GetWidth()): for y in xrange(0, self._mapImage.GetHeight()): diff --git a/plugins/PronterfaceUI/script.py b/plugins/PronterfaceUI/script.py index ab09d68e..705c113a 100644 --- a/plugins/PronterfaceUI/script.py +++ b/plugins/PronterfaceUI/script.py @@ -41,10 +41,8 @@ addColorCommand(240, 255, 0, sendGCode, "G28 X0") addColorCommand(220, 255, 0, sendGCode, "G28 Y0") addColorCommand(200, 255, 0, sendGCode, "G28 Z0") -addSpinner(180, 0, 160, sendGCode, "M104 S%d") -#Hot end temp button RGB is (180, 0, 140) -addSpinner(180, 0, 180, sendGCode, "M140 S%d") -#Bed temp button is (180, 0, 150) +addTextButton(180, 0, 160, 180, 0, 140, 'set', sendGCode, "M104 S%d") +addTextButton(180, 0, 180, 180, 0, 150, 'set', sendGCode, "M140 S%d") addTerminal(255, 0, 255) addTemperatureGraph(180, 0, 255)