示例#1
0
    def setup_gui(self):        
        fontBtn = button(self, wx.NewId(), _("Select Font"), self.on_font)
        self.colourBtn = wx.ColourPickerCtrl(self)
        self.okButton = wx.Button(self, wx.ID_OK, _("&OK"))
        self.cancelButton = wx.Button(self, wx.ID_CANCEL, _("&Cancel"))
        self.colourBtn.SetColour(self.colour)

        font_colour_sizer = wx.BoxSizer(wx.HORIZONTAL)
        font_colour_sizer.Add(fontBtn, 0, wx.RIGHT, 5)
        font_colour_sizer.Add(self.colourBtn, 0)
        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(self.okButton)
        btnSizer.AddButton(self.cancelButton)
        btnSizer.Realize()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.ctrl, 1, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 10)
        sizer.Add(font_colour_sizer, 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.LEFT | wx.TOP, 10)
        sizer.Add((10, 10))  # Spacer.
        sizer.Add(btnSizer, 0, wx.BOTTOM | wx.ALIGN_CENTRE, 10)
        self.SetSizer(sizer)
        
        self.okButton.SetDefault()        
        fix_std_sizer_tab_order(btnSizer)
        self.set_focus()
        
        self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_colour, self.colourBtn)
        self.Bind(wx.EVT_TEXT, self.update_canvas, self.ctrl)

        ac = [(wx.ACCEL_CTRL, wx.WXK_RETURN, self.okButton.GetId())]
        tbl = wx.AcceleratorTable(ac)
        self.SetAcceleratorTable(tbl)
示例#2
0
    def __init__(self, gui, name, method, style, args):
        wx.Dialog.__init__(self, gui, title=_("Save File?"))
        self.gui = gui
        self.method = method
        self.args = args
        logger.debug("Prompting for save, with method %s and arguments %s", method, args)

        warning = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_CMN_DIALOG)
        bmp = wx.StaticBitmap(self, bitmap=warning)
        btnSizer = wx.StdDialogButtonSizer()
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        iconSizer = wx.BoxSizer(wx.HORIZONTAL)
        textSizer = wx.BoxSizer(wx.VERTICAL)
        container = wx.BoxSizer(wx.HORIZONTAL)

        top_message = wx.StaticText(self, label=_('Save changes to "%s" before closing?') % name)
        bottom_message = wx.StaticText(self, label=self.get_time())

        font = create_bold_font()
        font.SetPointSize(font.GetPointSize() + 1)
        top_message.SetFont(font)

        if not self.gui.util.filename:
            saveButton = button(self, wx.ID_SAVE, _("Save &As..."), self.okay)
        else:
            saveButton = button(self, wx.ID_SAVE, _("&Save"), self.okay)

        if style == wx.YES_NO | wx.CANCEL:
            cancelButton = wx.Button(self, wx.ID_CANCEL, _("&Cancel"))
            btnSizer.AddButton(cancelButton)

        noButton = button(self, wx.ID_NO, _("&Don't Save"), self.no)
        saveButton.SetDefault()

        btnSizer.AddButton(noButton)
        btnSizer.AddButton(saveButton)
        btnSizer.Realize()
        iconSizer.Add(bmp, 0)

        textSizer.Add(top_message)
        textSizer.Add((10, 10))
        textSizer.Add(bottom_message)

        container.Add(iconSizer, 0, wx.LEFT, 15)
        container.Add((15, -1))
        container.Add(textSizer, 1, wx.RIGHT, 15)
        container.Layout()

        mainSizer.Add((10, 15))
        mainSizer.Add(container, wx.ALL, 30)
        mainSizer.Add((10, 10))
        mainSizer.Add(btnSizer, 0, wx.TOP | wx.BOTTOM | wx.ALIGN_CENTRE, 15)

        self.SetSizerAndFit(mainSizer)
        self.SetFocus()
        self.SetAutoLayout(True)
        fix_std_sizer_tab_order(btnSizer)
示例#3
0
    def __init__(self, gui):
        """
        Two spinctrls are used to set the width/height. Canvas updates as the
        values change
        """
        wx.Dialog.__init__(self, gui, title=_("Resize Canvas"))

        self.gui = gui
        gap = wx.LEFT | wx.TOP | wx.RIGHT
        width, height = self.gui.canvas.buffer.GetSize()
        self.size = (width, height)

        self.wctrl = spinctrl(self, 12000, width, self.resize)
        self.hctrl = spinctrl(self, 12000, height, self.resize)

        csizer = wx.GridSizer(cols=2, hgap=1, vgap=2)
        csizer.Add(wx.StaticText(self, label=_("Width:")), 0, wx.TOP |
                                                            wx.ALIGN_RIGHT, 10)
        csizer.Add(self.wctrl, 1, gap, 7)
        csizer.Add(wx.StaticText(self, label=_("Height:")), 0, wx.TOP |
                                                             wx.ALIGN_RIGHT, 7)
        csizer.Add(self.hctrl, 1, gap, 7)

        okButton = button(self, wx.ID_OK, _("&OK"), self.ok)
        okButton.SetDefault()
        cancelButton = button(self, wx.ID_CANCEL, _("&Cancel"), self.cancel)
        applyButton = button(self, wx.ID_APPLY, _("&Apply"), self.apply)

        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(okButton)
        btnSizer.AddButton(cancelButton)
        btnSizer.AddButton(applyButton)
        btnSizer.Realize()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(csizer, 0, gap, 7)
        sizer.Add((10, 15))
        sizer.Add(btnSizer, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        sizer.Add((15, 5))
        self.SetSizer(sizer)
        self.SetFocus()
        self.SetEscapeId(cancelButton.GetId())
        self.Fit()

        fix_std_sizer_tab_order(sizer)