예제 #1
0
    def toWxColor(colorEnum: 'PyutColorEnum') -> Colour:
        """
        """
        cdb: ColourDatabase = ColourDatabase()
        if colorEnum == PyutColorEnum.BLACK:
            c: Colour = cdb.Find(PyutColorEnum.BLACK.value)
        elif colorEnum == PyutColorEnum.CORNFLOWER_BLUE:
            c = cdb.Find(PyutColorEnum.CORNFLOWER_BLUE.value)
        elif colorEnum == PyutColorEnum.LIGHT_GREY:
            c = cdb.Find(PyutColorEnum.LIGHT_GREY.value)
        elif colorEnum == PyutColorEnum.GREEN:
            c = cdb.Find(PyutColorEnum.GREEN.value)
        elif colorEnum == PyutColorEnum.MEDIUM_BLUE:
            c = cdb.Find(PyutColorEnum.MEDIUM_BLUE.value)
        elif colorEnum == PyutColorEnum.MIDNIGHT_BLUE:
            c = cdb.Find(PyutColorEnum.MIDNIGHT_BLUE.value)
        elif colorEnum == PyutColorEnum.YELLOW:
            c = cdb.Find(PyutColorEnum.YELLOW.value)
        elif colorEnum == PyutColorEnum.SALMON:
            c = cdb.Find(PyutColorEnum.SALMON.value)
        else:
            c = cdb.Find(PyutColorEnum.WHITE.value)

        del cdb
        assert c.IsOk(), 'Developer Error.  Invalid color'
        return c
예제 #2
0
 def _set_styles(self, readonly=False):
     color_settings = self.settings.get_without_default('Text Edit')
     background = color_settings.get('background', '#FFFFFF')
     if readonly:
         h = background.lstrip('#')
         if h.upper() == background.upper():
             from wx import ColourDatabase
             cdb = ColourDatabase()
             bkng = cdb.Find(h.upper())
             bkg = (bkng[0], bkng[1], bkng[2])
         else:
             bkg = tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))
         if bkg >= (180, 180, 180):
             bkg = (max(160, bkg[0] - 80), max(160, bkg[1] - 80),
                    max(160, bkg[2] - 80))
         else:
             bkg = (min(255, bkg[0] + 180), min(255, bkg[1] + 180),
                    min(255, bkg[2] + 180))
         background = '#%02X%02X%02X' % bkg
     if robotframeworklexer:
         styles = {
             robotframeworklexer.ARGUMENT: {
                 'fore': color_settings.get('argument', '#bb8844')
             },
             robotframeworklexer.COMMENT: {
                 'fore': color_settings.get('comment', 'black')
             },
             robotframeworklexer.ERROR: {
                 'fore': color_settings.get('error', 'black')
             },
             robotframeworklexer.GHERKIN: {
                 'fore': color_settings.get('gherkin', 'black')
             },
             robotframeworklexer.HEADING: {
                 'fore': color_settings.get('heading', '#999999'),
                 'bold': 'true'
             },
             robotframeworklexer.IMPORT: {
                 'fore': color_settings.get('import', '#555555')
             },
             robotframeworklexer.KEYWORD: {
                 'fore': color_settings.get('keyword', '#990000'),
                 'bold': 'true'
             },
             robotframeworklexer.SEPARATOR: {
                 'fore': color_settings.get('separator', 'black')
             },
             robotframeworklexer.SETTING: {
                 'fore': color_settings.get('setting', 'black'),
                 'bold': 'true'
             },
             robotframeworklexer.SYNTAX: {
                 'fore': color_settings.get('syntax', 'black')
             },
             robotframeworklexer.TC_KW_NAME: {
                 'fore': color_settings.get('tc_kw_name', '#aaaaaa')
             },
             robotframeworklexer.VARIABLE: {
                 'fore': color_settings.get('variable', '#008080')
             }
         }
         self.tokens = {}
         for index, token in enumerate(styles):
             self.tokens[token] = index
             self.editor.StyleSetSpec(
                 index,
                 self._get_style_string(back=background, **styles[token]))
     else:
         foreground = color_settings.get('setting', 'black')
         self.editor.StyleSetSpec(
             0, self._get_style_string(back=background, fore=foreground))
     self.editor.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, background)
     self.editor.SetZoom(self._zoom_factor())
     self.editor.Refresh()
예제 #3
0
파일: DlgAbout.py 프로젝트: hasii2011/PyUt
    def __init__(self, parent: Window, wxID: int, title: str):
        """

        Args:
            parent:     parent window
            wxID:        wx ID of this frame
            title:      Title to display
        """
        super().__init__(parent, wxID, title, DefaultPosition,
                         Size(FrameWidth, FrameHeight))

        self.logger: Logger = getLogger(__name__)

        if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM:

            fileName: str = PyutUtils.getResourcePath(
                packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico')
            icon: Icon = Icon(fileName, BITMAP_TYPE_ICO)
            self.SetIcon(icon)

        self.Center(BOTH)

        longTextStr: str = PyutUtils.retrieveResourceText(
            ResourceTextType.KUDOS_TEXT_TYPE)
        self._textToShow: List[str] = longTextStr.split('\n')

        bgWhite: Colour = ColourDatabase().Find('White')
        self.SetBackgroundColour(bgWhite)
        # Animation panel
        self._panel: Panel = Panel(self,
                                   ID_ANY,
                                   size=(FrameWidth, FrameHeight))

        self._picture: StaticBitmap = StaticBitmap(
            self, ID_ANY, ImgPyut.embeddedImage.GetBitmap())
        summaryText: str = "2022 Humberto Sanchez II and the PyUt team.\nPublished under the GNU General Public License"
        self._label: StaticText = StaticText(self,
                                             ID_ANY,
                                             summaryText,
                                             style=CAPTION)

        # Main sizer
        self.SetAutoLayout(True)
        sizer = BoxSizer(VERTICAL)
        sizer.Add(self._picture, 0, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._panel, 1, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._label, 0, ALL | ALIGN_CENTER, 5)

        btnOk: Button = Button(self, ID_OK, "&Ok")
        sizer.Add(btnOk, 0, ALL | ALIGN_CENTER, 5)
        self.SetSizer(sizer)
        sizer.Fit(self)

        self._textPosition = 0.0  # Current position

        self._timer: Timer = Timer(self)
        self.Bind(EVT_TIMER, self._onTimer, self._timer)

        self.Bind(EVT_BUTTON, self._onOk, btnOk)
        self._panel.Bind(EVT_PAINT, self.OnRefreshPanel)
        self.Bind(EVT_CLOSE, self._onOk)