Esempio n. 1
0
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)
Esempio n. 3
0
    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, 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()
Esempio n. 5
0
    def spaceCenterDidOpen(self, notification):

        s = notification["window"].window()
        s.flipButton = ImageButton((10, 10, 26, 22),
                                   imagePath=self.path1,
                                   title=None,
                                   bordered=0,
                                   callback=self.flip)

        preLine = s.spacingView.top.glyphLinePreInput
        line = s.spacingView.top.glyphLineInput
        for view in [preLine, line]:
            l, t, w, h = view.getPosSize()
            view.setPosSize((l + 32, t, w, h))

        self.s = s
    def fontOverviewDidOpen(self, info):
        # resize the glyph cells
        if self.startupSetting == 1:
            self.resize(None)

        # add button
        self.sb = info["fontOverview"].statusBar

        if hasattr(self.sb, 'fit_button'):
            del self.sb.fit_button

        self.sb.fit_button = ImageButton((-122, -19, 18, 18),
                                         imageObject=icon,
                                         callback=self.resize,
                                         sizeStyle='regular')
        self.sb.fit_button.getNSButton().setBordered_(0)
        self.sb.fit_button.getNSButton().setBezelStyle_(2)
        self.sb.fit_button.getNSButton().image().setTemplate_(True)
Esempio n. 7
0
    def makeButton(self, notification):
        csc = CurrentSpaceCenter()
        gutter = 10
        b_w = 20
        inset_b = 1

        l, t, w, h = csc.top.glyphLineInput.getPosSize()
        b_h = h - inset_b * 2

        csc.top.glyphLineInput.setPosSize((l + b_w + gutter, t, w, h))
        l, t, w, h = csc.top.glyphLineInput.getPosSize()

        csc.save = ImageButton(
            (l - gutter - b_w, t + inset_b, b_w, b_h),
            imagePath=self.resources_path + '/_icon_Save.pdf',
            callback=self.saverCallback,
            sizeStyle='regular')
        csc.save.getNSButton().setBordered_(0)
        csc.save.getNSButton().setBezelStyle_(2)
	def createUI(self):
		x = 10; y = 10; w = 100; h = 30; space = 5; self.size = (200,450); pos = (1200,300); self.minSize = (50,400);

		self.w = HUDFloatingWindow((pos[0],pos[1],self.size[0],self.size[1]), "ToolsWindow", minSize=(self.minSize[0], self.minSize[1]))
		
		h = 30

		self.w.innerFillButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[0]+".png", callback=self.handleInnerFill)
		self.w.innerFillText = TextBox((x+40,y,w,h), "innerFill")
		y += h + space

		self.w.penPairButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[1]+".png", callback=self.handlePenPair)
		self.w.PenPairText = TextBox((x+40,y,w,h), "penPair")
		y += h + space

		self.w.dependXButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[2]+".png", callback=self.handleDependX)
		self.w.dependXText = TextBox((x+40,y,w,h), "dependX")
		y += h + space

		self.w.dependYButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[3]+".png", callback=self.handleDependY)
		self.w.dependYText = TextBox((x+40,y,w,h), "dependY")
		y += h + space

		self.w.stokeButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[4]+".png", callback=self.handleStroke)
		self.w.strokeText = TextBox((x+40,y,w,h), "stroke")
		y += h + space

		self.w.deleteButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[5]+".png", callback=self.popDelete)
		self.w.deleteText = TextBox((x+40,y,w,h), "delete")
		y += h + space

		self.w.selectButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[6]+".png", callback=self.handleSelect)
		self.w.selectText = TextBox((x+40,y,w,h), "select")
		y += h + space

		self.w.minimizeBox = CheckBox((x,y,80,20), "", callback=self.minimizeCallback, value=False)
		y += h +space

		mode = getExtensionDefault(DefaultKey+".mode")

		self.w.bind("close", self.close)
		self.w.open()
Esempio n. 9
0
    def _buildUI(self):
        editPresetsImgPath = os.path.join(currentFileDir,\
                                          "..", "resources",\
                                          "editPresetsIcon.pdf")

        listForList = [
            {
                "title": "#",
                "key": "order",
                "width": 20,
                "editable": False
            },
            {
                "title": "Group name",
                "key": "name",
                "width": 160,
                "editable": True
            },
            {
                "title": "Type size",
                "key": "typeSize",
                "width": 70,
                "editable": True,
            },
            {
                "title": "Leading",
                "key": "leading",
                "width": 65,
                "editable": True
            },
            {
                "title": " 🖨",
                "key": "print",
                "cell": CheckBoxListCell()
            }
        ]

        width = 425
        left = 10
        row = 10
        textWidth = 48
        textHeight = 20
        popUpLeft = left + textWidth + 5
        presetsPopUpWidth = width - popUpLeft - 47
        listWidth = textWidth + presetsPopUpWidth

        self.w = Window((width, 600), "Proof Drawer")

        self.w.fontText = TextBox((left, row, textWidth, textHeight),
                                  "Font:",
                                  alignment="right")
        self.w.fontsList = PopUpButton((popUpLeft, row, -10, textHeight),
                                       items=self.fonts,
                                       callback=self.fontButtonCB)

        row += 30
        self.w.presetText = TextBox((left, row, textWidth, textHeight),
                                    "Preset:",
                                    alignment="right")

        self.w.presetsList = PopUpButton((popUpLeft, row, presetsPopUpWidth, textHeight),
                                         items=self.presetNamesList,
                                         callback=self.setCurrentPresetCB)

        self.w.editPresets = ImageButton((width - 38, row, 22, 22),
                                         imagePath=editPresetsImgPath,
                                         bordered=False,
                                         callback=self.openPresetsEditorCB)

        row += 35
        self.w.line1 = HorizontalLine((left, row, -10, 1))

        row += 15
        self.w.proofGroups = List((left + 3, row, listWidth, 255),
                                  rowHeight=18,
                                  items=[],
                                  columnDescriptions=listForList,
                                  allowsSorting=False,
                                  allowsMultipleSelection=False,
                                  editCallback=self.editProofGroupCB)

        buttonGroup1Left = popUpLeft + presetsPopUpWidth + 3
        buttonGroup1Top = row + 58
        self.w.inspectGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                     "\u24D8",
                                     callback=self.inspectGroupCB)

        buttonGroup1Top += 40
        self.w.moveGroupUP = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "↑",
                                    callback=self.moveGroupCB)
        buttonGroup1Top += 25
        self.w.moveGroupDN = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "↓",
                                    callback=self.moveGroupCB)

        buttonGroup1Top += 40
        self.w.removeGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "-",
                                    callback=self.removeGroupCB)

        row += 275
        self.w.line2 = HorizontalLine((left, row, -10, 1))

        row += 10
        self.w.additionalGroupNamesText = TextBox((left, row, -10, 20),
                                                  "Add more proof groups:")

        row += 25
        self.w.additionalGroupNames = List((left + 3, row, listWidth, 150),
                                           rowHeight=17,
                                           items=self.currentPreset.uniqueGroupNames,
                                           allowsSorting=False,
                                           allowsMultipleSelection=True)

        self.w.addGroup = Button((buttonGroup1Left, row + 60, 30, 20),
                                 "+",
                                 callback=self.addProofGroupsCB)

        buttonWidth = 100
        self.w.previewButton = Button((width/2 - buttonWidth - 10, -37, buttonWidth, 20),
                                      "Preview",
                                      callback=self.testerCB)

        self.w.printButton = Button((width/2 + 10, -37, buttonWidth, 20),
                                    "Print",
                                    callback=self.testerCB)
        self.w.setDefaultButton(self.w.printButton)