def on_button_color(self, event): # wxGlade: ElementProperty.<event_handler> button = event.EventObject color = None if 'none' not in button.name: color = button.GetBackgroundColour() rgb = color.GetRGB() color = swizzlecolor(rgb) color = Color(color, 1.0) if 'stroke' in button.name: if color is not None: self.path_element.stroke = color self.path_element.values[SVG_ATTR_STROKE] = color.hex self.path_element.altered() color = wx.Colour(swizzlecolor(self.path_element.stroke)) self.text_name.SetBackgroundColour(color) else: self.path_element.stroke = Color('none') self.path_element.values[SVG_ATTR_STROKE] = 'none' self.path_element.altered() self.text_name.SetBackgroundColour(wx.WHITE) elif 'fill' in button.name: if color is not None: self.path_element.fill = color self.path_element.values[SVG_ATTR_FILL] = color.hex self.path_element.altered() else: self.path_element.fill = Color('none') self.path_element.values[SVG_ATTR_FILL] = 'none' self.path_element.altered() self.path_element.emphasize() self.Refresh() self.device.using('module', 'Console').write('declassify\nclassify\n') self.device.signal('element_property_update', self.path_element) self.device.signal('refresh_scene', 0)
def on_button_layer(self, event): # wxGlade: OperationProperty.<event_handler> data = wx.ColourData() if self.operation.color is not None and self.operation.color != 'none': data.SetColour(wx.Colour(swizzlecolor(self.operation.color))) dlg = wx.ColourDialog(self, data) if dlg.ShowModal() == wx.ID_OK: data = dlg.GetColourData() color = data.GetColour() rgb = color.GetRGB() color = swizzlecolor(rgb) self.operation.color = Color(color, 1.0) self.button_layer_color.SetBackgroundColour(wx.Colour(swizzlecolor(self.operation.color))) self.device.signal('element_property_update', self.operation)
def on_button_color(self, event): # wxGlade: TextProperty.<event_handler> button = event.EventObject color = None if 'none' not in button.name: color = button.GetBackgroundColour() rgb = color.GetRGB() color = swizzlecolor(rgb) color = Color(color, 1.0) if 'stroke' in button.name: if color is not None: self.element.stroke = color self.element.values[SVG_ATTR_STROKE] = color.hex self.element.altered() else: self.element.stroke = Color('none') self.element.values[SVG_ATTR_STROKE] = 'none' self.element.altered() elif 'fill' in button.name: if color is not None: self.element.fill = color self.element.values[SVG_ATTR_FILL] = color.hex self.element.altered() else: self.element.fill = Color('none') self.element.values[SVG_ATTR_FILL] = 'none' self.element.altered() self.update_label() self.refresh() event.Skip()
def on_button_color(self, event): # wxGlade: ElementProperty.<event_handler> button = event.EventObject color = None if 'none' not in button.name: color = button.GetBackgroundColour() rgb = color.GetRGB() color = swizzlecolor(rgb) color = Color(color, 1.0) if 'stroke' in button.name: if color is not None: self.path_element.stroke = color self.path_element.values[SVG_ATTR_STROKE] = color.hex else: self.path_element.stroke = Color('none') self.path_element.values[SVG_ATTR_STROKE] = 'none' elif 'fill' in button.name: if color is not None: self.path_element.fill = color self.path_element.values[SVG_ATTR_FILL] = color.hex else: self.path_element.fill = Color('none') self.path_element.values[SVG_ATTR_FILL] = 'none' if self.kernel is not None: self.kernel.signal("element_property_update", self.path_element) self.kernel.signal("refresh_scene", 0)
def set_widgets(self): if self.operation.operation is not None: op = self.operation.operation if op == "Engrave": self.combo_type.SetSelection(0) elif op == "Cut": self.combo_type.SetSelection(1) elif op == "Raster": self.combo_type.SetSelection(2) elif op == "Image": self.combo_type.SetSelection(3) self.button_layer_color.SetBackgroundColour(wx.Colour(swizzlecolor(self.operation.color))) if self.operation.speed is not None: self.text_speed.SetValue(str(self.operation.speed)) if self.operation.power is not None: self.text_power.SetValue(str(self.operation.power)) if self.operation.dratio is not None: self.text_dratio.SetValue(str(self.operation.dratio)) if self.operation.dratio_custom is not None: self.check_dratio_custom.SetValue(self.operation.dratio_custom) if self.operation.acceleration is not None: self.slider_accel.SetValue(self.operation.acceleration) if self.operation.acceleration_custom is not None: self.checkbox_custom_accel.SetValue(self.operation.acceleration_custom) self.slider_accel.Enable(self.checkbox_custom_accel.GetValue()) if self.operation.raster_step is not None: self.text_raster_step.SetValue(str(self.operation.raster_step)) if self.operation.overscan is not None: self.text_overscan.SetValue(str(self.operation.overscan)) if self.operation.raster_direction is not None: self.combo_raster_direction.SetSelection(self.operation.raster_direction) if self.operation.raster_swing is not None: self.radio_directional_raster.SetSelection(self.operation.raster_swing) if self.operation.raster_preference_top is not None: self.slider_top.SetValue(self.operation.raster_preference_top + 1) if self.operation.raster_preference_left is not None: self.slider_left.SetValue(self.operation.raster_preference_left + 1) if self.operation.raster_preference_right is not None: self.slider_right.SetValue(self.operation.raster_preference_right + 1) if self.operation.raster_preference_bottom is not None: self.slider_bottom.SetValue(self.operation.raster_preference_bottom + 1) if self.operation.advanced is not None: self.checkbox_advanced.SetValue(self.operation.advanced) if self.operation.dot_length_custom is not None: self.check_dot_length_custom.SetValue(self.operation.dot_length_custom) if self.operation.dot_length is not None: self.text_dot_length.SetValue(str(self.operation.dot_length)) if self.operation.group_pulses is not None: self.check_group_pulse.SetValue(self.operation.group_pulses) if self.operation.passes_custom is not None: self.check_passes.SetValue(self.operation.passes_custom) if self.operation.passes is not None: self.text_passes.SetValue(str(self.operation.passes)) if self.operation.output is not None: self.checkbox_output.SetValue(self.operation.output) if self.operation.show is not None: self.checkbox_show.SetValue(self.operation.show) self.on_check_advanced() self.on_combo_operation()
def set_element(self, element): self.path_element = element try: if element.stroke is not None and element.stroke != "none": color = wx.Colour(swizzlecolor(element.stroke)) self.text_name.SetBackgroundColour(color) except AttributeError: pass
def set_widgets(self): try: if self.path_element.stroke is not None and self.path_element.stroke != "none": color = wx.Colour(swizzlecolor(self.path_element.stroke)) self.text_name.SetBackgroundColour(color) except AttributeError: pass self.Refresh()
def update_label(self): element = self.element try: self.label_fonttest.SetFont(element.wxfont) except AttributeError: pass self.label_fonttest.SetLabelText(element.text) self.label_fonttest.SetForegroundColour( wx.Colour(swizzlecolor(element.fill)))
def on_button_color(self, event): # wxGlade: ElementProperty.<event_handler> button = event.EventObject self.text_name.SetBackgroundColour(button.GetBackgroundColour()) self.text_name.Refresh() color = swizzlecolor(button.GetBackgroundColour().GetRGB()) for e in self.element.flat_elements(): e.set_color(color) if self.project is not None: self.project("elements", 0)
def on_button_choose_font(self, event): # wxGlade: TextProperty.<event_handler> font_data = wx.FontData() try: font_data.SetInitialFont(self.element.wxfont) font_data.SetColour(wx.Colour(swizzlecolor(self.element.fill))) dialog = wx.FontDialog(None, font_data) except AttributeError: dialog = wx.FontDialog(None, font_data) if dialog.ShowModal() == wx.ID_OK: data = dialog.GetFontData() font = data.GetChosenFont() color = data.GetColour() rgb = color.GetRGB() color = swizzlecolor(rgb) color = Color(color, 1.0) self.element.wxfont = font self.element.fill = color self.update_label() self.refresh() dialog.Destroy() event.Skip()
def set_project_element(self, project, element): self.project = project self.element = element self.text_name.SetValue(str(element)) props = element.properties if VARIABLE_NAME_SPEED in props: self.spin_speed_set.SetValue(props[VARIABLE_NAME_SPEED]) if VARIABLE_NAME_POWER in props: self.spin_power_set.SetValue(props[VARIABLE_NAME_POWER]) if VARIABLE_NAME_DRATIO in props: self.spin_speed_dratio.SetValue(props[VARIABLE_NAME_DRATIO]) if VARIABLE_NAME_PASSES in props: self.spin_passes.SetValue(props[VARIABLE_NAME_PASSES]) if VARIABLE_NAME_RASTER_STEP in props: self.spin_step_size.SetValue(props[VARIABLE_NAME_RASTER_STEP]) if VARIABLE_NAME_RASTER_DIRECTION in props: self.combo_raster_direction.SetSelection( props[VARIABLE_NAME_RASTER_DIRECTION]) if VARIABLE_NAME_COLOR in props: color = wx.Colour(swizzlecolor(props[VARIABLE_NAME_COLOR])) self.text_name.SetBackgroundColour(color)