def __init__(self):
		self._print_profiles = []
		self._material_profiles = []
		self._material_in_print_profile = False
		for filename in resources.getSimpleModeProfiles(profile.getMachineSetting('machine_type')):
			pi = ProfileInfo(filename)
			self._print_profiles.append(pi)
			if pi.material is not None:
				self._material_in_print_profile = True

		if not self._material_in_print_profile and profile.getMachineSetting('gcode_flavor') != 'UltiGCode':
			for filename in resources.getSimpleModeMaterials():
				pi = ProfileInfo(filename)
				self._material_profiles.append(pi)

		self._print_profiles.sort(cmp=lambda a, b: a.order - b.order)
		self._material_profiles.sort(cmp=lambda a, b: a.order - b.order)
Example #2
0
	def __init__(self):
		self._print_profiles = []
		self._material_profiles = []
		self._material_in_print_profile = False
		for filename in resources.getSimpleModeProfiles(profile.getMachineSetting('machine_type')):
			pi = ProfileInfo(filename)
			self._print_profiles.append(pi)
			if pi.material is not None:
				self._material_in_print_profile = True

		if not self._material_in_print_profile and profile.getMachineSetting('gcode_flavor') != 'UltiGCode':
			for filename in resources.getSimpleModeMaterials():
				pi = ProfileInfo(filename)
				self._material_profiles.append(pi)

		self._print_profiles.sort(cmp=lambda a, b: a.order - b.order)
		self._material_profiles.sort(cmp=lambda a, b: a.order - b.order)
Example #3
0
	def __init__(self, parent, callback):
		super(simpleModePanel, self).__init__(parent)
		self._callback = callback
		self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )
		self._nozzle_size_options = [0.25, 0.4, 0.5, 0.6, 0.8]
		self._print_profile_options = []
		self._print_material_options = []

		printTypePanel = wx.Panel(self)
		for filename in resources.getSimpleModeProfiles():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printTypePanel, -1, name, wx.DefaultPosition, wx.Size( -1,25 ), style=wx.RB_GROUP if len(self._print_profile_options) == 0 else 0)
			button.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
			button.base_filename = base_filename
			button.filename = filename
			self._print_profile_options.append(button)
			if profile.getPreference('simpleModeProfile') == base_filename:
				button.SetValue(True)

		printMaterialPanel = wx.Panel(self)
		for filename in resources.getSimpleModeMaterials():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printMaterialPanel, -1, name, wx.DefaultPosition, wx.Size( -1,25 ), style=wx.RB_GROUP if len(self._print_material_options) == 0 else 0)
			button.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
			button.base_filename = base_filename
			button.filename = filename
			self._print_material_options.append(button)
			if profile.getPreference('simpleModeMaterial') == base_filename:
				button.SetValue(True)

		if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
			printMaterialPanel.Show(False)

		self.nozzle_size_panel = wx.Panel(self)
		self.nozzle_size_label = wx.StaticText(self.nozzle_size_panel, -1, _("Diameter (mm):"))
		self.nozzle_size_label.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		choices = []
		for i in self._nozzle_size_options:
			choices.append(_(str(i)))
		self.nozzle_size_combo = wx.ComboBox(self.nozzle_size_panel, -1, '', choices=choices, style=wx.CB_DROPDOWN|wx.CB_READONLY)
		self.nozzle_size_combo.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		index = 1 # fallback index
		try:
			nozzle = profile.getPreferenceFloat("active_nozzle")
			if nozzle is None or nozzle <= 0:
				nozzle = 0.4
			index = self._nozzle_size_options.index(nozzle)
		except:
			pass
		self.nozzle_size_combo.SetSelection(index)
		sizer = wx.BoxSizer(wx.VERTICAL)
		sizer.Add(self.nozzle_size_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP, 10)
		sizer.Add(self.nozzle_size_combo, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.EXPAND, 10)
		self.nozzle_size_panel.SetSizer(sizer)

		# self.printSupport = wx.CheckBox(self, -1, _("Print support structure"))
		# self.printSupport.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		self.platform_adhesion_panel = wx.Panel(self)
		self.platform_adhesion_label = wx.StaticText(self.platform_adhesion_panel, -1, _("Platform adhesion: "))
		self.platform_adhesion_label.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		self.platform_adhesion_combo = wx.ComboBox(self.platform_adhesion_panel, -1, '', choices=[_("None"), _("Brim"), _("Raft")], style=wx.CB_DROPDOWN|wx.CB_READONLY)
		self.platform_adhesion_combo.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		self.platform_adhesion_combo.SetSelection(int(profile.getPreference('simpleModePlatformAdhesion')))
		sizer = wx.BoxSizer(wx.VERTICAL)
		sizer.Add(self.platform_adhesion_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP, 10)
		sizer.Add(self.platform_adhesion_combo, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.EXPAND, 10)
		self.platform_adhesion_panel.SetSizer(sizer)

		self.platform_support_panel = wx.Panel(self)
		self.platform_support_label = wx.StaticText(self.platform_support_panel, -1, _("Support Type:"))
		self.platform_support_label.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		self.platform_support_combo = wx.ComboBox(self.platform_support_panel, -1, '', choices=[_("None"), _("Touching buildplate"), _("Everywhere")], style=wx.CB_DROPDOWN|wx.CB_READONLY)
		self.platform_support_combo.SetFont( wx.Font( 12, 74, 90, 90, False, "Sans" ) )
		self.platform_support_combo.SetSelection(int(profile.getPreference('simpleModeSupportType')))
		sizer = wx.BoxSizer(wx.VERTICAL)
		sizer.Add(self.platform_support_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP, 10)
		sizer.Add(self.platform_support_combo, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.EXPAND, 10)
		self.platform_support_panel.SetSizer(sizer)


		sizer = wx.GridBagSizer()
		self.SetSizer(sizer)
		sizer.Add((15, 15), (0, 0))
		sb = wx.StaticBox(self, label=_("Nozzle:"))
		sb.SetFont( wx.Font( 12, 74, 90, 92, False, "Sans" ) )
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		boxsizer.Add(self.nozzle_size_panel)
		sizer.Add(boxsizer, (1,0), flag=wx.EXPAND)
		sizer.Add((20, 20), (2, 0))

		sb = wx.StaticBox(printTypePanel, label=_("Print Quality:"))
		sb.SetFont( wx.Font( 12, 74, 90, 92, False, "Sans" ) )
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_profile_options:
			boxsizer.Add(button)
		printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(printTypePanel, (3,0), flag=wx.EXPAND)
		sizer.Add((20, 20), (4, 0))
		sb = wx.StaticBox(printMaterialPanel, label=_("Material:"))
		sb.SetFont( wx.Font( 12, 74, 90, 92, False, "Sans" ) )
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_material_options:
			boxsizer.Add(button)
		printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(printMaterialPanel, (5,0), flag=wx.EXPAND)
		sizer.Add((20, 20), (6, 0))
		sb = wx.StaticBox(self, label=_("Other:"))
		sb.SetFont( wx.Font( 12, 74, 90, 92, False, "Sans" ) )
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		# boxsizer.Add(self.printSupport)
		boxsizer.Add(self.platform_adhesion_panel)
		boxsizer.Add(self.platform_support_panel)
		sizer.Add(boxsizer, (7,0), flag=wx.EXPAND)

		for button in self._print_profile_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)
		for button in self._print_material_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)

		# self.printSupport.Bind(wx.EVT_CHECKBOX, self._update)
		self.nozzle_size_combo.Bind(wx.EVT_COMBOBOX, self._update)
		self.platform_adhesion_combo.Bind(wx.EVT_COMBOBOX, self._update)
		self.platform_support_combo.Bind(wx.EVT_COMBOBOX, self._update)
Example #4
0
    def __init__(self, parent, callback):
        super(simpleModePanel, self).__init__(parent)
        self._callback = callback

        self._print_material_options = []
        self._print_profile_options = []
        self._print_other_options = []
        self._print_material_types = {}
        self._all_print_materials = []

        materials = resources.getSimpleModeMaterials()
        other_print_material_types = []
        for material in materials:
            if material.disabled:
                continue
            if len(material.types) == 0:
                other_print_material_types.append(material)
            else:
                for type in material.types:
                    if self._print_material_types.has_key(type):
                        self._print_material_types[type].append(material)
                    else:
                        self._print_material_types[type] = [material]

        if len(self._print_material_types) == 0:
            self._print_material_types = None

        # Create material buttons
        self.printMaterialPanel = wx.Panel(self)
        selectedMaterial = None
        for material in materials:
            if material.disabled:
                continue
            # Show radio buttons if there are no material types
            if self._print_material_types is None:
                button = wx.RadioButton(
                    self.printMaterialPanel,
                    -1,
                    material.name.replace('&', '&&'),
                    style=wx.RB_GROUP
                    if len(self._print_material_options) == 0 else 0)
                button.profile = material
                button.Bind(wx.EVT_RADIOBUTTON, self._materialSelected)
                self._print_material_options.append(button)
            self._all_print_materials.append(material)
            if profile.getProfileSetting(
                    'simpleModeMaterial') == material.name:
                selectedMaterial = material

        # Decide on the default selected material
        if selectedMaterial is None:
            for material in self._all_print_materials:
                if material.default:
                    selectedMaterial = material
                    break

        if selectedMaterial is None and len(self._all_print_materials) > 0:
            selectedMaterial = self._all_print_materials[0]

        # Decide to show the panel or not
        if self._print_material_types is None and len(
                self._print_material_options) < 2:
            self.printMaterialPanel.Show(len(self._print_material_options) > 1 and \
                    self._print_material_options[0].always_visible)

        # Create material types combobox
        self.printMaterialTypesPanel = wx.Panel(self)
        selectedMaterialType = None
        if self._print_material_types is not None:
            for material_type in self._print_material_types:
                if profile.getProfileSetting('simpleModeMaterialType') == material_type and \
                   selectedMaterial in self._print_material_types[material_type]:
                    selectedMaterialType = material_type

            if selectedMaterialType is None:
                if profile.getProfileSetting('simpleModeMaterialType') == _(
                        "All"):
                    selectedMaterialType = profile.getProfileSetting(
                        'simpleModeMaterialType')
                elif selectedMaterial is None or len(
                        selectedMaterial.types) == 0:
                    selectedMaterialType = _("Others")
                else:
                    selectedMaterialType = selectedMaterial.types[0]

        # Decide to show the material types or not
        if self._print_material_types is None:
            self.printMaterialTypesPanel.Show(False)

        self.printTypePanel = wx.Panel(self)

        sizer = wx.GridBagSizer()
        self.SetSizer(sizer)

        boxsizer = wx.BoxSizer(wx.VERTICAL)
        boxsizer.SetMinSize((80, 20))
        if self._print_material_types is None:
            self.materialTypeCombo = None
        else:
            choices = self._print_material_types.keys()
            choices.sort(key=lambda type: sum(
                [mat.order for mat in self._print_material_types[type]]))
            # Now we can add Others, so it appears towards the end
            if len(other_print_material_types) > 0:
                self._print_material_types[_(
                    "Others")] = other_print_material_types
                choices.append(_("Others"))
            choices.append(_("All"))
            label = wx.StaticText(self.printMaterialTypesPanel,
                                  label=_("Material ease of use:"))
            self.materialTypeCombo = wx.ComboBox(self.printMaterialTypesPanel,
                                                 -1,
                                                 selectedMaterialType,
                                                 choices=choices,
                                                 style=wx.CB_READONLY)
            self.materialTypeCombo.Bind(wx.EVT_COMBOBOX,
                                        self._materialTypeSelected)
            boxsizer.Add(label, flag=wx.EXPAND)
            boxsizer.Add(self.materialTypeCombo,
                         border=5,
                         flag=wx.BOTTOM | wx.TOP | wx.EXPAND)
        self.printMaterialTypesPanel.SetSizer(boxsizer)
        sizer.Add(self.printMaterialTypesPanel, (0, 0),
                  border=10,
                  flag=wx.EXPAND | wx.RIGHT | wx.LEFT | wx.TOP)

        if self._print_material_types is None:
            sb = wx.StaticBox(self.printMaterialPanel, label=_("Material:"))
            boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
            boxsizer.SetMinSize((80, 20))
            for button in self._print_material_options:
                # wxpython 2.8 gives a 13 pixel high radio/checkbutton but wxpython 3.0
                # gives it a 25 pixels height, so we add a border to compensate for the ugliness
                if button.GetBestSize()[1] < 20:
                    border = 5
                else:
                    border = 0
                boxsizer.Add(button, border=border, flag=wx.ALL)
            self.printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
            self.printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
            self.materialCombo = None
        else:
            boxsizer = wx.BoxSizer(wx.VERTICAL)
            boxsizer.SetMinSize((80, 20))
            label = wx.StaticText(self.printMaterialPanel,
                                  label=_("Material:"))
            self.materialCombo = wx.ComboBox(self.printMaterialPanel,
                                             -1,
                                             selectedMaterial.name,
                                             choices=[],
                                             style=wx.CB_READONLY)
            self.materialCombo.Bind(wx.EVT_COMBOBOX, self._materialSelected)
            boxsizer.Add(label, flag=wx.EXPAND)
            boxsizer.Add(self.materialCombo,
                         border=5,
                         flag=wx.BOTTOM | wx.TOP | wx.EXPAND)
            self.printMaterialPanel.SetSizer(boxsizer)
        self.materialHyperlink = wx.HyperlinkCtrl(
            self.printMaterialPanel,
            -1,
            label=_('Material Information'),
            url='',
            style=wx.HL_ALIGN_LEFT | wx.BORDER_NONE | wx.HL_CONTEXTMENU)
        self.materialHyperlink.Show(False)
        self.materialDescription = wx.StaticText(self.printMaterialPanel, -1,
                                                 '')
        self.materialDescription.Show(False)
        boxsizer.Add(self.materialDescription,
                     border=5,
                     flag=wx.BOTTOM | wx.TOP | wx.EXPAND)
        boxsizer.Add(self.materialHyperlink,
                     border=5,
                     flag=wx.BOTTOM | wx.TOP | wx.EXPAND)
        sizer.Add(self.printMaterialPanel, (1, 0),
                  border=10,
                  flag=wx.EXPAND | wx.RIGHT | wx.LEFT | wx.TOP)

        sb = wx.StaticBox(self.printTypePanel,
                          label=_("Select a quickprint profile:"))
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        boxsizer.SetMinSize((180, 20))
        self.printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
        sizer.Add(self.printTypePanel, (2, 0),
                  border=10,
                  flag=wx.EXPAND | wx.RIGHT | wx.LEFT | wx.TOP)

        self.printOptionsBox = wx.StaticBox(self, label=_("Other options:"))
        boxsizer = wx.StaticBoxSizer(self.printOptionsBox, wx.VERTICAL)
        boxsizer.SetMinSize((100, 20))
        sizer.Add(boxsizer, (3, 0),
                  border=10,
                  flag=wx.EXPAND | wx.RIGHT | wx.LEFT | wx.TOP)
        self.printOptionsSizer = boxsizer

        if selectedMaterialType:
            self.materialTypeCombo.SetValue(selectedMaterialType)
            self._materialTypeSelected(None)
        if selectedMaterial:
            if self.materialCombo:
                self.materialCombo.SetValue(selectedMaterial.name)
            else:
                for button in self._print_material_options:
                    if button.profile == selectedMaterial:
                        button.SetValue(True)
                        break
        self._materialSelected(None)
        self.Layout()
Example #5
0
    def __init__(self, parent, callback):
        super(simpleModePanel, self).__init__(parent)
        self._callback = callback

        self._print_profile_options = []
        self._print_material_options = []

        printTypePanel = wx.Panel(self)
        for filename in resources.getSimpleModeProfiles():
            cp = configparser.ConfigParser()
            cp.read(filename)
            base_filename = os.path.splitext(os.path.basename(filename))[0]
            name = base_filename
            if cp.has_option('info', 'name'):
                name = cp.get('info', 'name')
            button = wx.RadioButton(
                printTypePanel,
                -1,
                name,
                style=wx.RB_GROUP
                if len(self._print_profile_options) == 0 else 0)
            button.base_filename = base_filename
            button.filename = filename
            self._print_profile_options.append(button)
            if profile.getPreference('simpleModeProfile') == base_filename:
                button.SetValue(True)

        printMaterialPanel = wx.Panel(self)
        for filename in resources.getSimpleModeMaterials():
            cp = configparser.ConfigParser()
            cp.read(filename)
            base_filename = os.path.splitext(os.path.basename(filename))[0]
            name = base_filename
            if cp.has_option('info', 'name'):
                name = cp.get('info', 'name')
            button = wx.RadioButton(
                printMaterialPanel,
                -1,
                name,
                style=wx.RB_GROUP
                if len(self._print_material_options) == 0 else 0)
            button.base_filename = base_filename
            button.filename = filename
            self._print_material_options.append(button)
            if profile.getPreference('simpleModeMaterial') == base_filename:
                button.SetValue(True)

        if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
            printMaterialPanel.Show(False)

        self.printSupport = wx.CheckBox(self, -1, _("Print support structure"))

        sizer = wx.GridBagSizer()
        self.SetSizer(sizer)

        sb = wx.StaticBox(printTypePanel,
                          label=_("Select a quickprint profile:"))
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        for button in self._print_profile_options:
            boxsizer.Add(button)
        printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
        printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
        sizer.Add(printTypePanel, (0, 0), flag=wx.EXPAND)

        sb = wx.StaticBox(printMaterialPanel, label=_("Material:"))
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        for button in self._print_material_options:
            boxsizer.Add(button)
        printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
        printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
        sizer.Add(printMaterialPanel, (1, 0), flag=wx.EXPAND)

        sb = wx.StaticBox(self, label=_("Other:"))
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        boxsizer.Add(self.printSupport)
        sizer.Add(boxsizer, (2, 0), flag=wx.EXPAND)

        for button in self._print_profile_options:
            button.Bind(wx.EVT_RADIOBUTTON, self._update)
        for button in self._print_material_options:
            button.Bind(wx.EVT_RADIOBUTTON, self._update)

        self.printSupport.Bind(wx.EVT_CHECKBOX, self._update)
Example #6
0
	def __init__(self, parent, callback):
		super(simpleModePanel, self).__init__(parent)
		self._callback = callback

		self._print_material_options = []
		self._print_profile_options = []
		self._print_other_options = []
		self._print_material_types = {}
		self._all_print_materials = []

		materials = resources.getSimpleModeMaterials()
		other_print_material_types = []
		for material in materials:
			if material.disabled:
				continue
			if len(material.types) == 0:
				other_print_material_types.append(material)
			else:
				for type in material.types:
					if self._print_material_types.has_key(type):
						self._print_material_types[type].append(material)
					else:
						self._print_material_types[type] = [material]

		if len(self._print_material_types) == 0:
			self._print_material_types = None

		# Create material buttons
		self.printMaterialPanel = wx.Panel(self)
		selectedMaterial = None
		for material in materials:
			if material.disabled:
				continue
			# Show radio buttons if there are no material types
			if self._print_material_types is None:
				button = wx.RadioButton(self.printMaterialPanel, -1, material.name.replace('&', '&&'),
										style=wx.RB_GROUP if len(self._print_material_options) == 0 else 0)
				button.profile = material
				button.Bind(wx.EVT_RADIOBUTTON, self._materialSelected)
				self._print_material_options.append(button)
			self._all_print_materials.append(material)
			if profile.getProfileSetting('simpleModeMaterial') == material.name:
				selectedMaterial = material

		# Decide on the default selected material
		if selectedMaterial is None:
			for material in self._all_print_materials:
				if material.default:
					selectedMaterial = material
					break

		if selectedMaterial is None and len(self._all_print_materials) > 0:
			selectedMaterial = self._all_print_materials[0]

		# Decide to show the panel or not
		if self._print_material_types is None and len(self._print_material_options) < 2:
			self.printMaterialPanel.Show(len(self._print_material_options) > 1 and \
										 self._print_material_options[0].always_visible)

		# Create material types combobox
		self.printMaterialTypesPanel = wx.Panel(self)
		selectedMaterialType = None
		if self._print_material_types is not None:
			for material_type in self._print_material_types:
				if profile.getProfileSetting('simpleModeMaterialType') == material_type and \
				   selectedMaterial in self._print_material_types[material_type]:
					selectedMaterialType = material_type

			if selectedMaterialType is None:
				if profile.getProfileSetting('simpleModeMaterialType') == _("All"):
					selectedMaterialType = profile.getProfileSetting('simpleModeMaterialType')
				elif selectedMaterial is None or len(selectedMaterial.types) == 0:
					selectedMaterialType = _("Others")
				else:
					selectedMaterialType = selectedMaterial.types[0]

		# Decide to show the material types or not
		if self._print_material_types is None:
			self.printMaterialTypesPanel.Show(False)

		self.printTypePanel = wx.Panel(self)

		sizer = wx.GridBagSizer()
		self.SetSizer(sizer)

		boxsizer = wx.BoxSizer(wx.VERTICAL)
		boxsizer.SetMinSize((80, 20))
		if self._print_material_types is None:
			self.materialTypeCombo = None
		else:
			choices = self._print_material_types.keys()
			choices.sort(key=lambda type: sum([mat.order for mat in self._print_material_types[type]]))
			# Now we can add Others, so it appears towards the end
			if len(other_print_material_types) > 0:
				self._print_material_types[_("Others")] = other_print_material_types
				choices.append(_("Others"))
			choices.append(_("All"))
			label = wx.StaticText(self.printMaterialTypesPanel, label=_("Material ease of use:"))
			self.materialTypeCombo = wx.ComboBox(self.printMaterialTypesPanel, -1, selectedMaterialType,
												 choices=choices, style=wx.CB_READONLY)
			self.materialTypeCombo.Bind(wx.EVT_COMBOBOX, self._materialTypeSelected)
			boxsizer.Add(label, flag=wx.EXPAND)
			boxsizer.Add(self.materialTypeCombo, border=5, flag=wx.BOTTOM|wx.TOP|wx.EXPAND)
		self.printMaterialTypesPanel.SetSizer(boxsizer)
		sizer.Add(self.printMaterialTypesPanel, (0,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)

		if self._print_material_types is None:
			sb = wx.StaticBox(self.printMaterialPanel, label=_("Material:"))
			boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
			boxsizer.SetMinSize((80, 20))
			for button in self._print_material_options:
				# wxpython 2.8 gives a 13 pixel high radio/checkbutton but wxpython 3.0
				# gives it a 25 pixels height, so we add a border to compensate for the ugliness
				if button.GetBestSize()[1] < 20:
					border = 5
				else:
					border = 0
				boxsizer.Add(button, border=border, flag=wx.ALL)
			self.printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
			self.printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
			self.materialCombo = None
		else:
			boxsizer = wx.BoxSizer(wx.VERTICAL)
			boxsizer.SetMinSize((80, 20))
			label = wx.StaticText(self.printMaterialPanel, label=_("Material:"))
			self.materialCombo = wx.ComboBox(self.printMaterialPanel, -1, selectedMaterial.name,
											 choices=[], style=wx.CB_READONLY)
			self.materialCombo.Bind(wx.EVT_COMBOBOX, self._materialSelected)
			boxsizer.Add(label, flag=wx.EXPAND)
			boxsizer.Add(self.materialCombo, border=5, flag=wx.BOTTOM|wx.TOP|wx.EXPAND)
			self.printMaterialPanel.SetSizer(boxsizer)
		self.materialHyperlink = wx.HyperlinkCtrl(self.printMaterialPanel, -1, label=_('Material Information'), url='',
												  style=wx.HL_ALIGN_LEFT|wx.BORDER_NONE|wx.HL_CONTEXTMENU)
		self.materialHyperlink.Show(False)
		self.materialDescription = wx.StaticText(self.printMaterialPanel, -1, '')
		self.materialDescription.Show(False)
		boxsizer.Add(self.materialDescription, border=5, flag=wx.BOTTOM|wx.TOP|wx.EXPAND)
		boxsizer.Add(self.materialHyperlink, border=5, flag=wx.BOTTOM|wx.TOP|wx.EXPAND)
		sizer.Add(self.printMaterialPanel, (1,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)

		sb = wx.StaticBox(self.printTypePanel, label=_("Select a quickprint profile:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		boxsizer.SetMinSize((180, 20))
		self.printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		self.printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(self.printTypePanel, (2,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)


		self.printOptionsBox = wx.StaticBox(self, label=_("Other options:"))
		boxsizer = wx.StaticBoxSizer(self.printOptionsBox, wx.VERTICAL)
		boxsizer.SetMinSize((100, 20))
		sizer.Add(boxsizer, (3,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)
		self.printOptionsSizer = boxsizer

		if selectedMaterialType:
			self.materialTypeCombo.SetValue(selectedMaterialType)
			self._materialTypeSelected(None)
		if selectedMaterial:
			if self.materialCombo:
				self.materialCombo.SetValue(selectedMaterial.name)
			else:
				for button in self._print_material_options:
					if button.profile == selectedMaterial:
						button.SetValue(True)
						break
		self._materialSelected(None)
		self.Layout()
	def __init__(self, parent, callback):
		super(simpleModePanel, self).__init__(parent)

		self._use_nozzle_options = False

		self._callback = callback

		self._print_profile_options = []
		self._print_material_options = []
		self._print_nozzle_options = []

		printTypePanel = wx.Panel(self)
		for filename in resources.getSimpleModeProfiles():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printTypePanel, -1, name, style=wx.RB_GROUP if len(self._print_profile_options) == 0 else 0)
			button.base_filename = base_filename
			button.filename = filename
			self._print_profile_options.append(button)
			if profile.getPreference('simpleModeProfile') == base_filename:
				button.SetValue(True)

		printMaterialPanel = wx.Panel(self)
		for filename in resources.getSimpleModeMaterials():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printMaterialPanel, -1, name, style=wx.RB_GROUP if len(self._print_material_options) == 0 else 0)
			button.base_filename = base_filename
			button.filename = filename
			self._print_material_options.append(button)
			if profile.getPreference('simpleModeMaterial') == base_filename:
				button.SetValue(True)

		printNozzlePanel = wx.Panel(self)
		for nozzle_size in [0.4, 0.25, 0.6, 0.8, 1.0]:
			name = str(nozzle_size) + "mm"
			button = wx.RadioButton(printNozzlePanel, -1, name, style=wx.RB_GROUP if len(self._print_nozzle_options) == 0 else 0)
			button.nozzle_size = nozzle_size
			button.nozzle_name = name
			self._print_nozzle_options.append(button)
			if profile.getPreference('simpleModeNozzle') == name:
				button.SetValue(True)

		if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
			printMaterialPanel.Show(False)
		if not self._use_nozzle_options or profile.getMachineSetting('gcode_flavor') != 'UltiGCode':
			printNozzlePanel.Show(False)

		self.printSupport = wx.CheckBox(self, -1, _("Print support structure"))

		sizer = wx.GridBagSizer()
		self.SetSizer(sizer)

		sb = wx.StaticBox(printTypePanel, label=_("Select a quickprint profile:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_profile_options:
			boxsizer.Add(button)
		printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(printTypePanel, (0,0), flag=wx.EXPAND)

		sb = wx.StaticBox(printMaterialPanel, label=_("Material:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_material_options:
			boxsizer.Add(button)
		printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(printMaterialPanel, (1,0), flag=wx.EXPAND)

		sb = wx.StaticBox(printNozzlePanel, label=_("Nozzle:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_nozzle_options:
			boxsizer.Add(button)
		printNozzlePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printNozzlePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
		sizer.Add(printNozzlePanel, (2,0), flag=wx.EXPAND)

		sb = wx.StaticBox(self, label=_("Other:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		boxsizer.Add(self.printSupport)
		sizer.Add(boxsizer, (3,0), flag=wx.EXPAND)

		for button in self._print_profile_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)
		for button in self._print_material_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)
		for button in self._print_nozzle_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)

		self.printSupport.Bind(wx.EVT_CHECKBOX, self._update)
Example #8
0
	def __init__(self, parent, callback):
		super(simpleModePanel, self).__init__(parent)
		self._callback = callback

		self._print_profile_options = []
		self._print_material_options = []
		self._print_other_options = []

		printTypePanel = wx.Panel(self)
		for filename in resources.getSimpleModeProfiles():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printTypePanel, -1, name, style=wx.RB_GROUP if len(self._print_profile_options) == 0 else 0)
			button.base_filename = base_filename
			button.filename = filename
			self._print_profile_options.append(button)
			if profile.getProfileSetting('simpleModeProfile') == base_filename:
				button.SetValue(True)

		printMaterialPanel = wx.Panel(self)
		for filename in resources.getSimpleModeMaterials():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.RadioButton(printMaterialPanel, -1, name, style=wx.RB_GROUP if len(self._print_material_options) == 0 else 0)
			button.base_filename = base_filename
			button.filename = filename
			self._print_material_options.append(button)
			if profile.getProfileSetting('simpleModeMaterial') == base_filename:
				button.SetValue(True)

		if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
			printMaterialPanel.Show(False)

		for filename in resources.getSimpleModeOptions():
			cp = configparser.ConfigParser()
			cp.read(filename)
			base_filename = os.path.splitext(os.path.basename(filename))[0]
			name = base_filename
			if cp.has_option('info', 'name'):
				name = cp.get('info', 'name')
			button = wx.CheckBox(self, -1, name)
			button.base_filename = base_filename
			button.filename = filename
			self._print_other_options.append(button)

		sizer = wx.GridBagSizer()
		self.SetSizer(sizer)

		sb = wx.StaticBox(printTypePanel, label=_("Select a quickprint profile:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_profile_options:
			boxsizer.Add(button)
		printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printTypePanel.GetSizer().Add(boxsizer, border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)
		sizer.Add(printTypePanel, (0,0), flag=wx.EXPAND)

		sb = wx.StaticBox(printMaterialPanel, label=_("Material:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_material_options:
			boxsizer.Add(button)
		printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		printMaterialPanel.GetSizer().Add(boxsizer, border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)
		sizer.Add(printMaterialPanel, (1,0), flag=wx.EXPAND)

		sb = wx.StaticBox(self, label=_("Other:"))
		boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
		for button in self._print_other_options:
			boxsizer.Add(button)
		sizer.Add(boxsizer, (2,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP)

		for button in self._print_profile_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)
		for button in self._print_material_options:
			button.Bind(wx.EVT_RADIOBUTTON, self._update)
		for button in self._print_other_options:
			button.Bind(wx.EVT_CHECKBOX, self._update)