Exemplo n.º 1
0
    def _createStandardDialogWidgets(self):
        self.captionText = wx.StaticText(self.topPanel, wx.ID_ANY, self.caption)
        self.image = None
        bitmap = self._getBitmap()
        if bitmap:
            self.image = wx.StaticBitmap(self.topPanel, wx.ID_ANY, bitmap)

        self.accelTable = ZStandardDialogAcceleratorTable(self, self._getButtonTypes())
        self.SetAcceleratorTable(self.accelTable)
Exemplo n.º 2
0
class ZStandardDialog(ZBaseDialog):
    def __init__(self, parent, title, caption, buttonMask, imageName):
        self.caption = caption
        self.buttonMask = buttonMask
        self.imageName = imageName
        ZBaseDialog.__init__(self, parent, wx.ID_ANY, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        (w, h) = self.GetBestSizeTuple()
        w = min(max(w, 350), 500)
        self.SetSize(wx.Size(w, h))
        self.Layout()

    # end __init__()

    def _createContentWidgets(self):
        self.topPanel = wx.Panel(self, wx.ID_ANY)
        self.topPanel.SetBackgroundColour(wx.WHITE)

        self._createStandardDialogWidgets()

        self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)

    # end _createContentWidgets()

    def _createStandardDialogWidgets(self):
        self.captionText = wx.StaticText(self.topPanel, wx.ID_ANY, self.caption)
        self.image = None
        bitmap = self._getBitmap()
        if bitmap:
            self.image = wx.StaticBitmap(self.topPanel, wx.ID_ANY, bitmap)

        self.accelTable = ZStandardDialogAcceleratorTable(self, self._getButtonTypes())
        self.SetAcceleratorTable(self.accelTable)

    # end _createStandardDialogWidgets()

    def _layoutContentWidgets(self):
        sizer = self._layoutTopPanel()

        self.topPanel.SetSizer(sizer)
        self.topPanel.SetAutoLayout(True)

        vertSizer = wx.BoxSizer(wx.VERTICAL)
        vertSizer.Add(self.topPanel, 1, wx.EXPAND)
        vertSizer.Add(self.staticLine, 0, wx.EXPAND)
        return vertSizer

    # end _layoutContentWidgets()

    def _layoutTopPanel(self):
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        if self.image:
            sizer.Add(self.image, 0, wx.LEFT | wx.TOP | wx.BOTTOM, 10)

        sizer.Add(self.captionText, 1, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, 10)
        return sizer

    # end _layoutTopPanel()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_BUTTON, self.onYes, None, wx.ID_YES)
        self.Bind(wx.EVT_BUTTON, self.onNo, None, wx.ID_NO)

        self.accelTable.bindTo(self)

    # end _bindWidgetEvents()

    def onYes(self, event):
        self.EndModal(wx.ID_YES)
        event.Skip()

    # end onYes()

    def onNo(self, event):
        self.EndModal(wx.ID_NO)
        event.Skip()

    # end onNo()

    def _getBitmap(self):
        if not self.imageName:
            return None
        path = os.path.join(
            u"images", u"widgets", u"standard_dialog", self.imageName + u".png"
        )  # $NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$ #$NON-NLS-4$
        return getApplicationModel().getResourceRegistry().getBitmap(path)

    # end _getBitmap()

    def _getButtonTypes(self):
        return self.buttonMask