chiark / gitweb /
Converting temperature spinner to button
authorJustin Nesselrotte <jnesselr@harding.edu>
Tue, 30 Dec 2014 06:32:26 +0000 (00:32 -0600)
committerSteven Abadie <steven@alephobjects.com>
Tue, 30 Dec 2014 22:34:11 +0000 (15:34 -0700)
Cura/gui/printWindow.py
plugins/PronterfaceUI/script.py

index 13ac87f57ae21660f2219297bc81193632718922..947f6643961d6576b6ba365afb724671937fb21c 100644 (file)
@@ -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()):
index ab09d68e9d19cfb0cf8d8703e98a7853d786ddb6..705c113a1302ef37e69eec5ee183d7f5b1299813 100644 (file)
@@ -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)