コード例 #1
0
    def __init__(self, editor):
        """ Initializes the object.
        """
        wx.Frame.__init__(self, editor.control, -1, '', style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(WindowColor)
        wx.EVT_ACTIVATE(self, self._on_close_dialog)
        self._closed = False

        dlg_editor = CustomEditor(self,
                                  factory=editor.factory,
                                  ui=editor.ui,
                                  object=editor.object,
                                  name=editor.name,
                                  description=editor.description,
                                  update_handler=self._close_dialog)

        dlg_editor.init(self)

        # Wrap the dialog around the image button panel:
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(dlg_editor.control)
        sizer.Fit(self)

        # Position the dialog:
        position_window(self, parent=editor.control)
        self.Show()
コード例 #2
0
    def edit_instance(self):
        """ Edit the contents of the object trait when the user clicks the
            button.
        """
        # Create the user interface:
        factory = self.factory
        view = self.ui.handler.trait_view_for(self.ui.info, factory.view,
                                              self.value, self.object_name,
                                              self.name)
        ui = self.value.edit_traits(view, kind=factory.kind, id=factory.id)

        # Make sure the editor is properly disposed
        QtCore.QObject.connect(self._button, QtCore.SIGNAL('destroyed()'),
                               lambda: ui.dispose())

        # Check to see if the view was 'modal', in which case it will already
        # have been closed (i.e. is None) by the time we get control back:
        if ui.control is not None:
            # Position the window on the display:
            position_window(ui.control)

            # Chain our undo history to the new user interface if it does not
            # have its own:
            if ui.history is None:
                ui.history = self.ui.history
コード例 #3
0
ファイル: ui_panel.py プロジェクト: zishendianxia/traitsui
    def __init__(self, parent, html, scale_dx, scale_dy):
        """ Initializes the object.
        """
        # Local import to avoid a WebKit dependency when one isn't needed.
        from pyface.qt import QtWebKit

        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create the html control
        html_control = QtWebKit.QWebView()
        html_control.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        html_control.setHtml(html)
        layout.addWidget(html_control)

        # Create the OK button
        bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                      QtCore.Qt.Horizontal)
        bbox.accepted.connect(self.accept)
        layout.addWidget(bbox)

        # Position and show the dialog
        position_window(self, parent=parent)
        self.show()
コード例 #4
0
    def __init__ ( self, parent, html, scale_dx, scale_dy ):
        """ Initializes the object.
        """
        # Local import to avoid a WebKit dependency when one isn't needed.
        from pyface.qt import QtWebKit

        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create the html control
        html_control = QtWebKit.QWebView()
        html_control.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        html_control.setHtml(html)
        layout.addWidget(html_control)

        # Create the OK button
        bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                      QtCore.Qt.Horizontal)
        bbox.accepted.connect(self.accept)
        layout.addWidget(bbox)

        # Position and show the dialog
        position_window(self, parent=parent)
        self.show()
コード例 #5
0
ファイル: instance_editor.py プロジェクト: 5n1p/traitsui
    def edit_instance(self):
        """ Edit the contents of the object trait when the user clicks the
            button.
        """
        # Create the user interface:
        factory = self.factory
        view    = self.ui.handler.trait_view_for( self.ui.info, factory.view,
                                                  self.value, self.object_name,
                                                  self.name )
        ui = self.value.edit_traits( view, kind=factory.kind, id=factory.id )

        # Make sure the editor is properly disposed
        QtCore.QObject.connect( self._button, QtCore.SIGNAL( 'destroyed()' ),
                                lambda: ui.dispose() )

        # Check to see if the view was 'modal', in which case it will already
        # have been closed (i.e. is None) by the time we get control back:
        if ui.control is not None:
            # Position the window on the display:
            position_window( ui.control )

            # Chain our undo history to the new user interface if it does not
            # have its own:
            if ui.history is None:
                ui.history = self.ui.history
コード例 #6
0
ファイル: ui_panel.py プロジェクト: bpteague/traitsui
    def __init__(self, parent, html, scale_dx, scale_dy):
        """ Initializes the object.
        """
        wx.Frame.__init__(self, parent, -1, 'Help', style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(WindowColor)

        # Wrap the dialog around the image button panel:
        sizer = wx.BoxSizer(wx.VERTICAL)
        html_control = wh.HtmlWindow(self)
        html_control.SetBorders(2)
        html_control.SetPage(html)
        sizer.Add(html_control, 1, wx.EXPAND)
        sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
        b_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button = wx.Button(self, -1, 'OK')
        wx.EVT_BUTTON(self, button.GetId(), self._on_ok)
        b_sizer.Add(button, 0)
        sizer.Add(b_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        self.SetSizer(sizer)
        self.SetSize(
            wx.Size(int(scale_dx * screen_dx), int(scale_dy * screen_dy)))

        # Position and show the dialog:
        position_window(self, parent=parent)
        self.Show()
コード例 #7
0
ファイル: image_enum_editor.py プロジェクト: 5n1p/traitsui
    def __init__ ( self, editor ):
        """ Initializes the object.
        """
        wx.Frame.__init__( self, editor.control, -1, '',
                           style = wx.SIMPLE_BORDER )
        self.SetBackgroundColour( WindowColor )
        wx.EVT_ACTIVATE( self, self._on_close_dialog )
        self._closed = False

        dlg_editor = CustomEditor( self,
                                   factory        = editor.factory,
                                   ui             = editor.ui,
                                   object         = editor.object,
                                   name           = editor.name,
                                   description    = editor.description,
                                   update_handler = self._close_dialog )

        dlg_editor.init( self )

        # Wrap the dialog around the image button panel:
        sizer = wx.BoxSizer( wx.VERTICAL )
        sizer.Add( dlg_editor.control )
        sizer.Fit( self )

        # Position the dialog:
        position_window( self, parent = editor.control )
        self.Show()
コード例 #8
0
    def edit_instance(self):
        """ Edit the contents of the object trait when the user clicks the
            button.
        """
        # Create the user interface:
        factory = self.factory
        view = self.ui.handler.trait_view_for(self.ui.info, factory.view,
                                              self.value, self.object_name,
                                              self.name)
        self._dialog_ui = self.value.edit_traits(view,
                                                 kind=factory.kind,
                                                 id=factory.id)

        # Check to see if the view was 'modal', in which case it will already
        # have been closed (i.e. is None) by the time we get control back:
        if self._dialog_ui.control is not None:
            # Position the window on the display:
            position_window(self._dialog_ui.control)

            # Chain our undo history to the new user interface if it does not
            # have its own:
            if self._dialog_ui.history is None:
                self._dialog_ui.history = self.ui.history

        else:
            self._dialog_ui = None
コード例 #9
0
    def edit_instance(self):
        """ Edit the contents of the object trait when the user clicks the
            button.
        """
        # Create the user interface:
        factory = self.factory
        view = self.ui.handler.trait_view_for(self.ui.info, factory.view,
                                              self.value, self.object_name,
                                              self.name)
        self._dialog_ui = self.value.edit_traits(view, kind=factory.kind,
                                                 id=factory.id)

        # Check to see if the view was 'modal', in which case it will already
        # have been closed (i.e. is None) by the time we get control back:
        if self._dialog_ui.control is not None:
            # Position the window on the display:
            position_window(self._dialog_ui.control)

            # Chain our undo history to the new user interface if it does not
            # have its own:
            if self._dialog_ui.history is None:
                self._dialog_ui.history = self.ui.history

        else:
            self._dialog_ui = None
コード例 #10
0
ファイル: ui_panel.py プロジェクト: rwl/traitsui
    def __init__ ( self, parent, html, scale_dx, scale_dy ):
        """ Initializes the object.
        """
        super(HTMLHelpWindow, self).__init__()
        self.setParent(parent)

        layout = VerticalLayout()
        layout.setMargin(False)

        # Create the html control
        html_control = Label(html)
        html_control.setContentMode(Label.CONTENT_XHTML)
        layout.addComponent(html_control)

        # Create the OK button
        ok = Button('OK')
        # FIXME: add event handler
        layout.addComponent(ok)
        layout.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT)

        # Position and show the dialog
        position_window(self, parent=parent)
        self.show()
コード例 #11
0
ファイル: ui_panel.py プロジェクト: jdmarch/traitsui
    def __init__ ( self, parent, html, scale_dx, scale_dy ):
        """ Initializes the object.
        """
        QtGui.QDialog.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create the html control
        html_control = QtWebKit.QWebView()
        html_control.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        html_control.setHtml(html)
        layout.addWidget(html_control)

        # Create the OK button
        bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                      QtCore.Qt.Horizontal)
        QtCore.QObject.connect(bbox, QtCore.SIGNAL('accepted()'),
                               self, QtCore.SLOT('accept()'))
        layout.addWidget(bbox)

        # Position and show the dialog
        position_window(self, parent=parent)
        self.show()
コード例 #12
0
ファイル: ui_panel.py プロジェクト: gdsylzj/traitsui
    def __init__(self, parent, html, scale_dx, scale_dy):
        """ Initializes the object.
        """
        wx.Frame.__init__(self, parent, -1, "Help", style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(WindowColor)

        # Wrap the dialog around the image button panel:
        sizer = wx.BoxSizer(wx.VERTICAL)
        html_control = wh.HtmlWindow(self)
        html_control.SetBorders(2)
        html_control.SetPage(html)
        sizer.Add(html_control, 1, wx.EXPAND)
        sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
        b_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button = wx.Button(self, -1, "OK")
        wx.EVT_BUTTON(self, button.GetId(), self._on_ok)
        b_sizer.Add(button, 0)
        sizer.Add(b_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        self.SetSizer(sizer)
        self.SetSize(wx.Size(int(scale_dx * screen_dx), int(scale_dy * screen_dy)))

        # Position and show the dialog:
        position_window(self, parent=parent)
        self.Show()
コード例 #13
0
ファイル: toolkit.py プロジェクト: timdiller/traitsui
    def position(self, ui):
        """ Positions the associated dialog window on the display.
        """
        view = ui.view
        window = ui.control

        # Set up the default position of the window:
        parent = window.GetParent()
        if parent is None:
            px, py = 0, 0
            pdx, pdy = screen_dx, screen_dy
        else:
            px, py = parent.GetPositionTuple()
            pdx, pdy = parent.GetSizeTuple()

        # Calculate the correct width and height for the window:
        cur_width, cur_height = window.GetSizeTuple()
        width = view.width
        height = view.height

        if width < 0.0:
            width = cur_width
        elif width <= 1.0:
            width = int(width * screen_dx)
        else:
            width = int(width)

        if height < 0.0:
            height = cur_height
        elif height <= 1.0:
            height = int(height * screen_dy)
        else:
            height = int(height)

        if view.kind in Popups:
            position_window(window, width, height)
            return

        # Calculate the correct position for the window:
        x = view.x
        y = view.y

        if x < -99999.0:
            # BH- I think this is the case when there is a parent
            # so this logic tries to place it in the middle of the parent
            # if possible, otherwise tries an offset from the parent
            x = px + (pdx - width) / 2
            if x < 0:
                x = px + 20
        elif x <= -1.0:
            x = px + pdx - width + int(x) + 1
        elif x < 0.0:
            x = px + pdx - width + int(x * pdx)
        elif x <= 1.0:
            x = px + int(x * pdx)
        else:
            x = int(x)

        if y < -99999.0:
            # BH- I think this is the case when there is a parent
            # so this logic tries to place it in the middle of the parent
            # if possible, otherwise tries an offset from the parent
            y = py + (pdy - height) / 2
            if y < 0:
                y = py + 20
        elif y <= -1.0:
            y = py + pdy - height + int(y) + 1
        elif x < 0.0:
            y = py + pdy - height + int(y * pdy)
        elif y <= 1.0:
            y = py + int(y * pdy)
        else:
            y = int(y)

        # make sure the position is on the visible screen, maybe
        # the desktop had been resized?
        x = min(x, wx.DisplaySize()[0])
        y = min(y, wx.DisplaySize()[1])

        # Position and size the window as requested:
        window.SetDimensions(max(0, x), max(0, y), width, height)
コード例 #14
0
ファイル: toolkit.py プロジェクト: 5n1p/traitsui
    def position ( self, ui ):
        """ Positions the associated dialog window on the display.
        """
        view   = ui.view
        window = ui.control

        # Set up the default position of the window:
        parent = window.GetParent()
        if parent is None:
           px,  py  = 0, 0
           pdx, pdy = screen_dx, screen_dy
        else:
           px,  py  = parent.GetPositionTuple()
           pdx, pdy = parent.GetSizeTuple()

        # Calculate the correct width and height for the window:
        cur_width, cur_height = window.GetSizeTuple()
        width  = view.width
        height = view.height

        if width < 0.0:
            width = cur_width
        elif width <= 1.0:
            width = int( width * screen_dx )
        else:
            width = int( width )

        if height < 0.0:
            height = cur_height
        elif height <= 1.0:
            height = int( height * screen_dy )
        else:
            height = int( height )

        if view.kind in Popups:
            position_window( window, width, height )
            return

        # Calculate the correct position for the window:
        x = view.x
        y = view.y

        if x < -99999.0:
            # BH- I think this is the case when there is a parent
            # so this logic tries to place it in the middle of the parent
            # if possible, otherwise tries an offset from the parent
            x = px + (pdx - width)/2
            if x < 0:
                 x = px + 20
        elif x <= -1.0:
            x = px + pdx - width + int( x ) + 1
        elif x < 0.0:
            x = px + pdx - width + int( x * pdx )
        elif x <= 1.0:
            x = px + int( x * pdx )
        else:
            x = int( x )

        if y < -99999.0:
            # BH- I think this is the case when there is a parent
            # so this logic tries to place it in the middle of the parent
            # if possible, otherwise tries an offset from the parent
            y = py + (pdy - height)/2
            if y < 0:
                y = py + 20
        elif y <= -1.0:
            y = py + pdy - height + int( y ) + 1
        elif x < 0.0:
            y = py + pdy - height + int( y * pdy )
        elif y <= 1.0:
            y = py + int( y * pdy )
        else:
            y = int( y )

        # make sure the position is on the visible screen, maybe
        # the desktop had been resized?
        x = min(x, wx.DisplaySize()[0])
        y = min(y, wx.DisplaySize()[1])

        # Position and size the window as requested:
        window.SetDimensions( max( 0, x ), max( 0, y ), width, height )