Пример #1
0
    def __init__(self, parent, *args, **kwargs):
        try:
            S = kwargs.pop("S")

        except KeyError:
            S = None

        try:
            dimensions = kwargs.pop("dimensions")

        except KeyError:
            dimensions = (config["grid_rows"], config["grid_columns"],
                          config["grid_tables"])

        wx.Frame.__init__(self, parent, *args, **kwargs)

        self.interfaces = GuiInterfaces(self)

        try:
            self._mgr = aui.AuiManager(self)

        except Exception:
            # This may fail if py.test runs under Windows
            # Therefore, we set up a basic framework for the unit tests
            self.grid = Grid(self, -1, S=S, dimensions=dimensions)
            self.clipboard = Clipboard()
            self.actions = AllMainWindowActions(self.grid)

        self.parent = parent

        self.handlers = MainWindowEventHandlers(self)

        # Program states
        # --------------

        self._states()

        # GUI elements
        # ------------

        # Menu Bar
        self.menubar = wx.MenuBar()
        self.main_menu = MainMenu(parent=self, menubar=self.menubar)
        self.SetMenuBar(self.menubar)

        # Disable menu item for leaving safe mode
        post_command_event(self, self.SafeModeExitMsg)

        # Status bar
        statusbar = StatusBar(self)
        self.SetStatusBar(statusbar)

        welcome_text = _("Welcome to pyspread.")
        post_command_event(self, self.StatusBarMsg, text=welcome_text)

        # Toolbars
        self.main_toolbar = MainToolbar(self, -1)
        self.macro_toolbar = MacroToolbar(self, -1)
        self.find_toolbar = FindToolbar(self, -1)
        self.attributes_toolbar = AttributesToolbar(self, -1)
        self.widget_toolbar = WidgetToolbar(self, -1)

        # Entry line
        self.entry_line_panel = EntryLineToolbarPanel(self, -1)

        # Main grid
        self.grid = Grid(self, -1, S=S, dimensions=dimensions)

        # TableChoiceListCtrl
        self.table_list_panel = TableChoiceListCtrl(self, self.grid)

        # Clipboard
        self.clipboard = Clipboard()

        # Main window actions

        self.actions = AllMainWindowActions(self.grid)

        # Layout and bindings

        self._set_properties()
        self._do_layout()
        self._bind()
Пример #2
0
class TestClipboard(object):
    """Unit tests for Clipboard"""

    clipboard = Clipboard()

    param_convert_clipboard = [
        {
            'data': "1\t2\t3",
            'sep': "\t",
            'res': [['1', '2', '3']]
        },
        {
            'data': "1\t2\t3\n4\t5\t6",
            'sep': "\t",
            'res': [['1', '2', '3'], ['4', '5', '6']]
        },
        {
            'data': "1,2,3\n4,5,6",
            'sep': ",",
            'res': [['1', '2', '3'], ['4', '5', '6']]
        },
    ]

    @params(param_convert_clipboard)
    def test_convert_clipboard(self, data, sep, res):
        """Unit test for _convert_clipboard"""

        gengen = self.clipboard._convert_clipboard(data, sep)
        result = list(list(linegen) for linegen in gengen)

        assert result == res

    param_set_get_clipboard = [
        {
            'text': ""
        },
        {
            'text': "Test"
        },
        {
            'text': u"ÓÓó€ëáßðïœ"
        },
        {
            'text': "Test1\tTest2"
        },
        {
            'text': "\b"
        },
    ]

    @params(param_set_get_clipboard)
    def test_set_get_clipboard(self, text):
        """Unit test for get_clipboard and set_clipboard"""

        clipboard = wx.TheClipboard

        textdata = wx.TextDataObject()
        textdata.SetText(text)
        clipboard.Open()
        clipboard.SetData(textdata)
        clipboard.Close()

        assert self.clipboard.get_clipboard() == text