Пример #1
0
    def _create_popup_menu(self, widget):
        menu = misc.wxGladePopupMenu(self.name)

        # edit: remove/copy/cut
        widgetclass = self.__class__.__name__.lstrip("Edit")
        i = misc.append_menu_item(menu, -1,
                                  _('Remove %s\tDel') % widgetclass,
                                  wx.ART_DELETE)
        misc.bind_menu_item_after(widget, i, self.remove)
        i = misc.append_menu_item(menu, -1, _('Copy\tCtrl+C'), wx.ART_COPY)
        misc.bind_menu_item_after(widget, i, clipboard.copy, self)
        i = misc.append_menu_item(menu, -1, _('Cut\tCtrl+X'), wx.ART_CUT)
        misc.bind_menu_item_after(widget, i, clipboard.cut, self)
        menu.AppendSeparator()

        if self.sizer:
            self.sizer._add_popup_menu_items(menu, self, widget)

        # preview (create or close?)
        p = misc.get_toplevel_widget(self)
        if p is not None and p.preview_is_visible():
            item = _('Close preview (%s)\tF5') % p.name
        else:
            item = _('Preview (%s)\tF5') % p.name
        i = misc.append_menu_item(menu, -1, item)
        #misc.bind_menu_item_after(widget, i, self.preview_parent)
        misc.bind_menu_item(widget, i, self.preview_parent)

        return menu
Пример #2
0
 def setup_preview_menu(self):
     p = misc.get_toplevel_widget(self)
     if p is not None:
         item = list(self._rmenu.GetMenuItems())[-1]
         if p.preview_is_visible():
             item.SetText(_('Close preview') + ' (%s)\tCtrl+P' % p.name)
         else:
             item.SetText(_('Preview') + ' (%s)\tCtrl+P' % p.name)        
Пример #3
0
 def setup_preview_menu(self):
     p = misc.get_toplevel_widget(self)
     if p is not None:
         item = list(self._rmenu.GetMenuItems())[-1]
         if p.preview_is_visible():
             item.SetText(_('Close preview') + ' (%s)\tCtrl+P' % p.name)
         else:
             item.SetText(_('Preview') + ' (%s)\tCtrl+P' % p.name)
Пример #4
0
    def _create_popup_menu(self, widget):
        menu = misc.wxGladePopupMenu(self.name)

        # edit: remove/copy/cut
        widgetclass = self.__class__.__name__.lstrip("Edit")
        i = misc.append_menu_item(menu, -1, _('Remove %s\tDel')%widgetclass, wx.ART_DELETE)
        misc.bind_menu_item_after(widget, i, self.remove)
        i = misc.append_menu_item( menu, -1, _('Copy\tCtrl+C'), wx.ART_COPY )
        misc.bind_menu_item_after(widget, i, clipboard.copy, self)
        i = misc.append_menu_item( menu, -1, _('Cut\tCtrl+X'), wx.ART_CUT )
        misc.bind_menu_item_after(widget, i, clipboard.cut, self)
        menu.AppendSeparator()

        # rows/cols if inside a grid sizer
        if "rows" in self.sizer.PROPERTIES:
            row, col = self.sizer._get_row_col(self.pos)
            i = misc.append_menu_item(menu, -1, _('Insert Row before') )
            misc.bind_menu_item_after(widget, i, self.sizer.insert_row, self.pos)
            i = misc.append_menu_item(menu, -1, _('Insert Column before') )
            misc.bind_menu_item_after(widget, i, self.sizer.insert_col, self.pos)
            if row==self.sizer.rows-1:
                # last row
                i = misc.append_menu_item(menu, -1, _('Add Row') )
                misc.bind_menu_item_after(widget, i, self.sizer.insert_row, -1)
            if col==self.sizer.cols-1:
                # last col
                i = misc.append_menu_item(menu, -1, _('Add Column') )
                misc.bind_menu_item_after(widget, i, self.sizer.insert_col, -1)
            menu.AppendSeparator()

        if not self.sizer.is_virtual() and self.sizer._can_add_insert_slots():
            # slots
            i = misc.append_menu_item(menu, -1, _('Insert Slot before\tCtrl+I') )
            misc.bind_menu_item_after(widget, i, self.sizer.insert_slot, self.pos)
            i = misc.append_menu_item(menu, -1, _('Insert Slots before...\tCtrl+Shift+I') )
            misc.bind_menu_item_after(widget, i, self.sizer.insert_slot, self.pos, True)

            if self.pos==len(self.sizer.children)-1: # last slot -> allow to add
                i = misc.append_menu_item(menu, -1, _('Add Slot\tCtrl+A') )
                misc.bind_menu_item_after(widget, i, self.sizer.add_slot)
                i = misc.append_menu_item(menu, -1, _('Add Slots...\tCtrl+Shift+A') )
                misc.bind_menu_item_after(widget, i, self.sizer.add_slot, True)
            menu.AppendSeparator()

        # preview (create or close?)
        p = misc.get_toplevel_widget(self)
        if p is not None and p.preview_is_visible():
            item = _('Close preview (%s)\tF5') % p.name
        else:
            item = _('Preview (%s)\tF5') % p.name
        i = misc.append_menu_item( menu, -1, item )
        #misc.bind_menu_item_after(widget, i, self.preview_parent)
        misc.bind_menu_item(widget, i, self.preview_parent)

        return menu
Пример #5
0
 def _get_toplevel(self):
     # return the toplevel for a preview or design window
     if misc.focused_widget and not isinstance(misc.focused_widget,
                                               application.Application):
         # a widget is selected, find the toplevel window for it
         return misc.get_toplevel_widget(misc.focused_widget)
     # find main toplevel window
     toplevel_name = common.app_tree.app.top_window
     toplevel = None
     for c in common.app_tree.app.node.children or []:
         if c.widget.name == toplevel_name:
             toplevel = c.widget
     return toplevel
Пример #6
0
    def preview(self, event):
        """Generate preview of the current loaded project.
        
        A preview can be triggered by keyboard shortcut or by pressing the preview button.
        The preview can be triggered for all selected widgets.
        This doesn't mean that the widget is opened for editing."""

        if not common.app_tree.cur_widget or isinstance(
                common.app_tree.cur_widget, application.Application):
            preview_widget = common.app_tree.root.children[0].widget
        else:
            preview_widget = misc.get_toplevel_widget(
                common.app_tree.cur_widget)

        if preview_widget is None: return

        if preview_widget.preview_widget:
            # preview is already active: close and re-generate
            preview_widget.preview_widget.Close()
            wx.CallAfter(preview_widget.preview, None)
        else:
            preview_widget.preview(None)
Пример #7
0
 def preview_parent(self):
     widget = misc.get_toplevel_widget(self)
     if widget is not None:
         widget.preview(None)
Пример #8
0
 def preview_parent(self, *args):
     widget = misc.get_toplevel_widget(self)
     if widget is not None:
         wx.CallAfter(widget.preview)  # direct call would result in crash
Пример #9
0
 def preview(event):
     if common.app_tree.cur_widget is not None:
         p = misc.get_toplevel_widget(common.app_tree.cur_widget)
         if p is not None:
             p.preview(None)
Пример #10
0
 def preview_parent(self):
     widget = misc.get_toplevel_widget(self)
     if widget is not None:
         widget.preview(None)
Пример #11
0
 def preview(event):
     if common.app_tree.cur_widget is not None:
         p = misc.get_toplevel_widget(common.app_tree.cur_widget)
         if p is not None:
             p.preview(None)