• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python _events.post_command_event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中src.gui._events.post_command_event函数的典型用法代码示例。如果您正苦于以下问题:Python post_command_event函数的具体用法?Python post_command_event怎么用?Python post_command_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了post_command_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: sign_file

    def sign_file(self, filepath):
        """Signs file if possible"""

        signature = sign(filepath)
        if signature is None:
            statustext = _('Error signing file. File is not signed.')
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=statustext)
            except TypeError:
                # The main window does not exist any more
                pass

            return

        signfile = open(filepath + '.sig', 'wb')
        signfile.write(signature)
        signfile.close()

        # Statustext differs if a save has occurred

        if self.code_array.safe_mode:
            statustext = _('File saved and signed')
        else:
            statustext = _('File signed')

        try:
            post_command_event(self.main_window, self.StatusBarMsg,
                           text=statustext)
        except TypeError:
            # The main window does not exist any more
            pass
开发者ID:sandeep-datta,项目名称:pyspread,代码行数:32,代码来源:_grid_actions.py


示例2: OnInit

    def OnInit(self):
        """Init class that is automatically run on __init__"""

        # Get command line options and arguments
        self.get_cmd_args()

        # Initialize the prerequisitions to construct the main window
        InitAllImageHandlers()

        # Main window creation
        from src.gui._main_window import MainWindow

        self.main_window = MainWindow(None, title="pyspread")

        ## Set dimensions

        ## Initialize file loading via event

        # Create GPG key if not present

        from src.lib.gpg import genkey

        genkey()

        # Show application window
        self.SetTopWindow(self.main_window)
        self.main_window.Show()

        # Load filename if provided
        if self.filepath is not None:
            post_command_event(self.main_window, self.GridActionOpenMsg,
                               attr={"filepath": self.filepath})
            self.main_window.filepath = self.filepath

        return True
开发者ID:mnagel,项目名称:pyspread,代码行数:35,代码来源:pyspread.py


示例3: merge

    def merge(self, merge_area, tab):
        """Merges top left cell with all cells until bottom_right"""

        top, left, bottom, right = merge_area

        cursor = self.grid.actions.cursor
        top_left_code = self.code_array((top, left, cursor[2]))

        selection = Selection([(top, left)], [(bottom, right)], [], [], [])

        # Check if the merge area overlaps another merge area

        error_msg = _("Overlapping merge area at {} prevents merge.")

        for row in xrange(top, bottom + 1):
            for col in xrange(left, right + 1):
                key = row, col, tab
                if self.code_array.cell_attributes[key]["merge_area"]:
                    post_command_event(self.main_window, self.StatusBarMsg,
                                       text=error_msg.format(str(key)))
                    return

        self.delete_selection(selection)
        self.set_code((top, left, cursor[2]), top_left_code)

        attr = {"merge_area": merge_area, "locked": True}

        self._set_cell_attr(selection, tab, attr)

        tl_selection = Selection([], [], [], [], [(top, left)])
        attr = {"locked": False}

        self._set_cell_attr(tl_selection, tab, attr)
开发者ID:daleathan,项目名称:pyspread,代码行数:33,代码来源:_grid_cell_actions.py


示例4: set_cursor

    def set_cursor(self, value):
        """Changes the grid cursor cell.

        Parameters
        ----------

        value: 2-tuple or 3-tuple of String
        \trow, col, tab or row, col for target cursor position

        """

        if len(value) == 3:
            self.grid._last_selected_cell = row, col, tab = value

            if tab != self.cursor[2]:
                post_command_event(self.main_window,
                                   self.GridActionTableSwitchMsg, newtable=tab)
                if is_gtk():
                    wx.Yield()
        else:
            row, col = value
            self.grid._last_selected_cell = row, col, self.grid.current_table

        if not (row is None and col is None):
            self.grid.MakeCellVisible(row, col)
            self.grid.SetGridCursor(row, col)
开发者ID:chrmorais,项目名称:pyspread,代码行数:26,代码来源:_grid_actions.py


示例5: OnApply

    def OnApply(self, event):
        """Event handler for Apply button"""

        post_command_event(self.parent, self.MacroReplaceMsg, macros=self.macros)
        post_command_event(self.parent, self.MacroExecuteMsg)

        event.Skip()
开发者ID:mnagel,项目名称:pyspread,代码行数:7,代码来源:_dialogs.py


示例6: progress_status

    def progress_status(self):
        """Displays progress in statusbar"""

        if self.line % self.freq == 0:
            text = self.statustext.format(nele=self.line,
                                          totalele=self.total_lines)

            if self.main_window.grid.actions.pasting:
                try:
                    post_command_event(self.main_window,
                                       self.main_window.StatusBarMsg,
                                       text=text)
                except TypeError:
                    # The main window does not exist any more
                    pass
            else:
                # Write directly to the status bar because the event queue
                # is not emptied during file access

                self.main_window.GetStatusBar().SetStatusText(text)

            # Now wait for the statusbar update to be written on screen
            if is_gtk():
                try:
                    wx.Yield()
                except:
                    pass

        self.line += 1
开发者ID:01-,项目名称:pyspread,代码行数:29,代码来源:fileio.py


示例7: switch_to_table

    def switch_to_table(self, event):
        """Switches grid to table

        Parameters
        ----------

        event.newtable: Integer
        \tTable that the grid is switched to

        """

        newtable = event.newtable

        no_tabs = self.grid.code_array.shape[2] - 1

        if 0 <= newtable <= no_tabs:
            self.grid.current_table = newtable
            self.main_window.table_choice.SetMax(newtable + 1)
            self.main_window.table_choice.SetValue(newtable)

            # Reset row heights and column widths by zooming

            self.zoom()

            statustext = _("Switched to table {}.").format(newtable)

            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)
开发者ID:sandeep-datta,项目名称:pyspread,代码行数:28,代码来源:_grid_actions.py


示例8: import_file

    def import_file(self, filepath, filterindex):
        """Imports external file

        Parameters
        ----------

        filepath: String
        \tPath of import file
        filterindex: Integer
        \tIndex for type of file, 0: csv, 1: tab-delimited text file

        """

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg)

        if filterindex == 0:
            # CSV import option choice
            return self._import_csv(filepath)
        elif filterindex == 1:
            # TXT import option choice
            return self._import_txt(filepath)
        else:
            msg = _("Unknown import choice {choice}.")
            msg = msg.format(choice=filterindex)
            short_msg = _('Error reading CSV file')

            self.main_window.interfaces.display_warning(msg, short_msg)
开发者ID:daleathan,项目名称:pyspread,代码行数:28,代码来源:_main_window_actions.py


示例9: OnMacroListLoad

    def OnMacroListLoad(self, event):
        """Macro list load event handler"""

        # Get filepath from user

        wildcards = get_filetypes2wildcards(["py", "all"]).values()

        wildcard = "|".join(wildcards)

        message = _("Choose macro file.")

        style = wx.OPEN
        filepath, filterindex = \
            self.interfaces.get_filepath_findex_from_user(wildcard, message,
                                                          style)

        if filepath is None:
            return

        # Enter safe mode because macro file could be harmful

        post_command_event(self.main_window, self.main_window.SafeModeEntryMsg)

        # Load macros from file

        self.main_window.actions.open_macros(filepath)

        event.Skip()
开发者ID:daleathan,项目名称:pyspread,代码行数:28,代码来源:_main_window.py


示例10: zoom

    def zoom(self, zoom=None):
        """Zooms to zoom factor"""

        status = True

        if zoom is None:
            zoom = self.grid.grid_renderer.zoom
            status = False

        # Zoom factor for grid content
        self.grid.grid_renderer.zoom = zoom

        # Zoom grid labels
        self._zoom_labels(zoom)

        # Zoom rows and columns
        self._zoom_rows(zoom)
        self._zoom_cols(zoom)

        self.grid.ForceRefresh()

        if status:
            statustext = _(u"Zoomed to {0:.2f}.").format(zoom)

            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)
开发者ID:jean,项目名称:pyspread,代码行数:26,代码来源:_grid_actions.py


示例11: replace_all

    def replace_all(self, findpositions, find_string, replace_string):
        """Replaces occurrences of find_string with replace_string at findpos

        and marks content as changed

        Parameters
        ----------

        findpositions: List of 3-Tuple of Integer
        \tPositions in grid that shall be replaced
        find_string: String
        \tString to be overwritten in the cell
        replace_string: String
        \tString to be used for replacement

        """
        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg,
                           changed=True)

        for findpos in findpositions:
            old_code = self.grid.code_array(findpos)
            new_code = old_code.replace(find_string, replace_string)

            self.grid.code_array[findpos] = new_code

        statustext = _("Replaced {no_cells} cells.")
        statustext = statustext.format(no_cells=len(findpositions))

        post_command_event(self.main_window, self.StatusBarMsg,
                           text=statustext)

        self.grid.ForceRefresh()
开发者ID:jean,项目名称:pyspread,代码行数:33,代码来源:_grid_actions.py


示例12: replace

    def replace(self, findpos, find_string, replace_string):
        """Replaces occurrences of find_string with replace_string at findpos

        and marks content as changed

        Parameters
        ----------

        findpos: 3-Tuple of Integer
        \tPosition in grid that shall be replaced
        find_string: String
        \tString to be overwritten in the cell
        replace_string: String
        \tString to be used for replacement

        """

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg,
                           changed=True)

        old_code = self.grid.code_array(findpos)
        new_code = old_code.replace(find_string, replace_string)

        self.grid.code_array[findpos] = new_code
        self.grid.actions.cursor = findpos

        statustext = _("Replaced {old} with {new} in cell {key}.")
        statustext = statustext.format(old=old_code, new=new_code, key=findpos)

        post_command_event(self.main_window, self.StatusBarMsg,
                           text=statustext)
开发者ID:jean,项目名称:pyspread,代码行数:32,代码来源:_grid_actions.py


示例13: switch_to_table

    def switch_to_table(self, event):
        """Switches grid to table

        Parameters
        ----------

        event.newtable: Integer
        \tTable that the grid is switched to

        """

        newtable = event.newtable

        no_tabs = self.grid.code_array.shape[2] - 1

        if 0 <= newtable <= no_tabs:
            self.grid.current_table = newtable

            # Change value of entry_line and table choice
            post_command_event(self.main_window, self.TableChangedMsg,
                               table=newtable)

            # Reset row heights and column widths by zooming

            self.zoom()
开发者ID:jean,项目名称:pyspread,代码行数:25,代码来源:_grid_actions.py


示例14: copy_selection_access_string

    def copy_selection_access_string(self):
        """Copys access_string to selection to the clipboard

        An access string is Python code to reference the selection
        If there is no selection then a reference to the current cell is copied

        """

        selection = self.get_selection()
        if not selection:
            cursor = self.grid.actions.cursor
            selection = Selection([], [], [], [], [tuple(cursor[:2])])
        shape = self.grid.code_array.shape
        tab = self.grid.current_table

        access_string = selection.get_access_string(shape, tab)

        # Copy access string to clipboard
        self.grid.main_window.clipboard.set_clipboard(access_string)

        # Display copy operation and access string in status bar
        statustext = _("Cell reference copied to clipboard: {access_string}")
        statustext = statustext.format(access_string=access_string)

        post_command_event(self.main_window, self.StatusBarMsg,
                           text=statustext)
开发者ID:jean,项目名称:pyspread,代码行数:26,代码来源:_grid_actions.py


示例15: _set_cell_attr

    def _set_cell_attr(self, selection, table, attr):
        """Sets cell attr for key cell and mark grid content as changed

        Parameters
        ----------

        attr: dict
        \tContains cell attribute keys
        \tkeys in ["borderwidth_bottom", "borderwidth_right",
        \t"bordercolor_bottom", "bordercolor_right",
        \t"bgcolor", "textfont",
        \t"pointsize", "fontweight", "fontstyle", "textcolor", "underline",
        \t"strikethrough", "angle", "column-width", "row-height",
        \t"vertical_align", "justification", "frozen", "merge_area"]

        """

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg,
                           changed=True)

        if selection is not None:
            cell_attributes = self.code_array.cell_attributes
            cell_attributes.undoable_append((selection, table, attr),
                                            mark_unredo=False)
开发者ID:jean,项目名称:pyspread,代码行数:25,代码来源:_grid_cell_actions.py


示例16: paste

    def paste(self, tl_key, data, freq=None):
        """Pastes data into grid, marks grid changed

        If no selection is present, data is pasted starting with current cell
        If a selection is present, data is pasted fully if the selection is
        smaller. If the selection is larger then data is duplicated.

        Parameters
        ----------

        ul_key: Tuple
        \key of top left cell of paste area
        data: iterable of iterables where inner iterable returns string
        \tThe outer iterable represents rows
        freq: Integer, defaults to None
        \tStatus message frequency

        """

        # Get selection bounding box

        selection = self.get_selection()

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg,
                           changed=True)

        if selection:
            # There is a selection.  Paste into it
            self.paste_to_selection(selection, data, freq=freq)
        else:
            # There is no selection.  Paste from top left cell.
            self.paste_to_current_cell(tl_key, data, freq=freq)
开发者ID:jean,项目名称:pyspread,代码行数:33,代码来源:_grid_actions.py


示例17: change_frozen_attr

    def change_frozen_attr(self):
        """Changes frozen state of cell if there is no selection"""

        # Selections are not supported

        if self.grid.selection:
            statustext = _("Freezing selections is not supported.")
            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)

        cursor = self.grid.actions.cursor

        frozen = self.grid.code_array.cell_attributes[cursor]["frozen"]

        if frozen:
            # We have an frozen cell that has to be unfrozen

            # Delete frozen cache content
            self.grid.code_array.frozen_cache.pop(repr(cursor))

        else:
            # We have an non-frozen cell that has to be frozen

            # Add frozen cache content
            res_obj = self.grid.code_array[cursor]
            self.grid.code_array.frozen_cache[repr(cursor)] = res_obj

        # Set the new frozen state / code
        selection = Selection([], [], [], [], [cursor[:2]])
        self.set_attr("frozen", not frozen, selection=selection)
开发者ID:jean,项目名称:pyspread,代码行数:30,代码来源:_grid_cell_actions.py


示例18: write

    def write(self, iterable):
        """Writes values from iterable into CSV file"""

        io_error_text = _("Error writing to file {filepath}.")
        io_error_text = io_error_text.format(filepath=self.path)

        try:

            with open(self.path, "wb") as csvfile:
                csv_writer = csv.writer(csvfile, self.dialect)

                for line in iterable:
                    csv_writer.writerow(
                        list(encode_gen(line, encoding=self.encoding)))

        except IOError:
            txt = \
                _("Error opening file {filepath}.").format(filepath=self.path)
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=txt)
            except TypeError:
                # The main window does not exist any more
                pass

            return False
开发者ID:01-,项目名称:pyspread,代码行数:26,代码来源:__csv.py


示例19: save_macros

    def save_macros(self, filepath, macros):
        """Saves macros to file

        Parameters
        ----------
        filepath: String
        \tPath to macro file
        macros: String
        \tMacro code

        """

        io_error_text = _("Error writing to file {filepath}.")
        io_error_text = io_error_text.format(filepath=filepath)

        try:
            with open(filepath, "w") as macro_outfile:
                macro_outfile.write(macros)

        except IOError:
            txt = _("Error opening file {filepath}.").format(filepath=filepath)
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=txt)
            except TypeError:
                # The main window does not exist any more
                pass

            wx.EndBusyCursor()

            return False
开发者ID:lorynj,项目名称:pyspread,代码行数:31,代码来源:_main_window_actions.py


示例20: delete_cols

    def delete_cols(self, col, no_cols=1):
        """Deletes no_cols column and marks grid as changed"""

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg,
                           changed=True)

        self.code_array.delete(col, no_cols, axis=1)
开发者ID:sandeep-datta,项目名称:pyspread,代码行数:8,代码来源:_grid_actions.py



注:本文中的src.gui._events.post_command_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python main_window.Pireal类代码示例发布时间:2022-05-27
下一篇:
Python graph.Graph类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap