Пример #1
0
 def permListDoubleClick(self, sender):  # Make a new sheet appear
     try:
         groupText1 = sender[sender.getSelection()[0]]["Left"]
         groupText2 = sender[sender.getSelection()[0]]["Right"]
         sWidth = 600
         self.s = vanilla.Sheet((sWidth, 300), self.w)
         edWidth = int((sWidth - spX * 3) / 2)
         self.s.text1 = vanilla.TextBox((spX, 5, edWidth, txY),
                                        "Left",
                                        sizeStyle="small")
         self.s.text2 = vanilla.TextBox(
             (spX * 2 + edWidth, 5, edWidth, txY),
             "Right",
             sizeStyle="small")
         self.s.group1 = vanilla.TextEditor(
             (spX, 10 + txY, edWidth, -spY * 2 - btnY), groupText1)
         self.s.group1._textView.setFont_(Menlo12)
         self.s.group2 = vanilla.TextEditor(
             (spX * 2 + edWidth, 10 + txY, edWidth, -spY * 2 - btnY),
             groupText2)
         self.s.group2._textView.setFont_(Menlo12)
         self.s.cancel = vanilla.Button(
             (-spX * 2 - 200, -spY - btnY, 100, -spY),
             "Cancel",
             callback=self.cancelChange)
         self.s.ok = vanilla.Button((-spX - 100, -spY - btnY, -spX, -spY),
                                    "OK",
                                    callback=self.confirmChange)
         self.s.setDefaultButton(self.s.ok)
         self.s.open()
     except IndexError:
         pass
     except Exception, e:
         Glyphs.showMacroWindow()
         print "BubbleKern Error (permListDoubleClick): %s" % e
Пример #2
0
    def __init__(self, parentWindow=None):
        self.needsUpdate = False
        self.__version__ = __version__
        if not getDefault("DrawBotCheckForUpdatesAtStartup", True):
            return
        self.currentVersion = getCurrentVersion()
        self.needsUpdate = StrictVersion(__version__) < StrictVersion(self.currentVersion)
        if not self.needsUpdate:
            return
        if parentWindow:
            self.w = vanilla.Sheet((450, 130), parentWindow=parentWindow)
        else:
            self.w = vanilla.Window((450, 130))

        self.w.appIcon = vanilla.ImageView((25, 15, 65, 65))
        self.w.appIcon.setImage(imageObject=AppKit.NSApp().applicationIconImage())

        title = "There is a new version of DrawBot!"
        txt = AppKit.NSAttributedString.alloc().initWithString_attributes_(title, {AppKit.NSFontAttributeName: AppKit.NSFont.boldSystemFontOfSize_(0)})
        self.w.introBold = vanilla.TextBox((100, 15, -15, 20), txt)

        self.w.intro = vanilla.TextBox((100, 45, -15, 200), "DrawBot %s is out now (you have %s).\nWould you like to download it now?" % (self.currentVersion, __version__), sizeStyle="small")

        self.w.cancelButton = vanilla.Button((-270, -30, 60, 20), "Cancel", callback=self.cancelCallback, sizeStyle="small")
        self.w.cancelButton.bind(".", ["command"])
        self.w.cancelButton.bind(unichr(27), [])

        self.w.openInBrowser = vanilla.Button((-200, -30, 120, 20), "Show In Browser", callback=self.openInBrowserCallback, sizeStyle="small")
        self.w.okButton = vanilla.Button((-70, -30, 55, 20), "OK", callback=self.okCallback, sizeStyle="small")
        self.w.setDefaultButton(self.w.okButton)

        self.w.open()
Пример #3
0
    def __init__(self, parentWindow, callback, existingURLs):
        self._callback = callback
        self._existingURLs = existingURLs
        self._valid = False
        self._validation_report = ""

        self.w = vanilla.Sheet((350, 85), parentWindow=parentWindow)

        self.w.urlText = vanilla.TextBox((10, 22, -10, 22), "URL:")
        self.w.url = vanilla.EditText((60, 20, -10, 22))

        self.w.message = vanilla.TextBox((10, -25, -10, 22),
                                         "(A valid extension json stream)",
                                         sizeStyle="mini")

        self.w.addButton = vanilla.Button((-70, -30, -10, 20),
                                          "Add",
                                          callback=self.addCallback,
                                          sizeStyle="small")
        self.w.setDefaultButton(self.w.addButton)

        self.w.closeButton = vanilla.Button((-150, -30, -80, 20),
                                            "Cancel",
                                            callback=self.closeCallback,
                                            sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(chr(27), [])

        self.w.open()
Пример #4
0
 def editName(self, index, name):
     # Make a new vanilla "sheet" with controls for editing the name of the theme
     self.nameSheet = vanilla.Sheet((200, 110), self.w)
     self.nameSheet.editingIndex = index
     self.nameSheet.nameTitle = vanilla.TextBox((10, 10, -10, 25),
                                                "Theme Name:")
     self.nameSheet.name = vanilla.EditText((10, 35, -10, 25), name)
     self.nameSheet.cancelButton = vanilla.Button(
         (10, -35, 95, 25), "Cancel", callback=self.editSheetClose)
     self.nameSheet.okButton = vanilla.Button(
         (115, -35, -10, 25), "OK", callback=self.editSheetOKCallback)
     self.nameSheet.open()
Пример #5
0
 def _open_sheet(self, sender):
     self.s = vanilla.Sheet((self._width - 50, 220), self.w,
                            (self._width - 50, 220))
     #self.s.contents = vanilla.EditText((10, 10, -10, -40), continuous=False, sizeStyle="small")
     self.s.contents = CodeEditor((10, 10, -10, -40), "", lexer="xml")
     self.s.ok_button = vanilla.Button(
         (-80, -30, -10, 20),
         "OK",
         callback=self._close_sheet,
         sizeStyle="small",
     )
     _key = sender.get()[sender.getSelection()[0]]  #["Key"]
     self.s.contents.set(self._key_contents[_key["Key"]])
     self._sheet = True
     self.s.open()
Пример #6
0
 def __init__(self, text="", tickCount=None, parentWindow=None):
     if parentWindow is None:
         self.w = vanilla.Window((250, 60), closable=False, miniaturizable=False, textured=False)
     else:
         self.w = vanilla.Sheet((250, 60), parentWindow)
     if tickCount is None:
         isIndeterminate = True
         tickCount = 0
     else:
         isIndeterminate = False
     self.w.progress = vanilla.ProgressBar((15, 15, -15, 12), maxValue=tickCount, isIndeterminate=isIndeterminate, sizeStyle="small")
     self.w.text = vanilla.TextBox((15, 32, -15, 14), text, sizeStyle="small")
     self.w.progress.start()
     self.w.center()
     self.setUpBaseWindowBehavior()
     self.w.open()
Пример #7
0
 def __init__(self, parentWindow):
     self.w = vanilla.Sheet((600, 700),
                            minSize=(300, 300),
                            parentWindow=parentWindow)
     if inRoboFont:
         from lib.scripting.codeEditor import CodeEditor as codeEditorClass
     else:
         codeEditorClass = vanilla.TextEditor
     self.w.editor = codeEditorClass((15, 15, -15, -50),
                                     settingsManager.startupCode)
     self.w.cancelButton = vanilla.Button(
         (-165, -35, -95, 20), "Cancel", callback=self.cancelButtonCallback)
     self.w.applyButton = vanilla.Button((-85, -35, -15, 20),
                                         "Apply",
                                         callback=self.applyButtonCallback)
     self.w.cancelButton.bind(".", ["command"])
     self.w.open()
Пример #8
0
    def buildBaseWindow(self, parentWindow):
        """ Make the base window. """
        self._dirty = False
        self._sheetWidth = 315
        self._sheetHeight = 200
        if parentWindow is None:
            self.w = vanilla.Window(
                (self._sheetWidth, self._sheetHeight),
                title=self._title,
                closable=False,
                miniaturizable=False,
                minSize=(self._sheetWidth, self._sheetHeight),
                textured=False)
        else:
            self.w = vanilla.Sheet(
                (self._sheetWidth, self._sheetHeight),
                parentWindow,
                minSize=(self._sheetWidth, self._sheetHeight),
            )
        # cancel button
        self.w.cancelButton = vanilla.Button(
            (-205, -30, 100, 20),
            'Cancel',
            callback=self.callbackCancelButton,
            sizeStyle='small')
        self.w.cancelButton.bind(".", ["command"])
        self.w.cancelButton.bind(unichr(27), [])
        # ok button
        self.w.applyButton = vanilla.Button((-100, -30, -10, 20),
                                            'Add Glyphs',
                                            callback=self.callbackApplyButton,
                                            sizeStyle='small')
        self.w.setDefaultButton(self.w.applyButton)

        # get the specialised stuff in
        self.fillSheet()
        self.setUpBaseWindowBehavior()
        #self.refresh()
        self.w.open()
    def __init__(self, parentWindow, callback=None):
        self.callback = callback

        self.w = vanilla.Sheet((350, 90), parentWindow=parentWindow)

        self.w.glyphNameText = vanilla.TextBox((10, 17, 100, 22),
                                               "Glyph Name:")
        self.w.glyphName = vanilla.EditText((100, 17, -10, 22))

        self.w.addButton = vanilla.Button((-70, -30, -10, 20),
                                          "Add",
                                          callback=self.addCallback,
                                          sizeStyle="small")
        self.w.setDefaultButton(self.w.addButton)

        self.w.closeButton = vanilla.Button((-150, -30, -80, 20),
                                            "Cancel",
                                            callback=self.closeCallback,
                                            sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(unichr(27), [])

        self.w.open()
Пример #10
0
    def __init__(self, parentWindow, callback=None, debug=False):

        self._callback = callback
        self._shouldCallCallback = False

        if debug:
            self.w = vanilla.Window((400, 420))
        else:
            self.w = vanilla.Sheet((400, 420), parentWindow=parentWindow)

        y = 10
        self.w.checkForUpdate = vanilla.CheckBox(
            (10, y, -10, 22), "Check for Updates on Startup.")
        y += 30

        self.w.h1 = vanilla.HorizontalLine((0, y, 0, 1))
        y += 10

        columnDescriptions = [
            dict(title="extensions json url stream", key="url")
        ]
        self.w.urls = vanilla.List(
            (10, y, -10, 120),
            [],
            columnDescriptions=columnDescriptions,
            selfDropSettings=dict(type=genericListPboardType,
                                  operation=AppKit.NSDragOperationMove,
                                  callback=self.genericDropSelfCallback),
            dragSettings=dict(type=genericListPboardType,
                              callback=self.genericDragCallback),
        )
        y += 130
        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addURL = vanilla.SegmentedButton(
            (12, y, 100, 20),
            segmentDescriptions,
            selectionStyle="momentary",
            callback=self.addDelURLCallback)
        self.w.addURL.getNSSegmentedButton().setSegmentStyle_(
            AppKit.NSSegmentStyleSmallSquare)
        y += 30

        self.w.h2 = vanilla.HorizontalLine((0, y, 0, 1))
        y += 10

        columnDescriptions = [
            dict(title="single extension items", key="extensionName")
        ]
        self.w.singleExtenions = vanilla.List(
            (10, y, -10, 120),
            [],
            columnDescriptions=columnDescriptions,
            selfDropSettings=dict(type=genericListPboardType,
                                  operation=AppKit.NSDragOperationMove,
                                  callback=self.genericDropSelfCallback),
            dragSettings=dict(type=genericListPboardType,
                              callback=self.genericDragCallback),
        )
        y += 130
        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addSingleExtenions = vanilla.SegmentedButton(
            (12, y, 100, 20),
            segmentDescriptions,
            selectionStyle="momentary",
            callback=self.addDelSingleExtensionCallback)
        self.w.addSingleExtenions.getNSSegmentedButton().setSegmentStyle_(
            AppKit.NSSegmentStyleSmallSquare)
        y += 30

        self.w.resetButton = vanilla.Button((10, -30, 60, 20),
                                            "Reset",
                                            callback=self.resetCallback,
                                            sizeStyle="small")

        self.w.cancelButton = vanilla.Button((-170, -30, -80, 20),
                                             "Cancel",
                                             callback=self.closeCallback,
                                             sizeStyle="small")
        self.w.cancelButton.bind(".", ["command"])
        self.w.cancelButton.bind(chr(27), [])

        self.w.okButton = vanilla.Button((-70, -30, -10, 20),
                                         "OK",
                                         callback=self.okCallback,
                                         sizeStyle="small")
        self.w.setDefaultButton(self.w.okButton)

        self.getFromDefaults()
        self.w.open()
Пример #11
0
    def __init__(self, font):
        self.font = font
        self.w = vanilla.Sheet((700, 300), parentWindow=CurrentFontWindow().w, minSize=(200, 200))
        self.originalConstructions = ConstructionsLoader(font.defaultLayer).constructions
        columnDescriptions = [
            dict(
                title="Name",
                key="name",
                editable=False,
                width=100
            ),
            dict(
                title="Construction",
                key="construction",
                editable=True
            ),
            dict(
                title="Decompose",
                key="decompose",
                editable=True,
                cell=vanilla.CheckBoxListCell(),
                width=80
            )
        ]
        self.w.constructionList = vanilla.List(
            "auto",
            [],
            columnDescriptions=columnDescriptions
        )
        self.w.showExistingGlyphsCheckBox = vanilla.CheckBox(
            "auto",
            "Show Existing Glyphs",
            callback=self.showExistingGlyphsCheckBoxCallback
        )
        self.w.flex = vanilla.Group("auto")
        self.w.buildInAllFontsButton = vanilla.Button(
            "auto",
            "Build In All Fonts",
            callback=self.buildInAllFontsButtonCallback
        )
        self.w.cancelButton = vanilla.Button(
            "auto",
            "Cancel",
            callback=self.cancelButtonCallback
        )
        self.w.buildButton = vanilla.Button(
            "auto",
            "Build",
            callback=self.buildButtonCallback
        )

        metrics = dict(
            margin=15,
            padding=10,
            buttonWidth=80
        )
        rules = [
            "H:|[constructionList]|",
            "H:|-margin-[showExistingGlyphsCheckBox][flex(>=100)]-[buildInAllFontsButton]-padding-[cancelButton(==buttonWidth)]-padding-[buildButton(==buttonWidth)]-margin-|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[showExistingGlyphsCheckBox]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[flex]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[buildInAllFontsButton]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[cancelButton]"
                "-margin-"
            "|",
            "V:|"
                "[constructionList]"
                "-padding-"
                "[buildButton]"
                "-margin-"
            "|"
        ]
        self.w.addAutoPosSizeRules(rules, metrics)

        self.populateConstructionList()
        self.w.setDefaultButton(self.w.buildButton)
        self.w.cancelButton.bind(".", ["command"])
        self.w.open()