本文整理汇总了Python中src.gui._events.post_command_event函数的典型用法代码示例。如果您正苦于以下问题:Python post_command_event函数的具体用法?Python post_command_event怎么用?Python post_command_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post_command_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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)
示例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()
示例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
示例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)
示例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)
示例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()
示例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)
示例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()
示例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)
示例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()
示例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)
示例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)