Ejemplo n.º 1
0
    def __createGuiElements(self, config):
        self.fontLabel = wx.StaticText(self, -1, _("Font"))
        self.fontPicker = wx.FontPickerCtrl(self, -1)
        self.lineNumbersCheckBox = wx.CheckBox(self, -1,
                                               _("Show line numbers"))
        self.tabWidthLabel = wx.StaticText(self, -1, _("Tab width"))

        self.tabWidthSpin = wx.SpinCtrl(self,
                                        -1,
                                        str(config.TAB_WIDTH_DEFAULT),
                                        min=self.MIN_TAB_WIDTH,
                                        max=self.MAX_TAB_WIDTH,
                                        style=wx.SP_ARROW_KEYS
                                        | wx.TE_AUTO_URL)

        # Настройки для клавиш Home / End
        self.homeEndLabel = wx.StaticText(
            self, -1,
            _(u"Home / End keys moves the cursor \nto the beginning / end of ")
        )
        self.homeEndCombo = wx.ComboBox(self,
                                        -1,
                                        style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.homeEndCombo.SetMinSize((200, -1))
        self.homeEndCombo.AppendItems([_(u"Line"), _(u"Paragraph")])

        # Цвет шрифта
        self.fontColorLabel = wx.StaticText(self, label=_(u"Font color"))
        self.fontColorPicker = wx.ColourPickerCtrl(self,
                                                   style=wx.CLRP_SHOW_LABEL)

        # Цвет фона
        self.backColorLabel = wx.StaticText(self, label=_(u"Background color"))
        self.backColorPicker = wx.ColourPickerCtrl(self,
                                                   style=wx.CLRP_SHOW_LABEL)
Ejemplo n.º 2
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)
        self.log = log

        self.mainPanel = wx.Panel(self)
        self.mainPanel.SetBackgroundColour(wx.WHITE)

        # Initialize AquaButton 1 (with image)
        bitmap = wx.Bitmap(
            os.path.normpath(os.path.join(bitmapDir, "aquabutton.png")),
            wx.BITMAP_TYPE_PNG)
        self.btn1 = AB.AquaButton(self.mainPanel, -1, bitmap, "AquaButton")
        # Initialize AquaButton 2 (no image)
        self.btn2 = AB.AquaButton(self.mainPanel, -1, None, "Hello World!")

        self.backColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.btn2.GetBackgroundColour())
        self.hoverColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.btn2.GetHoverColour())
        self.focusColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.btn2.GetHoverColour())
        self.textColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.btn2.GetForegroundColour())
        self.pulseCheck = wx.CheckBox(self.mainPanel, -1, "Pulse On Focus")

        self.DoLayout()
        self.BindEvents()
Ejemplo n.º 3
0
    def _createContentWidgets(self):
        self.sizeStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"fontdialog.FontSettings")) #$NON-NLS-1$
        self.previewStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"fontdialog.FontPreview")) #$NON-NLS-1$
        self.fontLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"fontdialog.FontName")) #$NON-NLS-1$ #$NON-NLS-2$
        self.sizeLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"fontdialog.FontSize")) #$NON-NLS-1$ #$NON-NLS-2$
        self.colorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"fontdialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$
        self.backgroundLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"fontdialog.BackgroundColor")) #$NON-NLS-1$ #$NON-NLS-2$

        sizes = u"Default,8px,10px,12px,14px,16px,18px,24px,36px".split(u",") #$NON-NLS-1$ #$NON-NLS-2$
        self.sizeChoices = wx.Choice(self, wx.ID_ANY, (100, -1), choices = sizes)

        fonts = [u"Default"] #$NON-NLS-1$
        fonts.extend(self.systemFontNames)
        self.fontChoices = wx.Choice(self, wx.ID_ANY, (100, -1), choices = fonts)

        colors = [u"Default"] #$NON-NLS-1$
        self.colorChoicesHasRecent = False
        self.colorChoices = wx.Choice(self, wx.ID_ANY, (100, -1), choices = colors)
        self.colorPicker = wx.ColourPickerCtrl(self)

        bgColors = [u"Default"] #$NON-NLS-1$
        self.bgColorChoicesHasRecent = False
        self.bgColorChoices = wx.Choice(self, wx.ID_ANY, (100, -1), choices = bgColors)
        self.bgColorPicker = wx.ColourPickerCtrl(self)

        self.previewCntrl = ZHTMLViewControl(self, wx.ID_ANY)
Ejemplo n.º 4
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)
        self.log = log

        self.mainPanel = wx.Panel(self)
        self.mainPanel.SetBackgroundColour(wx.WHITE)

        self.gauge1 = PG.PyGauge(self.mainPanel,
                                 -1,
                                 size=(100, 25),
                                 style=wx.GA_HORIZONTAL)
        self.gauge1.SetValue(80)
        self.gauge1.SetBackgroundColour(wx.WHITE)
        self.gauge1.SetBorderColor(wx.BLACK)

        self.gauge2 = PG.PyGauge(self.mainPanel,
                                 -1,
                                 size=(100, 25),
                                 style=wx.GA_HORIZONTAL)
        self.gauge2.SetValue([20, 80])
        self.gauge2.SetBarColor(
            [wx.Colour(162, 255, 178),
             wx.Colour(159, 176, 255)])
        self.gauge2.SetBackgroundColour(wx.WHITE)
        self.gauge2.SetBorderColor(wx.BLACK)
        self.gauge2.SetBorderPadding(2)
        self.gauge2.Update([30, 0], 2000)

        self.gauge3 = PG.PyGauge(self.mainPanel,
                                 -1,
                                 size=(100, 25),
                                 style=wx.GA_HORIZONTAL)
        self.gauge3.SetValue(50)
        self.gauge3.SetBarColor(wx.GREEN)
        self.gauge3.SetBackgroundColour(wx.WHITE)
        self.gauge3.SetBorderColor(wx.BLACK)

        self.backColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.gauge3.GetBackgroundColour())
        self.borderColour = wx.ColourPickerCtrl(
            self.mainPanel, colour=self.gauge3.GetBorderColour())
        self.barColour = wx.ColourPickerCtrl(self.mainPanel,
                                             colour=self.gauge3.GetBarColour())
        self.gaugeValue = wx.TextCtrl(self.mainPanel,
                                      -1,
                                      str(self.gauge3.GetValue()),
                                      style=wx.TE_PROCESS_ENTER)
        self.gaugeRange = wx.TextCtrl(self.mainPanel,
                                      -1,
                                      str(self.gauge3.GetRange()),
                                      style=wx.TE_PROCESS_ENTER)
        self.gaugePadding = wx.TextCtrl(self.mainPanel,
                                        -1,
                                        str(self.gauge3.GetBorderPadding()),
                                        style=wx.TE_PROCESS_ENTER)

        self.DoLayout()
        self.BindEvents()
 def processArgumentNotation(self, argument, parent):
     type = argument.get("TYPE")
     elementToReturn = None
     if type:
         type = type.split()  # split on space
         typeOfElement = type[0]
         typeArguments = type[1:]  # all elements other then the first
         if typeOfElement == "FILE":
             if len(typeArguments) == 0:
                 elementToReturn = wx.FilePickerCtrl(parent=parent,
                                                     message="Open file",
                                                     style=wx.FD_OPEN)
             else:
                 elementToReturn = wx.FilePickerCtrl(
                     parent=parent,
                     message="Open file",
                     wildcard=self.wildcardReturn(typeArguments),
                     style=wx.FD_OPEN)
         elif typeOfElement == "DROPDOWN":
             elementToReturn = wx.ComboBox(parent=parent,
                                           choices=typeArguments)
         elif typeOfElement == "SLIDER":
             minValue = None
             maxValue = None
             if len(typeArguments) == 0:
                 minValue = 0
                 maxValue = 100
             else:
                 minValue = int(typeArguments[0])
                 maxValue = int(typeArguments[1])
             elementToReturn = wx.Slider(parent=parent,
                                         minValue=minValue,
                                         maxValue=maxValue,
                                         style=wx.SL_LABELS)
         elif typeOfElement == "COLOR":
             if len(typeArguments) == 0:
                 elementToReturn = wx.ColourPickerCtrl(parent=parent)
             else:
                 elementToReturn = wx.ColourPickerCtrl(
                     parent=parent,
                     colour=wx.Colour(*spectra.html(typeArguments[0]).rgb))
         elif typeOfElement == "TEXT":
             if len(typeArguments) == 0:
                 elementToReturn = wx.TextCtrl(parent=parent, value="")
             else:
                 elementToReturn = wx.TextCtrl(
                     parent=parent,
                     value=typeArguments[0].replace("_", " "))
     else:
         elementToReturn = wx.TextCtrl(parent=parent,
                                       value="")  # just a generic text box
     return elementToReturn
Ejemplo n.º 6
0
    def create_window(self, dialog):
        """
        Create a window with an information message, a color picker, and a sizer.

        Args:
            self
            dialog

        """
        # Create top-level window
        window = wx.Window(dialog, size=(300, 400))

        # Create info message
        self.text = wx.StaticText(window)
        self.update_text()

        # Create colorpicker
        picker = wx.ColourPickerCtrl(window)
        picker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.color_callback)

        # Set sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.text,
                  wx.SizerFlags().CenterHorizontal().Border(wx.TOP, 10))
        sizer.Add(picker,
                  wx.SizerFlags().CenterHorizontal().Border(wx.TOP, 10))
        window.SetSizer(sizer)

        return window
Ejemplo n.º 7
0
    def __init__(self, parent, log):

        self.log = log
        self.enabled = True

        wx.Panel.__init__(self, parent, -1)

        self.sizer_1_staticbox = wx.StaticBox(self, -1, "ZoomBar Options")
        self.zoomSpin = wx.SpinCtrl(self, -1, "3", min=1, max=5)

        self.colourzoom = wx.ColourPickerCtrl(self,
                                              colour=wx.Colour(97, 97, 97))
        self.buttonSize = masked.NumCtrl(self,
                                         value=32,
                                         allowNegative=False,
                                         min=32,
                                         max=72)

        self.centerZoom = wx.CheckBox(self, -1, "Center Zoom")
        self.showReflections = wx.CheckBox(self, -1, "Show Reflections")
        self.showLabels = wx.CheckBox(self, -1, "Show Labels")
        self.enableButton = wx.Button(self, -1, "Disable First Button")

        self.zbp = ZB.ZoomBar(self, -1)

        standard = glob.glob(bitmapDir + "/*96.png")
        reflections = glob.glob(bitmapDir + "/*96Flip40.png")

        separatorImage = bitmapDir + "/separator.gif"
        separatorReflection = bitmapDir + "/separatorFlip.png"
        count = 0

        for std, ref in zip(standard, reflections):
            if random.randint(0, 1) == 1 and count > 0:
                sep1 = wx.Bitmap(separatorImage, wx.BITMAP_TYPE_GIF)
                sep2 = wx.Bitmap(separatorReflection, wx.BITMAP_TYPE_PNG)
                self.zbp.AddSeparator(sep1, sep2)

            bname = os.path.split(std)[1][0:-6]
            self.zbp.AddButton(wx.Bitmap(std, wx.BITMAP_TYPE_PNG),
                               wx.Bitmap(ref, wx.BITMAP_TYPE_PNG), bname)
            count += 1

        self.zbp.ResetSize()

        self.SetProperties()
        self.DoLayout()

        self.Bind(wx.EVT_SPINCTRL, self.OnZoomFactor, self.zoomSpin)
        self.Bind(wx.EVT_CHECKBOX, self.OnCenterZoom, self.centerZoom)
        self.Bind(wx.EVT_CHECKBOX, self.OnShowReflections,
                  self.showReflections)
        self.Bind(wx.EVT_CHECKBOX, self.OnShowLabels, self.showLabels)
        self.Bind(wx.EVT_BUTTON, self.OnEnable, self.enableButton)

        self.Bind(masked.EVT_NUM, self.OnButtonSize, self.buttonSize)

        self.colourzoom.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnZoomColour)

        self.Bind(ZB.EVT_ZOOMBAR, self.OnZoomBar)
Ejemplo n.º 8
0
    def __init__(self, parent, posVal, colour=wx.BLACK, alpha=wx.ALPHA_OPAQUE):
        wx.Panel.__init__(self, parent)

        # make some widgets
        self.pos = wx.SpinCtrlDouble(self,
                                     value='%2f' % posVal,
                                     size=(65, -1),
                                     min=0.0,
                                     max=1.0,
                                     initial=posVal,
                                     inc=0.01)
        self.pos.SetToolTipString(
            "A value between 0 and 1 representing the distance between (x1,y1) "
            "and (x2,y2) for this gradient stop.")
        self.colour = wx.ColourPickerCtrl(self, col=colour)
        self.colour.SetToolTipString("The colour for this gradient stop")
        self.minusBtn = wx.Button(self, -1, " - ", style=wx.BU_EXACTFIT)
        self.minusBtn.SetToolTipString("Remove this gradient stop")

        # put them in a sizer
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.pos, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(self.colour, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10)
        sizer.Add(self.minusBtn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 25)
        border = wx.BoxSizer()
        border.Add(sizer, 1, wx.EXPAND | wx.ALL, 4)
        self.SetSizer(border)

        self.Bind(wx.EVT_BUTTON, self.OnMinusButton, self.minusBtn)
Ejemplo n.º 9
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          title=wx.EmptyString,
                          pos=wx.DefaultPosition,
                          size=wx.Size(500, 300),
                          style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        sbSizer1 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"label"),
                                     wx.VERTICAL)

        m_sdbSizer1 = wx.StdDialogButtonSizer()
        self.m_sdbSizer1OK = wx.Button(self, wx.ID_OK)
        m_sdbSizer1.AddButton(self.m_sdbSizer1OK)
        self.m_sdbSizer1Cancel = wx.Button(self, wx.ID_CANCEL)
        m_sdbSizer1.AddButton(self.m_sdbSizer1Cancel)
        m_sdbSizer1.Realize()

        sbSizer1.Add(m_sdbSizer1, 1, wx.EXPAND, 5)

        self.m_colourPicker1 = wx.ColourPickerCtrl(self, wx.ID_ANY, wx.BLACK,
                                                   wx.DefaultPosition,
                                                   wx.DefaultSize,
                                                   wx.CLRP_DEFAULT_STYLE)
        sbSizer1.Add(self.m_colourPicker1, 0, wx.ALL, 5)

        self.SetSizer(sbSizer1)
        self.Layout()

        self.Centre(wx.BOTH)
Ejemplo n.º 10
0
    def _CreateColorControl(self, label: str, alpha_label: str,
                            color_callback: ColorCallback, alpha_callback: FloatCallback,
                            sizer: wx.Sizer, alpha_range: Tuple[float, float] = (0, 1)) \
            -> Tuple[wx.ColourPickerCtrl, wx.TextCtrl]:
        """Helper method for creating a color control and adding it to the form.

        Args:
            label: The label text for the color control.
            alpha_label: The label text for the alpha control. Relevant only on Windows.
            color_callback: Callback called when the color changes.
            alpha_callback: Callback called when the alpha changes. Relevant only on Windows.
            sizer: The sizer to which widgets should be added.
            alpha_range: The inclusive range for the alpha value.

        Returns:
            A tuple of the color control and the alpha control.
        """
        ctrl = wx.ColourPickerCtrl(self)
        ctrl.Bind(wx.EVT_COLOURPICKER_CHANGED, color_callback)
        self._AppendControl(sizer, label, ctrl)

        alpha_ctrl = None

        if on_msw():
            # Windows does not support picking alpha in color picker. So we add an additional
            # field for that
            alpha_ctrl = wx.TextCtrl(self)
            self._AppendControl(sizer, alpha_label, alpha_ctrl)
            callback = self._MakeFloatCtrlFunction(alpha_ctrl.GetId(),
                                                   alpha_callback, alpha_range)
            alpha_ctrl.Bind(wx.EVT_TEXT, callback)

        return ctrl, alpha_ctrl
Ejemplo n.º 11
0
 def create_color_picker(self, parent, text, name, color):
     hbox = wx.BoxSizer(wx.HORIZONTAL)
     hbox.Add(wx.StaticText(parent, label=text), flag=wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
     picker = wx.ColourPickerCtrl(parent, name=name, colour=color)
     hbox.Add(picker, proportion=1, flag=wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL)
     picker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_color_picked)
     return hbox
Ejemplo n.º 12
0
    def addAppearanceSetting(self, fgColorSection, fgColorSetting,
                             bgColorSection, bgColorSetting, fontSection,
                             fontSetting, iconSection, iconSetting, text):
        currentFgColor = self.getvalue(fgColorSection, fgColorSetting)
        fgColorButton = wx.ColourPickerCtrl(self, col=currentFgColor)
        currentBgColor = self.getvalue(bgColorSection, bgColorSetting)
        bgColorButton = wx.ColourPickerCtrl(self, col=currentBgColor)
        defaultFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        nativeInfoString = self.gettext(fontSection, fontSetting)
        currentFont = wx.FontFromNativeInfoString(
            nativeInfoString) if nativeInfoString else None
        fontButton = widgets.FontPickerCtrl(self,
                                            font=currentFont or defaultFont,
                                            colour=currentFgColor)
        fontButton.SetBackgroundColour(currentBgColor)
        iconEntry = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY)
        imageNames = sorted(artprovider.chooseableItemImages.keys())
        for imageName in imageNames:
            label = artprovider.chooseableItemImages[imageName]
            bitmap = wx.ArtProvider_GetBitmap(imageName, wx.ART_MENU, (16, 16))
            item = iconEntry.Append(label, bitmap)
            iconEntry.SetClientData(item, imageName)
        currentIcon = self.gettext(iconSection, iconSetting)
        currentSelectionIndex = imageNames.index(currentIcon)
        iconEntry.SetSelection(currentSelectionIndex)  # pylint: disable=E1101

        self.addEntry(
            text,
            fgColorButton,
            bgColorButton,
            fontButton,
            iconEntry,
            flags=(
                wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                wx.ALL | wx.
                ALIGN_CENTER_VERTICAL,  # wx.EXPAND causes the button to be top aligned on Mac OS X
                wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL))
        self._colorSettings.append(
            (fgColorSection, fgColorSetting, fgColorButton))
        self._colorSettings.append(
            (bgColorSection, bgColorSetting, bgColorButton))
        self._iconSettings.append((iconSection, iconSetting, iconEntry))
        self._fontSettings.append((fontSection, fontSetting, fontButton))
        self._syncers.append(
            FontColorSyncer(fgColorButton, bgColorButton, fontButton))
Ejemplo n.º 13
0
    def _createLabelAndColorPicker(
            self, title: str,
            sizer: wx.Sizer) -> Tuple[wx.StaticText, wx.ColourPickerCtrl]:
        label = wx.StaticText(self, label=title)
        colorPicker = wx.ColourPickerCtrl(self)

        self._addLabelAndControlToSizer(sizer, label, colorPicker)
        return (label, colorPicker)
Ejemplo n.º 14
0
 def get_specific_widget(self, parent):
     import wx
     self.widget = wx.ColourPickerCtrl(parent,
                                       colour=wx.Colour(self.value),
                                       style=wx.CLRP_USE_TEXTCTRL)
     self.widget.SetValue = self.widget.SetColour
     self.widget.LayoutDirection = wx.Layout_RightToLeft
     return self.widget
Ejemplo n.º 15
0
 def _createColorPicker(self, currentColor, defaultColor):
     # wx.ColourPickerCtrl on Mac OS X expects a wx.Colour and fails on tuples
     # so convert the tuples to a wx.Colour:
     currentColor = wx.Colour(
         *currentColor) if currentColor else defaultColor  # pylint: disable=W0142
     picker = wx.ColourPickerCtrl(self, col=currentColor)
     picker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.onColorPicked)
     return picker
Ejemplo n.º 16
0
    def _createLabelAndColorPicker(self, text, sizer):
        label = wx.StaticText(self, label=text)

        colorPicker = wx.ColourPickerCtrl(self)

        self._addControlsPairToSizer(sizer, label, colorPicker)

        return (label, colorPicker)
Ejemplo n.º 17
0
    def LayoutItems(self):

        self.stc = PythonSTC(self.panel, -1)
        try:
            fid = open("RulerCtrl.py", "rt")
        except:
            fid = open("agw/RulerCtrl.py", "rt")

        text = fid.read()
        fid.close()
        self.stc.SetValue(text)

        self.ruler1 = RC.RulerCtrl(self.panel, -1, orient=wx.HORIZONTAL, style=wx.SUNKEN_BORDER)
        self.ruler2 = RC.RulerCtrl(self.panel, -1, orient=wx.VERTICAL, style=wx.SUNKEN_BORDER)
        self.ruler3 = RC.RulerCtrl(self.panel, -1, orient=wx.HORIZONTAL)

        self.rightbottomsizer_staticbox1 = wx.StaticBox(self.panel, -1, "Options")
        self.rightbottomsizer_staticbox2 = wx.StaticBox(self.panel, -1, "Messages")

        self.rulerformat = wx.ComboBox(self.panel, -1, choices=["Integer", "Real", "Time", "LinearDB"],
                                       style=wx.CB_DROPDOWN|wx.CB_READONLY)
        self.flip = wx.CheckBox(self.panel, -1, "Flip")
        self.logscale = wx.CheckBox(self.panel, -1, "Log Scale")
        self.labelminor = wx.CheckBox(self.panel, -1, "Label")
        self.alwayslabel = wx.CheckBox(self.panel, -1, "Always Label")
        self.csel1 = wx.ColourPickerCtrl(self.panel, -1, wx.WHITE, style=wx.CLRP_USE_TEXTCTRL)
        self.csel2 = wx.ColourPickerCtrl(self.panel, -1, wx.BLACK, style=wx.CLRP_USE_TEXTCTRL)
        self.csel3 = wx.ColourPickerCtrl(self.panel, -1, wx.BLACK, style=wx.CLRP_USE_TEXTCTRL)
        self.messages = wx.TextCtrl(self.panel, -1, "Here You'll See GUI Messages\n",
                                    style=wx.TE_READONLY|wx.TE_MULTILINE)

        self.SetProperties()
        self.DoLayout()

        self.Bind(wx.EVT_COMBOBOX, self.OnComboFormat, self.rulerformat)
        self.Bind(wx.EVT_CHECKBOX, self.OnFlip, self.flip)
        self.Bind(wx.EVT_CHECKBOX, self.OnLogScale, self.logscale)
        self.Bind(wx.EVT_CHECKBOX, self.OnLabelMinor, self.labelminor)
        self.Bind(wx.EVT_CHECKBOX, self.OnAlwaysLabel, self.alwayslabel)
        self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnBackgroundColour, self.csel1)
        self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnTickColour, self.csel2)
        self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnLabelColour, self.csel3)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        self.Bind(RC.EVT_INDICATOR_CHANGING, self.OnIndicatorChanging, id=103)
        self.Bind(RC.EVT_INDICATOR_CHANGED, self.OnIndicatorChanged, id=101, id2=104)
Ejemplo n.º 18
0
    def __createGui(self):
        self._stylesList = wx.ListBox(self, style=wx.LB_SINGLE)
        self._stylesList.SetMinSize((150, -1))

        self._colorPicker = wx.ColourPickerCtrl(self)
        self._bold = wx.CheckBox(self, label=_(u"Bold"))
        self._italic = wx.CheckBox(self, label=_(u"Italic"))
        self._underline = wx.CheckBox(self, label=_(u"Underline"))
Ejemplo n.º 19
0
    def __init__(self,
                 panel,
                 label,
                 configName,
                 defaultValue='',
                 helpText='Help: TODO',
                 type='profile'):
        "Add a setting to the configuration panel"
        sizer = panel.GetSizer()
        x = sizer.GetRows()
        y = 0
        flag = 0

        self.validators = []
        self.validationMsg = ''
        self.helpText = helpText
        self.configName = configName
        self.panel = panel
        self.type = type

        self.label = wx.lib.stattext.GenStaticText(panel, -1, label)
        self.label.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
        self.label.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit)

        getSettingFunc = profile.getPreference
        if self.type == 'profile':
            getSettingFunc = profile.getProfileSetting
        if isinstance(defaultValue, types.StringTypes):
            self.ctrl = wx.TextCtrl(panel, -1, getSettingFunc(configName))
            self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
            flag = wx.EXPAND
        elif isinstance(defaultValue, types.BooleanType):
            self.ctrl = wx.CheckBox(panel, -1, style=wx.ALIGN_RIGHT)
            self.SetValue(getSettingFunc(configName))
            self.ctrl.Bind(wx.EVT_CHECKBOX, self.OnSettingChange)
        elif isinstance(defaultValue, wx.Colour):
            self.ctrl = wx.ColourPickerCtrl(panel, -1)
            self.SetValue(getSettingFunc(configName))
            self.ctrl.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnSettingChange)
        else:
            self.ctrl = wx.ComboBox(panel,
                                    -1,
                                    getSettingFunc(configName),
                                    choices=defaultValue,
                                    style=wx.CB_DROPDOWN | wx.CB_READONLY)
            self.ctrl.Bind(wx.EVT_COMBOBOX, self.OnSettingChange)
            flag = wx.EXPAND

        sizer.Add(self.label, (x, y), flag=wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(self.ctrl, (x, y + 1), flag=wx.ALIGN_BOTTOM | flag)
        sizer.SetRows(x + 1)

        self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
        self.ctrl.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit)

        self.defaultBGColour = self.ctrl.GetBackgroundColour()

        panel.main.settingControlList.append(self)
Ejemplo n.º 20
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)

        self.log = log
        self.mainPanel = wx.Panel(self)
        self.mainPanel.SetBackgroundColour(wx.WHITE)
        # Initialize GradientButton 1 (no image)
        self.btn1 = GB.GradientButton(self.mainPanel, -1, None, "Hello World!")
        # Initialize GradientButton 2 (with image)
        bitmap = wx.Bitmap(os.path.normpath(bitmapDir+"gradientbutton.png"), wx.BITMAP_TYPE_PNG)
        self.btn2 = GB.GradientButton(self.mainPanel, -1, bitmap, "GradientButton")

        self.topStartColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetTopStartColour(),
                                                  name="Top Start")
        self.topEndColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetTopEndColour(),
                                                name="Top End")
        self.bottomStartColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetBottomStartColour(),
                                                     name="Bottom Start")
        self.bottomEndColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetBottomEndColour(),
                                                   name="Bottom End")
        self.pressedTopColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetPressedTopColour(),
                                                    name="Pressed Top")
        self.pressedBottomColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetPressedBottomColour(),
                                                       name="Pressed Bottom")
        self.textColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetForegroundColour(),
                                              name="Text Colour")

        self.DoLayout()
        self.BindEvents()
Ejemplo n.º 21
0
    def _createNonHeaderWidgets(self):
        self.imagePropsStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.ImageProperties")) #$NON-NLS-1$
        self.sizeStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Size")) #$NON-NLS-1$
        self.alignmentStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Alignment")) #$NON-NLS-1$
        self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Border")) #$NON-NLS-1$

        self.srcLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Src")) #$NON-NLS-1$ #$NON-NLS-2$
        self.altTextLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.ALTText")) #$NON-NLS-1$ #$NON-NLS-2$
        self.titleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Title")) #$NON-NLS-1$ #$NON-NLS-2$
        self.classLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Class")) #$NON-NLS-1$ #$NON-NLS-2$

        self.widthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.heightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Height")) #$NON-NLS-1$ #$NON-NLS-2$
        wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" #$NON-NLS-1$
        self.filePicker = wx.FilePickerCtrl(self, wildcard=wildcard,style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST )#|wx.FLP_USE_TEXTCTRL)

        self.srcText = ZValidatingTextCtrl(ZFileUrlSelectionValidator(_extstr(u"imagedialog.InvalidImageURLError")), self, wx.ID_ANY) #$NON-NLS-1$
        self.altText = wx.TextCtrl(self, wx.ID_ANY)
        self.titleText = wx.TextCtrl(self, wx.ID_ANY)
        self.classText = wx.TextCtrl(self, wx.ID_ANY)

        self.lockAspect = wx.CheckBox(self,wx.ID_ANY, u"%s" % _extstr(u"imagedialog.LockAspect")) #$NON-NLS-2$ #$NON-NLS-1$
        flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.ALLOW_ZERO | ZIntegerSelectionValidator.POSITIVE_ONLY
        self.widthText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)
        self.heightText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY)

        alignments = []
        for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS:
            alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$
        self.alignChoices = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments)

        self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$
        self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$
        
        borders = []
        for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS:
            borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] )
        
        self.borderStyles = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders)

        self.borderWidthValidator = ZCssLengthSelectionValidator()
        self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY)
        self.borderColorPicker = wx.ColourPickerCtrl(self)

        self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Margin")) #$NON-NLS-1$
        self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$
        self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$

        self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
        self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY)
Ejemplo n.º 22
0
    def base_top_window_menu_sizer_getter(self, frameParent, pluginType,
                                          pluginIcon, **kwargs):
        instrumentNameText = wx.StaticText(self, id=-1, label="Name:")
        self.instrumentNameTextCtrl = wx.TextCtrl(self,
                                                  id=-1,
                                                  value=self.pluginName)

        self.menusizer_staticbox = wx.StaticBox(self, -1, "Menu")
        self.menuStaticSizer = wx.StaticBoxSizer(self.menusizer_staticbox,
                                                 wx.HORIZONTAL)

        instrumentColorText = wx.StaticText(self, id=-1, label="Color:")
        self.colourRed = kwargs.get('colourRed', random.randint(0, 255))
        self.colourGreen = kwargs.get('colourGreen', random.randint(0, 255))
        self.colourBlue = kwargs.get('colourBlue', random.randint(0, 255))
        self.colourAlpha = kwargs.get('colourAlpha', 255)
        self.instrumentColorPicker = wx.ColourPickerCtrl(
            self,
            id=-1,
            colour=wx.Colour(self.colourRed,
                             self.colourGreen,
                             self.colourBlue,
                             alpha=self.colourAlpha))
        if self.isSound:
            self.instrumentNameTextCtrl.Disable()
            self.instrumentColorPicker.Disable()

        saveButton = wx.Button(self, -1,
                               "Modify" if self.isSound else "Generate Sound")

        self.menuStaticSizer.Add(instrumentNameText, 0, wx.ALL | wx.EXPAND, 5)
        self.menuStaticSizer.Add(self.instrumentNameTextCtrl, 2,
                                 wx.ALL | wx.EXPAND, 5)
        self.menuStaticSizer.Add(instrumentColorText, 0, wx.ALL | wx.EXPAND, 5)
        self.menuStaticSizer.Add(self.instrumentColorPicker, 0,
                                 wx.ALL | wx.EXPAND, 5)
        self.menuStaticSizer.Add(saveButton, 0, wx.ALL | wx.EXPAND, 5)

        self.frameParent = frameParent
        self.icon = pluginIcon
        self.pluginType = pluginType
        self.iconSize = (100, 50)
        self.Bind(wx.EVT_CHAR_HOOK, self.on_char)
        self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_color_changed,
                  self.instrumentColorPicker)

        if self.isSound:
            self.win.Bind(wx.EVT_CLOSE, self.on_exit_app)
            self.Bind(wx.EVT_WINDOW_DESTROY, self.on_close)
            self.Bind(wx.EVT_BUTTON, self.on_modify)
        else:
            self.Bind(wx.EVT_BUTTON, self.on_save)

        return self.menuStaticSizer
Ejemplo n.º 23
0
    def __init__(self, parent, *args, **kwds):

        wx.Panel.__init__(self, parent)

        self.CB_type = wx.ComboBox(self,
                                   -1,
                                   choices=['slider', 'knob', 'button'])
        self.TC_label = wx.TextCtrl(self, -1, value='label')
        self.SC_posx = wx.SpinCtrl(self,
                                   -1,
                                   size=(60, 25),
                                   min=-sys.maxint,
                                   max=sys.maxint,
                                   initial=20)
        self.SC_posy = wx.SpinCtrl(self,
                                   -1,
                                   size=(60, 25),
                                   min=-sys.maxint,
                                   max=sys.maxint,
                                   initial=20)
        self.RB_size = wx.RadioBox(self, -1, choices=['Big ', 'Small '])

        self.SC_minvalue = wx.SpinCtrl(self,
                                       -1,
                                       size=(75, 25),
                                       min=-sys.maxint,
                                       max=sys.maxint,
                                       initial=0)
        self.SC_defvalue = wx.SpinCtrl(self,
                                       -1,
                                       size=(75, 25),
                                       min=-sys.maxint,
                                       max=sys.maxint,
                                       initial=20)
        self.SC_maxvalue = wx.SpinCtrl(self,
                                       -1,
                                       size=(75, 25),
                                       min=-sys.maxint,
                                       max=sys.maxint,
                                       initial=100)
        self.CB_orientation = wx.ComboBox(self,
                                          -1,
                                          choices=['H', 'V'],
                                          style=wx.CB_READONLY)
        self.CP_ColorPicker = wx.ColourPickerCtrl(self,
                                                  -1,
                                                  size=(75, 25),
                                                  style=wx.CLRP_SHOW_LABEL)
        self.TC_csdchannel = wx.TextCtrl(self, -1, value='channel')

        self.__set_properties()
        self.__do_layout()
Ejemplo n.º 24
0
    def __init__(self, parent):
        wx.Frame.__init__(self, None, size=(350, 250), title='Settings')
        self.parent = parent
        self.panel = wx.Panel(self,
                              -1,
                              style=(wx.MINIMIZE_BOX | wx.SYSTEM_MENU
                                     | wx.CAPTION | wx.CLOSE_BOX),
                              size=(350, 250))

        icon(self)

        self.Centre()
        self.panel.SetBackgroundColour("white")

        # SettingsPanel objects
        self.backcolour = wx.StaticText(self.panel,
                                        label="Set background colour:",
                                        pos=(10, 13))
        self.BackgroundColourPick = wx.ColourPickerCtrl(
            self.panel,
            col=self.parent.MainPanel.GraphColor,
            pos=(140, 10),
            size=(99, 25))

        self.axcolour = wx.StaticText(self.panel,
                                      label="Set axis colour:",
                                      pos=(10, 40))
        self.AxisColourPick = wx.ColourPickerCtrl(
            self.panel,
            col=self.parent.MainPanel.AxisColor,
            pos=(140, 40),
            size=(99, 25))

        self.backgroundButton = wx.Button(self.panel,
                                          label="Apply settings",
                                          pos=(70, 100),
                                          size=(120, 50))

        self.Bind(wx.EVT_BUTTON, self.onbutton, self.backgroundButton)
Ejemplo n.º 25
0
    def __init__(self, parent, *args, **kwds):

        wx.Dialog.__init__(self, parent)
        #declara objetos

        ###OBJETOS COMUNES
        self.B_texture_fn = wx.Button(self, -1, "BG Filename")
        self.TC_texture_fn = wx.TextCtrl(self)
        self.CB_graphic_set = wx.ComboBox(self,
                                          -1,
                                          choices=['moog', 'roland'],
                                          value='moog')
        self.B_csdfile = wx.Button(self, -1, 'CSD Filename')
        self.TC_csdfile = wx.TextCtrl(self)

        self.SC_fontsize = wx.SpinCtrl(self,
                                       -1,
                                       size=(75, 25),
                                       min=-sys.maxint,
                                       max=sys.maxint,
                                       initial=7)
        self.CB_fontfamily = wx.ComboBox(self,
                                         choices=[
                                             'default', 'decorative', 'roman',
                                             'script', 'swiss', 'modern',
                                             'teletype', 'max'
                                         ],
                                         value='default')
        self.CB_fontstyle = wx.ComboBox(
            self, choices=['normal', 'italic', 'slant', 'max'], value='normal')
        self.CB_fontweight = wx.ComboBox(
            self, choices=['normal', 'light', 'bold', 'max'], value='normal')
        self.ColorPicker = wx.ColourPickerCtrl(self,
                                               -1,
                                               size=(75, 25),
                                               style=wx.CLRP_SHOW_LABEL)

        #######
        #Aqui se crearan los panel de cada instrumento
        self.listapanelines = []
        #####
        self.B_addInstrument = wx.Button(self, -1, "+")
        self.B_save = wx.Button(self, -1, "Save")
        #binds
        self.Bind(wx.EVT_BUTTON, self.OnOpenBG, self.B_texture_fn)
        self.Bind(wx.EVT_BUTTON, self.OnOpenCSD, self.B_csdfile)
        self.Bind(wx.EVT_BUTTON, self.AddPanelin, self.B_addInstrument)
        self.Bind(wx.EVT_BUTTON, self.OnSave, self.B_save)

        self.__set_properties()
        self.__do_layout()
Ejemplo n.º 26
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)
        self.log = log

        self.mainPanel = wx.Panel(self)

        # Initialize Peak Meter control 1
        self.vertPeak = PM.PeakMeterCtrl(self.mainPanel,
                                         -1,
                                         style=PM.PM_VERTICAL
                                         | wx.SIMPLE_BORDER)
        # Initialize Peak Meter control 2
        self.horzPeak = PM.PeakMeterCtrl(self.mainPanel,
                                         -1,
                                         style=PM.PM_HORIZONTAL
                                         | wx.SUNKEN_BORDER)

        self.startButton = wx.Button(self.mainPanel, -1, "Start")
        self.stopButton = wx.Button(self.mainPanel, -1, "Stop")
        self.staticLine = wx.StaticLine(self.mainPanel)

        self.gridCheck = wx.CheckBox(self.mainPanel, -1, "Show Grid")
        self.falloffCheck = wx.CheckBox(self.mainPanel, -1,
                                        "Show Falloff Effect")

        colour = self.mainPanel.GetBackgroundColour()
        self.backColour = wx.ColourPickerCtrl(self.mainPanel, col=colour)
        self.lowColour = wx.ColourPickerCtrl(self.mainPanel, col=wx.GREEN)
        self.mediumColour = wx.ColourPickerCtrl(self.mainPanel,
                                                col=wx.NamedColour("yellow"))
        self.highColour = wx.ColourPickerCtrl(self.mainPanel, col=wx.RED)

        self.timer = wx.Timer(self)

        self.SetProperties()
        self.DoLayout()
        self.BindEvents()
Ejemplo n.º 27
0
    def create_window(self, dialog):
        """
        Create a window to do the structural analysis.
        Args:
            self
            dialog
        """
        topPanel = wx.Panel(dialog, pos=(0, 0), size=(700, 500))

        # Create two panels size by side
        panel1 = wx.Panel(topPanel, -1, pos=(0, 100), size=(200, 100))
        panel2 = wx.Panel(topPanel, -1, pos=(100, 100), size=(450, 100))

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(panel1, 0, wx.EXPAND | wx.ALL, border=10)
        sizer.Add(panel2, 0, wx.EXPAND | wx.ALL, border=10)

        topPanel.SetSizer(sizer)

        # Add a notebook to the second panel
        nb = wx.Notebook(panel2)

        # Create the tabs
        self.tab1 = TabOne(nb)
        self.tab2 = TabTwo(nb)
        nb.AddPage(self.tab1, "Stoichiometry")
        nb.AddPage(self.tab2, "Moiety Conservation Laws")

        # Make sure the second panel fills the right side.
        sizer = wx.BoxSizer()
        sizer.Add(nb, 1, wx.EXPAND)
        panel2.SetSizer(sizer)

        Compute_btn = wx.Button(panel1, -1, 'Compute Conservation Laws',
                                (20, 20))
        Compute_btn.Bind(wx.EVT_BUTTON, self.Compute)

        wx.StaticText(panel1, -1, 'Select a row from the table of', (20, 100))
        wx.StaticText(panel1, -1, 'Moiety Conservation Laws', (20, 120))
        wx.StaticText(panel1, -1, 'and pick a color:', (20, 140))

        Picker = wx.ColourPickerCtrl(panel1, pos=(20, 160))
        Picker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.color_callback)

        wx.StaticText(panel1, -1, 'Unhighlight the nodes:', (20, 240))
        Clear_Btn = wx.Button(panel1, -1, 'Clear', (20, 260))
        Clear_Btn.Bind(wx.EVT_BUTTON, self.unhighlight)

        return topPanel
Ejemplo n.º 28
0
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        self.number_of_buttons = 0
        self.templates = [['A', 'B', 'C'], ['D', 'E'], ['F'], ['G', 'H']]

        self.frame = parent

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        widgetSizer = wx.BoxSizer(wx.VERTICAL)
        bottomSizer = wx.BoxSizer(wx.HORIZONTAL)

        # WIDGETSIZER
        for i in range(0, len(self.templates)):
            static_text = wx.StaticText(self, -1, style=wx.ALIGN_LEFT)
            static_text.SetLabel("Plot" + str(i + 1))
            widgetSizer.Add(static_text, 0, wx.CENTER | wx.ALL, 5)

            for j in range(0, len(self.templates[i])):
                hsizer = wx.BoxSizer(wx.HORIZONTAL)
                color_picker = wx.ColourPickerCtrl(
                    self,
                    id=wx.ID_ANY,
                    colour=wx.BLACK,
                    style=wx.CLRP_DEFAULT_STYLE,
                    validator=wx.DefaultValidator,
                    name=self.templates[i][j])
                static_text = wx.StaticText(self, -1, style=wx.ALIGN_LEFT)
                static_text.SetLabel("Color of " + self.templates[i][j])
                hsizer.Add(static_text, 0, wx.EXPAND | wx.RIGHT, 5)
                hsizer.Add(color_picker, 0, wx.EXPAND | wx.LEFT, 5)

                widgetSizer.Add(hsizer,
                                flag=wx.ALL | wx.ALIGN_CENTER,
                                border=5)
        # BOTTOM SIZER
        closeBtn = wx.Button(self, label="Cancel")
        closeBtn.Bind(wx.EVT_BUTTON, self.onClose)
        bottomSizer.Add(closeBtn, 0, wx.CENTER | wx.ALL, 5)

        self.plotBtn = wx.Button(self, label="Plot")
        self.plotBtn.Bind(wx.EVT_BUTTON, self.onPlot)
        bottomSizer.Add(self.plotBtn, 0, wx.CENTER | wx.ALL, 5)

        self.mainSizer.Add(widgetSizer, 0, wx.CENTER | wx.ALL, 10)
        self.mainSizer.Add(bottomSizer, 0, wx.CENTER | wx.ALL, 10)

        self.SetSizer(self.mainSizer)
Ejemplo n.º 29
0
    def _initialize(self):
        self.panel1 = wx.Panel(id=wx.ID_ANY, name='panel1', parent=self,
                               size=wx.DefaultSize, style=wx.TAB_TRAVERSAL)

        #  bottom buttons
        self.btnReset = wx.Button(label='Reset', id=wx.ID_ANY, parent=self.panel1, style=0)
        self.btnReset.SetToolTip('Reset Colors')
        self.btnReset.Bind(wx.EVT_BUTTON, self.OnBtnReset)

        self.btnCancel = wx.Button(label='Cancel', id=wx.ID_ANY, parent=self.panel1, style=0)
        self.btnCancel.SetToolTip('Ignore changes')
        self.btnCancel.Bind(wx.EVT_BUTTON, self.OnBtnCancel)

        self.btnOK = wx.Button(id=wx.ID_ANY, label='OK', parent=self.panel1, style=0)
        self.btnOK.SetToolTip('Exit this Dialog')
        self.btnOK.Bind(wx.EVT_BUTTON, lambda evt: self.OnBtnOK(evt))
        self.btnOK.Disable()

        self._cols = []
        # For each color/status: 
        #    create a sizer containing:
        #        - the type/name of color to tweak (text widget)
        #        - a ColorPicker
        for i in range(len(globs.fileColors)):
            # A Static Text in a box sizer used to center vertically...
            sts = wx.BoxSizer(orient=wx.VERTICAL)
            st = wx.StaticText(id=wx.ID_ANY, label=globs.FILE_COLORS_STATUS[i],
                               name=globs.FILE_COLORS_STATUS[i], parent=self.panel1, style=0)

            sts.Add(4, 4, 1, border=0, flag=wx.EXPAND)
            sts.Add(st, 0, border=0, flag=wx.EXPAND)
            sts.Add(4, 4, 1, border=0, flag=wx.EXPAND)

            sb = wx.StaticBox(id=wx.ID_ANY, label='', parent=self.panel1, style=0)
            defcol = globs.fileColors[i][0]
            cp = wx.ColourPickerCtrl(parent=self.panel1, id=wx.ID_ANY, colour=defcol, 
                                     style=wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
            cp.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)

            sbs = wx.StaticBoxSizer(box=sb, orient=wx.HORIZONTAL)
            sbs.Add(sts, 0, border=5, flag=wx.EXPAND | wx.ALL)    # Static Text
            sbs.Add(4, 4, 1, border=0, flag=wx.EXPAND)
            sbs.Add(cp, 0, border=5, flag=wx.EXPAND)    # Color Picker
            # Store [sizer, colorpicker] for this color
            self._cols.append([sbs, cp])

        self._init_sizers()
Ejemplo n.º 30
0
    def createColor(self, parent, sizer, label, defaultColor, prop,
                    changeProp):
        """
        Создать элементы для выбора цвета фона узла
        self._obj - объект диалога, для которого добавляются контролы и члены
        sizer - сайзер, куда нужно поместить контролы
        label - имя метки перед свойством
        defaultColor - цвет по умолчанию
        prop - имя свойства, которое будет добавлено в класс объекта self._obj для получения и изменения цвета
        changeProp - имя свойства, котороу будет добавлено в класс объекта self._obj для определения того, что цвет изменился
        """
        _colorCheckBox = wx.CheckBox(parent, label=label)
        _colorPicker = wx.ColourPickerCtrl(parent, col=defaultColor)

        _colorCheckBox.SetValue(False)
        _colorPicker.Enabled = False

        def isColorChangedGetter(self):
            return _colorCheckBox.GetValue()

        def isColorChangedSetter(self, value):
            _colorCheckBox.SetValue(value)

        def colorGetter(self):
            return _colorPicker.GetColour().GetAsString(wx.C2S_NAME
                                                        | wx.C2S_HTML_SYNTAX)

        def colorSetter(self, value):
            _colorPicker.SetColour(value)

        sizer.Add(_colorCheckBox,
                  flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                  border=2)

        sizer.Add(_colorPicker, flag=wx.ALL | wx.EXPAND, border=2)

        PropertyFactory.bindEnabled(self._obj, _colorCheckBox, _colorPicker)

        # Добавим свойства с заданными именами
        setattr(type(self._obj), prop, property(colorGetter, colorSetter))

        setattr(type(self._obj), changeProp,
                property(isColorChangedGetter, isColorChangedSetter))

        return (_colorCheckBox, _colorPicker)