class FileUploadField(Group): def __init__(self, dimensions, storage=NullStorage()): self.storage = storage super(FileUploadField, self).__init__(dimensions) self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file) self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file) self.filepath_label = TextBox((18, 3, -70, 20), "") self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file) self.filepath_button.getNSButton().setTransparent_(True) self.filetype_image = ImageView((0, 4, 16, 16)) self.filepath = self.storage.retrieve() def choose_file(self, sender): filepath = getFile("Choose a .txt or .pdf document to use as a license", "Select License", fileTypes=("txt", "md", "pdf")) if filepath is not None: self.storage.store(filepath[0]) self.filepath = filepath[0] def remove_file(self, sender): self.storage.store(None) self.filepath = None def reveal_file(self, sender): workspace = NSWorkspace.sharedWorkspace() workspace.selectFile_inFileViewerRootedAtPath_(self.filepath, os.path.dirname(self.filepath)) @property def filename(self): if self.filepath is not None: return os.path.basename(self.filepath) else: return "" @property def filepath(self): return self._filepath @filepath.setter def filepath(self, value): self._filepath = value selected = value is not None and value is not '' icon = NSWorkspace.sharedWorkspace().iconForFile_(self._filepath) self.choose_file_button.show(not selected) self.remove_file_button.show(selected) self.filepath_label.show(selected) self.filepath_label.set(self.filename) self.filepath_button.show(selected) self.filetype_image.show(selected) self.filetype_image.setImage(imageObject=icon)
class FileUploadField(Group): def __init__(self, dimensions, storage=NullStorage()): self.storage = storage super(FileUploadField, self).__init__(dimensions) self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file) self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file) self.filepath_label = TextBox((18, 3, -70, 20), "") self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file) self.filepath_button.getNSButton().setTransparent_(True) self.filetype_image = ImageView((0, 4, 16, 16)) self.filepath = self.storage.retrieve() def choose_file(self, sender): filepath = getFile("Choose a .txt or .pdf document to use as a license", "Select License", fileTypes=("txt", "md", "pdf")) if filepath is not None: self.storage.store(filepath[0]) self.filepath = filepath[0] def remove_file(self, sender): self.storage.store(None) self.filepath = None def reveal_file(self, sender): workspace = NSWorkspace.sharedWorkspace() workspace.selectFile_inFileViewerRootedAtPath_(self.filepath, os.path.dirname(self.filepath)) @property def filename(self): if self.filepath is not None: return os.path.basename(self.filepath) else: return "" @property def filepath(self): return self._filepath @filepath.setter def filepath(self, value): self._filepath = value selected = value is not None and value is not '' icon = NSWorkspace.sharedWorkspace().iconForFile_(self._filepath) self.choose_file_button.show(not selected) self.remove_file_button.show(selected) self.filepath_label.show(selected) self.filepath_label.set(WhiteText(self.filename)) self.filepath_button.show(selected) self.filetype_image.show(selected) self.filetype_image.setImage(imageObject=icon)
def __init__(self, dimensions, storage=NullStorage()): self.storage = storage super(FileUploadField, self).__init__(dimensions) self.choose_file_button = Button((0, 3, 100, 17), "Choose File", sizeStyle="small", callback=self.choose_file) self.remove_file_button = Button((-60, 3, 60, 17), "Remove", sizeStyle="small", callback=self.remove_file) self.filepath_label = TextBox((18, 3, -70, 20), "") self.filepath_button = ImageButton((0, 3, -70, 20), "", callback=self.reveal_file) self.filepath_button.getNSButton().setTransparent_(True) self.filetype_image = ImageView((0, 4, 16, 16)) self.filepath = self.storage.retrieve()
def __init__(self, parent): self.parent = parent self.w = FloatingWindow((150, 130), "Speed Punk %s" % VERSION, closable = False, autosaveName = 'de_yanone_speedPunk_%s.prefWindow' % (environment), ) self.w.illustrationPositionRadioGroup = RadioGroup((10, 10, -10, 40), ["Outside of glyph", "Outer side of curve"], callback=self.radioGroupCallback, sizeStyle = "small") self.w.curveGainTextBox = TextBox((10, 60, -10, 17), "Gain", sizeStyle = "mini") self.w.curveGainSlider = Slider((10, 70, -10, 25), tickMarkCount=5, callback=self.curveGainSliderCallback, sizeStyle = "small", minValue = curveGain[0], maxValue = curveGain[1], value = self.parent.getPreference('curveGain')) self.w.illustrationPositionRadioGroup.set(self.parent.getPreference('illustrationPositionIndex')) self.w.faderCheckBox = CheckBox((10, 100, -10, 17), "Fader", sizeStyle = "small", callback = self.faderCheckBoxCallback) self.w.faderSlider = Slider((10, 125, -10, 25), sizeStyle = "small", minValue = 0, maxValue = 1.0, value = 1.0, callback = self.faderSliderCallback) self.w.gradientImage = ImageView((10, 150, -10, 15)) self.w.histogramImage = ImageView((10, 150, -10, 15))
def _warning(self, sender, warning, prefKey): if self.prefs.get(prefKey): self.warning = Sheet((400, 140), self.w) self.warning.img = ImageView((10, 10, 60, 60)) self.warning.img.setImage(imageNamed=NSImageNameCaution) self.warning.txt = TextBox((70, 10, -10, -40), "Warning\n" + warning) callback = partial(self._changePref, key=prefKey, value=not self.prefs.get(prefKey)) self.warning.check = CheckBox((70, 80, -10, 20), "Always show this warning", value=self.prefs.get(prefKey), callback=callback) self.warning.closeButton = Button((10, 110, -10, 20), "I understand", callback=self._closeWarning) self.warning.setDefaultButton(self.warning.closeButton) self.warning.center() self.w.list.enable(False) self.warning.open()
def __init__(self, parent): self.parent = parent self.w = FloatingWindow((150, 130), "Speed Punk %s" % VERSION, closable = False, autosaveName = 'de_yanone_speedPunk_%s.prefWindow' % (environment), ) self.w.illustrationPositionRadioGroup = RadioGroup((10, 10, -10, 40), ( Glyphs.localize({ 'en': 'Outside of glyph', 'de': 'Außen an Form', 'fr': 'Éxterieur de la forme', 'es': 'Exterior del glifo', 'pt': 'Fora do glifo', }), Glyphs.localize({ 'en': 'Outer side of curve', 'de': 'Außen am Pfad', 'fr': 'Éxterieur de la courbe', 'es': 'Exterior del trazo', 'pt': 'Fora da curva', }), ), callback=self.radioGroupCallback, sizeStyle = "small") self.w.curveGainTextBox = TextBox((10, 60, -10, 17), Glyphs.localize({ 'en': 'Gain', 'de': 'Stärke', 'fr': 'Volume', 'es': 'Volumen', 'pt': 'Volume', }), sizeStyle = "mini") self.w.curveGainSlider = Slider((10, 70, -10, 25), tickMarkCount=5, callback=self.curveGainSliderCallback, sizeStyle = "small", minValue = curveGain[0], maxValue = curveGain[1], value = self.parent.getPreference('curveGain')) self.w.illustrationPositionRadioGroup.set(self.parent.getPreference('illustrationPositionIndex')) self.w.faderCheckBox = CheckBox((10, 100, -10, 17), Glyphs.localize({ 'en': 'Fade', 'de': 'Ausblenden', 'fr': 'Opacité', 'es': 'Opacidad', 'pt': 'Opacidade', }), sizeStyle = "small", callback = self.faderCheckBoxCallback) self.w.faderSlider = Slider((10, 125, -10, 25), sizeStyle = "small", minValue = 0, maxValue = 1.0, value = 1.0, callback = self.faderSliderCallback) self.w.gradientImage = ImageView((10, 150, -10, 15)) self.w.histogramImage = ImageView((10, 150, -10, 15))
def create_image(self): image = NSImage.imageNamed_("ExtensionIcon") self.w.image = ImageView((15, 15, 80, 80), scale='fit') self.w.image.setImage(imageObject=image)