예제 #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 _create_popup_menu(self, widget):
        # remove, hide
        menu = misc.wxGladePopupMenu(self.name)
        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)

        if self.widget and self.is_visible():
            # hide window
            i = misc.append_menu_item(menu, -1, _('Hide'))
            misc.bind_menu_item_after(widget, i, self.hide_widget)
        else:
            i = misc.append_menu_item(menu, -1, _('Show'))
            misc.bind_menu_item_after(widget, i, common.app_tree.show_toplevel,
                                      None, self)

        # paste
        i = misc.append_menu_item(menu, -1, _('Paste Sizer\tCtrl+V'),
                                  wx.ART_PASTE)
        misc.bind_menu_item_after(widget, i, self.clipboard_paste)
        if self.sizer is not None: i.Enable(False)

        # preview
        menu.AppendSeparator()
        i = misc.append_menu_item(menu, -1, _('Preview %s\tF5' % widgetclass))
        misc.bind_menu_item(widget, i, self.preview_parent)

        self._rmenu = (menu, widget)
        return menu
예제 #3
0
    def _add_popup_menu_items(self, menu, item, widget):
        # called from managed widget items' _create_popup_menu method
        i = misc.append_menu_item(menu, -1, _('Insert Notebook Tab before') ) # \tCtrl+I') )
        misc.bind_menu_item_after(widget, i, self.window.insert_tab, item.pos-1, "new tab")

        if item.pos==len(self.window.tabs): # last slot -> allow to add
            i = misc.append_menu_item(menu, -1, _('Add Notebook Tab') ) # \tCtrl+A') )
            misc.bind_menu_item_after(widget, i, self.window.insert_tab, item.pos, "new tab")
        menu.AppendSeparator()
예제 #4
0
    def _create_popup_menu(self, widget=None):
        REMOVE_ID, HIDE_ID = [wx.NewId() for i in range(2)]
        menu = misc.wxGladePopupMenu(self.name)
        misc.append_menu_item(menu, REMOVE_ID, _('Remove MenuBar\tDel'), wx.ART_DELETE)
        misc.append_menu_item(menu, HIDE_ID, _('Hide'))

        if widget is None: widget = self.widget
        wx.EVT_MENU(widget, REMOVE_ID, misc.exec_after(self.remove))
        wx.EVT_MENU(widget, HIDE_ID, misc.exec_after(self.hide_widget))
        self._rmenu = (menu, widget)
예제 #5
0
    def _create_popup_menu(self, widget=None):
        COPY_ID, REMOVE_ID, CUT_ID = [wx.NewId() for i in range(3)]
        menu = misc.wxGladePopupMenu(self.name)
        misc.append_menu_item(menu, REMOVE_ID, _('Remove Panel\tDel'),
                              wx.ART_DELETE)
        misc.append_menu_item(menu, COPY_ID, _('Copy\tCtrl+C'), wx.ART_COPY)
        misc.append_menu_item(menu, CUT_ID, _('Cut\tCtrl+X'), wx.ART_CUT)

        if widget is None: widget = self.widget
        wx.EVT_MENU(widget, REMOVE_ID, misc.exec_after(self.remove))
        wx.EVT_MENU(widget, COPY_ID, misc.exec_after(self.clipboard_copy))
        wx.EVT_MENU(widget, CUT_ID, misc.exec_after(self.clipboard_cut))

        PASTE_ID = wx.NewId()
        i = misc.append_menu_item(menu, PASTE_ID, _('Paste Sizer\tCtrl+V'),
                                  wx.ART_PASTE)
        wx.EVT_MENU(widget, PASTE_ID, misc.exec_after(self.clipboard_paste))
        if self.top_sizer is not None: i.Enable(False)

        PREVIEW_ID = wx.NewId()
        menu.AppendSeparator()
        misc.append_menu_item(menu, PREVIEW_ID, _('Preview'))
        wx.EVT_MENU(widget, PREVIEW_ID, misc.exec_after(self.preview_parent))

        self._rmenu = (menu, widget)  # store for destryoing and unbinding
        return menu
예제 #6
0
    def _create_popup_menu(self):
        REMOVE_ID = wx.NewId()
        HIDE_ID = wx.NewId()
        self._rmenu = misc.wxGladePopupMenu(self.name)
        misc.append_menu_item(self._rmenu, REMOVE_ID, _('Remove ToolBar\tDel'), wx.ART_DELETE)
        misc.append_menu_item(self._rmenu, HIDE_ID, _('Hide'))

        wx.EVT_MENU(self.pwidget, REMOVE_ID, misc.exec_after(self.remove))
        wx.EVT_MENU(self.pwidget, HIDE_ID, misc.exec_after(self.hide_widget))

        self._rmenu = (menu, widget) # store for destryoing and unbinding
        return menu
예제 #7
0
파일: notebook.py 프로젝트: wxGlade/wxGlade
    def _add_parent_popup_menu_items(self, menu, item, widget):
        # called from managed widget items' _create_popup_menu method
        if item.IS_SLOT:
            i = misc.append_menu_item(menu, -1, _('Remove Notebook Tab\tDel') )
            misc.bind_menu_item_after(widget, i, item.remove)

        i = misc.append_menu_item(menu, -1, _('Insert Notebook Tab before') ) # \tCtrl+I') )
        misc.bind_menu_item_after(widget, i, self.insert_tab, item.index, "new tab")

        if item.index==len(self.tabs)-1: # last slot -> allow to add
            i = misc.append_menu_item(menu, -1, _('Add Notebook Tab') ) # \tCtrl+A') )
            misc.bind_menu_item_after(widget, i, self.add_slot)
        menu.AppendSeparator()
예제 #8
0
 def _create_popup_menu(self, widget):
     self._destroy_popup_menu()
     menu = misc.wxGladePopupMenu("Application")
     i = misc.append_menu_item(menu, -1, _('Generate Code'))
     misc.bind_menu_item_after(
         widget, i, self.generate_code)  # a property, but it can be called
     self._rmenu = (menu, widget)  # store for destryoing and unbinding
     return menu
예제 #9
0
    def _create_popup_menu(self, widget=None):
        if widget is None: widget = self.widget
        menu = misc.wxGladePopupMenu(self.name)

        if self.widget and self.is_visible():
            item = misc.append_menu_item(menu, -1, _('Hide'))
            misc.bind_menu_item_after(widget, item, self.hide_widget)
        else:
            i = misc.append_menu_item(menu, -1, _('Show'))
            misc.bind_menu_item_after(widget, i, common.app_tree.show_toplevel, None, self)
        menu.AppendSeparator()

        item = misc.append_menu_item(menu, -1, _('Remove MenuBar\tDel'), wx.ART_DELETE)
        misc.bind_menu_item_after(widget, item, self.remove)

        item = misc.append_menu_item(menu, -1, _('Edit menus ...'))
        misc.bind_menu_item_after(widget, item, self.properties["menus"].edit_menus)

        return menu
예제 #10
0
    def _create_popup_menu(self, widget=None):
        if widget is None: widget = self.widget
        menu = misc.wxGladePopupMenu(self.name)
        i = misc.append_menu_item(menu, -1, _('Remove Panel\tDel'),  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)

        i = misc.append_menu_item(menu, -1, _('Paste Sizer\tCtrl+V'), wx.ART_PASTE)
        misc.bind_menu_item_after(widget, i, clipboard.paste, self)
        if self.top_sizer is not None or not clipboard.check("sizer"): i.Enable(False)
        menu.AppendSeparator()

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

        i = misc.append_menu_item(menu, -1, _('Preview'))
        misc.bind_menu_item_after(widget, i, self.preview_parent)

        return menu
예제 #11
0
파일: toolbar.py 프로젝트: wxGlade/wxGlade
    def _create_popup_menu(self, widget):
        menu = misc.wxGladePopupMenu(self.name)

        if self.IS_TOPLEVEL:
            if self.widget and self.is_visible():
                item = misc.append_menu_item(menu, -1, _('Hide'))
                misc.bind_menu_item_after(widget, item, self.hide_widget)
            else:
                i = misc.append_menu_item(menu, -1, _('Show'))
                misc.bind_menu_item_after(widget, i,
                                          common.app_tree.show_toplevel, None,
                                          self)
            menu.AppendSeparator()

        i = misc.append_menu_item(menu, -1, _('Remove ToolBar\tDel'),
                                  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)

        item = misc.append_menu_item(menu, -1, _('Edit tools ...'))
        misc.bind_menu_item_after(widget, item,
                                  self.properties["tools"].edit_tools)

        return menu
예제 #12
0
파일: panel.py 프로젝트: swt2c/wxGlade
    def _create_popup_menu(self, widget=None):
        if widget is None: widget = self.widget
        menu = misc.wxGladePopupMenu(self.name)
        i = misc.append_menu_item(menu, -1, _('Remove Panel\tDel'),
                                  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)

        i = misc.append_menu_item(menu, -1, _('Paste Sizer\tCtrl+V'),
                                  wx.ART_PASTE)
        misc.bind_menu_item_after(widget, i, clipboard.paste, self)
        if self.top_sizer is not None or not clipboard.check("sizer"):
            i.Enable(False)

        if self.sizer and not self.sizer.is_virtual(
        ) and self.sizer._can_add_insert_slots():
            menu.AppendSeparator()
            # 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()
        i = misc.append_menu_item(menu, -1, _('Preview'))
        misc.bind_menu_item_after(widget, i, self.preview_parent)

        return menu
예제 #13
0
    def _create_popup_menu(self, widget):
        menu = misc.wxGladePopupMenu("Application")
        i = misc.append_menu_item(menu, -1, _('Generate Code'))
        misc.bind_menu_item_after(
            widget, i, self.generate_code)  # a property, but it can be called

        # paste
        if clipboard.check("menubar"):
            i = misc.append_menu_item(menu, -1, _('Paste MenuBar\tCtrl+V'),
                                      wx.ART_PASTE)
            misc.bind_menu_item_after(widget, i, clipboard.paste, self)
        elif clipboard.check("toolbar"):
            i = misc.append_menu_item(menu, -1, _('Paste ToolBar\tCtrl+V'),
                                      wx.ART_PASTE)
            misc.bind_menu_item_after(widget, i, clipboard.paste, self)
        else:
            i = misc.append_menu_item(menu, -1,
                                      _('Paste Toplevel Window\tCtrl+V'),
                                      wx.ART_PASTE)
            misc.bind_menu_item_after(widget, i, clipboard.paste, self)
            if not clipboard.check("window"): i.Enable(False)

        return menu
예제 #14
0
    def _create_popup_menu(self, widget):
        # menu title
        if self.parent.IS_SIZER and "cols" in self.parent.properties:
            rows, cols = self.parent._get_actual_rows_cols()
            # calculate row and pos of our slot
            row, col = self.parent._get_row_col(self.pos)
            menu = wx.Menu(_("Slot %d/%d" % (row + 1, col + 1)))
        elif "pos" in self.properties:
            menu = wx.Menu(_("Slot %d" % self.pos))
        else:
            menu = wx.Menu(_("Slot"))

        # edit: paste
        i = misc.append_menu_item(menu, -1, _('Paste\tCtrl+V'), wx.ART_PASTE)
        misc.bind_menu_item_after(widget, i, clipboard.paste, self)
        if not clipboard.check("widget", "sizer"): i.Enable(False)
        menu.AppendSeparator()

        # slot actions
        if self.parent.IS_SIZER or self.parent.CHILDREN == -1:
            if not "cols" in self.parent.properties:
                i = misc.append_menu_item(menu, -1, _('Remove Slot\tDel'),
                                          wx.ART_DELETE)
                misc.bind_menu_item_after(widget, i, self.remove)
                if self.parent.IS_SIZER and len(self.parent.children) <= 1:
                    i.Enable(False)
            else:
                # if inside a grid sizer: allow removal of empty rows/cols
                # check whether all slots in same row/col are empty
                row_is_empty = col_is_empty = True
                for pos, child in enumerate(self.parent.children):
                    child_row, child_col = self.parent._get_row_col(pos)
                    if child_row == row and not child.IS_SLOT:
                        row_is_empty = False
                    if child_col == col and not child.IS_SLOT:
                        col_is_empty = False

                # allow removal of empty row
                i = misc.append_menu_item(menu, -1,
                                          _('Remove Row %d' % (row + 1)))
                misc.bind_menu_item_after(widget, i, self.parent.remove_row,
                                          self.pos)
                if not row_is_empty or rows <= 1: i.Enable(False)

                # allow removal of empty col
                i = misc.append_menu_item(menu, -1,
                                          _('Remove Column %d' % (col + 1)))
                misc.bind_menu_item_after(widget, i, self.parent.remove_col,
                                          self.pos)
                if not col_is_empty or cols <= 1: i.Enable(False)
                menu.AppendSeparator()

        if hasattr(self.parent, "_add_parent_popup_menu_items"):
            self.parent._add_parent_popup_menu_items(menu, self, widget)

        p = self.toplevel_parent_window  # misc.get_toplevel_widget(self.sizer)
        #if p is not None and p.preview_is_visible():
        if 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_after(widget, i, p.preview)

        return menu
예제 #15
0
 def _add_popup_menu_items(self, menu, widget):
     # called from managed widget items' _create_popup_menu method
     i = misc.append_menu_item(menu, -1, _('Add Notebook Tab'))
     misc.bind_menu_item_after(widget, i, self.add_slot)
예제 #16
0
 def _create_popup_menu(self, widget):
     menu = misc.wxGladePopupMenu("Application")
     i = misc.append_menu_item(menu, -1, _('Generate Code'))
     misc.bind_menu_item_after(
         widget, i, self.generate_code)  # a property, but it can be called
     return menu
예제 #17
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