Пример #1
0
 def select_path(self, path):
     "sets the selected widget from a path_list, which should be in the form returned by get_selected_path"
     index = 0
     item, cookie = self._get_first_child(self.GetRootItem())
     itemok = parent = pos = None
     while item.IsOk() and index < len(path):
         widget = self._GetItemData(item).widget
         name = path[index]
         if index == 0 and isinstance(name, tuple):
             name, pos = name
         if widget.name == name:
             #self.EnsureVisible(item)
             itemok = item
             if parent is None:
                 parent = self._GetItemData(itemok)
             self.cur_widget = widget
             item, cookie = self._get_first_child(item)
             index += 1
         else:
             item = self.GetNextSibling(item)
     if itemok is not None:
         node = self._GetItemData(itemok)
         if parent is not None:
             self._show_widget_toplevel(parent)
             if pos is not None:
                 misc.get_toplevel_parent(parent.widget).SetPosition(pos)
         self.select_item(node)
Пример #2
0
 def select_path(self, path):
     """\
     sets the selected widget from a path_list, which should be in the
     form returned by get_selected_path
     """
     index = 0
     item, cookie = self._get_first_child(self.GetRootItem())
     itemok = None
     parent = None
     pos = None
     while item.Ok() and index < len(path):
         widget = self.GetPyData(item).widget
         name = path[index]
         if index == 0 and type(name) == type(()):
             name, pos = name
         if misc.streq(widget.name, name):
             #print 'OK:', widget.name
             #self.EnsureVisible(item)
             itemok = item
             if parent is None:
                 parent = self.GetPyData(itemok)
             self.cur_widget = widget
             item, cookie = self._get_first_child(item)
             index += 1
         else:
             #print 'NO:', widget.name
             item = self.GetNextSibling(item)
     if itemok is not None:
         node = self.GetPyData(itemok)
         if parent is not None:
             self.show_widget(parent, True)
             if pos is not None:
                 misc.get_toplevel_parent(parent.widget).SetPosition(pos)
         self.select_item(node)
Пример #3
0
 def select_path(self, path):
     """\
     sets the selected widget from a path_list, which should be in the
     form returned by get_selected_path
     """
     index = 0
     item, cookie = self._get_first_child(self.GetRootItem())
     itemok = None
     parent = None
     pos = None
     while item.Ok() and index < len(path):
         widget = self.GetPyData(item).widget
         name = path[index]
         if index == 0 and type(name) == type(()):
             name, pos = name
         if misc.streq(widget.name, name):
             #print 'OK:', widget.name
             #self.EnsureVisible(item)
             itemok = item
             if parent is None:
                 parent = self.GetPyData(itemok)
             self.cur_widget = widget
             item, cookie = self._get_first_child(item)
             index += 1
         else:
             #print 'NO:', widget.name
             item = self.GetNextSibling(item)
     if itemok is not None:
         node = self.GetPyData(itemok)
         if parent is not None:
             self.show_widget(parent, True)
             if pos is not None:
                 misc.get_toplevel_parent(parent.widget).SetPosition(pos)
         self.select_item(node)
Пример #4
0
 def get_selected_path(self):
     """\
     returns a list of widget names, from the toplevel to the selected one
     Example:
     ['frame_1', 'sizer_1', 'panel_1', 'sizer_2', 'button_1']
     if button_1 is the currently selected widget.
     """
     from edit_sizers import SizerBase
     ret = []
     w = self.cur_widget
     oldw = None
     while w is not None:
         oldw = w
         ret.append(w.name)
         sizer = getattr(w, 'sizer', None)
         if getattr(w, 'parent', "") is None:
             w = w.parent
         elif sizer is not None and not sizer.is_virtual():
             w = sizer
         else:
             if isinstance(w, SizerBase):
                 w = w.window
             else:
                 w = w.parent
     ret.reverse()
     # ALB 2007-08-28: remember also the position of the toplevel window in
     # the selected path
     if oldw is not None:
         assert oldw.widget
         pos = misc.get_toplevel_parent(oldw.widget).GetPosition()
         ret[0] = (ret[0], pos)
     return ret
Пример #5
0
    def __init__(self, parent):
        pos = wx.GetMousePosition()
        wx.Dialog.__init__(self, misc.get_toplevel_parent(parent), -1,
                           _("Enter size"), pos)
        # the controls
        self.width = wx.SpinCtrl(self, -1, "20")
        self.height = wx.SpinCtrl(self, -1, "20")
        self.width.SetFocus()
        self.width.SetSelection(-1, -1)
        self.height.SetSelection(-1, -1)
        # the main sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        # grid sizer with the controls
        gsizer = wx.FlexGridSizer(cols=2)
        for label, control in [("Width", self.width), ("Height", self.height)]:
            gsizer.Add(wx.StaticText(self, -1, _(label)), 0,
                       wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
            gsizer.Add(control, 0,
                       wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 3)
        sizer.Add(gsizer)
        # horizontal sizer for action buttons
        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        hsizer.Add(wx.Button(self, wx.ID_CANCEL, _('Cancel')), 1, wx.ALL, 5)
        btn = wx.Button(self, wx.ID_OK, _('OK'))
        btn.SetDefault()
        hsizer.Add(btn, 1, wx.ALL, 5)
        sizer.Add(hsizer, 0, wx.EXPAND | wx.ALIGN_CENTER)

        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        sizer.Fit(self)
Пример #6
0
 def get_selected_path(self, w=None):
     """returns a list of widget names, from the toplevel to the selected one
     Example: ['frame_1', 'sizer_1', 'panel_1', 'sizer_2', 'button_1']
              if button_1 is the currently selected widget"""
     ret = []
     if w is None: w = self.cur_widget
     oldw = None
     while w is not None:
         oldw = w
         if isinstance(w, edit_sizers.SizerSlot):
             ret.append("SLOT %d" % w.pos)
         else:
             ret.append(w.name)
         sizer = getattr(w, 'sizer', None)
         if getattr(w, 'parent', "") is None:
             w = w.parent
         elif sizer is not None and not sizer.is_virtual():
             w = sizer
         else:
             if isinstance(w, edit_sizers.SizerBase):
                 w = w.window
             elif isinstance(w, application.Application):
                 w = None
             else:
                 w = w.parent
     ret.reverse()
     # ALB 2007-08-28: remember also the position of the toplevel window in the selected path
     if oldw is not None and oldw.widget is not None:
         assert oldw.widget
         pos = misc.get_toplevel_parent(oldw.widget).GetPosition()
         ret[0] = (ret[0], pos)
     return ret
Пример #7
0
 def on_mouse_events(self, event):
     if event.Dragging():
         # start drag & drop
         window = misc.get_toplevel_parent(self)
         clipboard.begin_drag(window, self)
         return
     event.Skip()
Пример #8
0
 def raise_all(self):
     # when one window is raised, raise all
     children = self.GetChildren()
     for child in children:
         child = misc.get_toplevel_parent(child)
         if child.IsShown() and child.GetTitle(): child.Raise()
     self.Raise()
Пример #9
0
        def __init__(self):
            wx.Dialog.__init__(self, misc.get_toplevel_parent(parent), -1, _("Enter size"))

            self.width = SpinProperty(self, "width", self, label=_("width"))
            self.height = SpinProperty(self, "height", self, label=_("height"))
            self.width.set_value(20)
            self.height.set_value(20)

            szr = wx.BoxSizer(wx.VERTICAL)
            szr.Add(self.width.panel, 0, wx.EXPAND)
            szr.Add(self.height.panel, 0, wx.EXPAND)
            sz = wx.BoxSizer(wx.HORIZONTAL)
            sz.Add(wx.Button(self, wx.ID_OK, _("OK")))
            szr.Add(sz, 0, wx.ALL | wx.ALIGN_CENTER, 4)
            self.SetAutoLayout(True)
            self.SetSizer(szr)
            szr.Fit(self)
            self.CenterOnScreen()
Пример #10
0
        def __init__(self):
            wx.Dialog.__init__(self, misc.get_toplevel_parent(parent), -1,
                               _("Enter size"))

            self.width = SpinProperty(self, 'width', self, label=_("width"))
            self.height = SpinProperty(self, 'height', self, label=_("height"))
            self.width.set_value(20)
            self.height.set_value(20)

            szr = wx.BoxSizer(wx.VERTICAL)
            szr.Add(self.width.panel, 0, wx.EXPAND)
            szr.Add(self.height.panel, 0, wx.EXPAND)
            sz = wx.BoxSizer(wx.HORIZONTAL)
            sz.Add(wx.Button(self, wx.ID_OK, _('OK')))
            szr.Add(sz, 0, wx.ALL | wx.ALIGN_CENTER, 4)
            self.SetAutoLayout(True)
            self.SetSizer(szr)
            szr.Fit(self)
            self.CenterOnScreen()
Пример #11
0
 def raise_all(self, event):
     children = self.GetChildren()
     for child in children:
         child = misc.get_toplevel_parent(child)
         if child.IsShown() and child.GetTitle(): child.Raise()
     self.Raise()
Пример #12
0
 def raise_all(self, event):
     children = self.GetChildren()
     for child in children:
         child = misc.get_toplevel_parent(child)
         if child.IsShown() and child.GetTitle(): child.Raise()
     self.Raise()