INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Returns xls workbook object with everything from code_array | def from_code_array(self):
"""Returns xls workbook object with everything from code_array"""
worksheets = []
self._shape2xls(worksheets)
self._code2xls(worksheets)
self._row_heights2xls(worksheets)
self._col_widths2xls(worksheets)
return self.workbook |
Replaces everything in code_array from xls_file | def to_code_array(self):
"""Replaces everything in code_array from xls_file"""
self._xls2shape()
worksheets = self.workbook.sheet_names()
for tab, worksheet_name in enumerate(worksheets):
worksheet = self.workbook.sheet_by_name(worksheet_name)
self._xls2code(wo... |
Rstrips string for \n and splits string for \t | def _split_tidy(self, string, maxsplit=None):
"""Rstrips string for \n and splits string for \t"""
if maxsplit is None:
return string.rstrip("\n").split("\t")
else:
return string.rstrip("\n").split("\t", maxsplit) |
Asserts pys file version | def _pys_assert_version(self, line):
"""Asserts pys file version"""
if float(line.strip()) > 1.0:
# Abort if file version not supported
msg = _("File version {version} unsupported (>1.0).").format(
version=line.strip())
raise ValueError(msg) |
Writes shape to pys file
Format: <rows>\t<cols>\t<tabs>\n | def _shape2pys(self):
"""Writes shape to pys file
Format: <rows>\t<cols>\t<tabs>\n
"""
shape_line = u"\t".join(map(unicode, self.code_array.shape)) + u"\n"
self.pys_file.write(shape_line) |
Updates shape in code_array | def _pys2shape(self, line):
"""Updates shape in code_array"""
self.code_array.shape = self._get_key(*self._split_tidy(line)) |
Writes code to pys file
Format: <row>\t<col>\t<tab>\t<code>\n | def _code2pys(self):
"""Writes code to pys file
Format: <row>\t<col>\t<tab>\t<code>\n
"""
for key in self.code_array:
key_str = u"\t".join(repr(ele) for ele in key)
code_str = self.code_array(key)
if code_str is not None:
out_str = k... |
Updates code in pys code_array | def _pys2code(self, line):
"""Updates code in pys code_array"""
row, col, tab, code = self._split_tidy(line, maxsplit=3)
key = self._get_key(row, col, tab)
self.code_array.dict_grid[key] = unicode(code, encoding='utf-8') |
Writes attributes to pys file
Format:
<selection[0]>\t[...]\t<tab>\t<key>\t<value>\t[...]\n | def _attributes2pys(self):
"""Writes attributes to pys file
Format:
<selection[0]>\t[...]\t<tab>\t<key>\t<value>\t[...]\n
"""
# Remove doublettes
purged_cell_attributes = []
purged_cell_attributes_keys = []
for selection, tab, attr_dict in self.code_arr... |
Updates attributes in code_array | def _pys2attributes(self, line):
"""Updates attributes in code_array"""
splitline = self._split_tidy(line)
selection_data = map(ast.literal_eval, splitline[:5])
selection = Selection(*selection_data)
tab = int(splitline[5])
attrs = {}
for col, ele in enumerate... |
Writes row_heights to pys file
Format: <row>\t<tab>\t<value>\n | def _row_heights2pys(self):
"""Writes row_heights to pys file
Format: <row>\t<tab>\t<value>\n
"""
for row, tab in self.code_array.dict_grid.row_heights:
if row < self.code_array.shape[0] and \
tab < self.code_array.shape[2]:
height = self.cod... |
Updates row_heights in code_array | def _pys2row_heights(self, line):
"""Updates row_heights in code_array"""
# Split with maxsplit 3
split_line = self._split_tidy(line)
key = row, tab = self._get_key(*split_line[:2])
height = float(split_line[2])
shape = self.code_array.shape
try:
if... |
Writes col_widths to pys file
Format: <col>\t<tab>\t<value>\n | def _col_widths2pys(self):
"""Writes col_widths to pys file
Format: <col>\t<tab>\t<value>\n
"""
for col, tab in self.code_array.dict_grid.col_widths:
if col < self.code_array.shape[1] and \
tab < self.code_array.shape[2]:
width = self.code_ar... |
Updates col_widths in code_array | def _pys2col_widths(self, line):
"""Updates col_widths in code_array"""
# Split with maxsplit 3
split_line = self._split_tidy(line)
key = col, tab = self._get_key(*split_line[:2])
width = float(split_line[2])
shape = self.code_array.shape
try:
if co... |
Writes macros to pys file
Format: <macro code line>\n | def _macros2pys(self):
"""Writes macros to pys file
Format: <macro code line>\n
"""
macros = self.code_array.dict_grid.macros
pys_macros = macros.encode("utf-8")
self.pys_file.write(pys_macros) |
Updates macros in code_array | def _pys2macros(self, line):
"""Updates macros in code_array"""
if self.code_array.dict_grid.macros and \
self.code_array.dict_grid.macros[-1] != "\n":
# The last macro line does not end with \n
# Therefore, if not new line is inserted, the codeis broken
s... |
Writes fonts to pys file | def _fonts2pys(self):
"""Writes fonts to pys file"""
# Get mapping from fonts to fontfiles
system_fonts = font_manager.findSystemFonts()
font_name2font_file = {}
for sys_font in system_fonts:
font_name = font_manager.FontProperties(fname=sys_font).get_name()
... |
Updates custom font list | def _pys2fonts(self, line):
"""Updates custom font list"""
font_name, ascii_font_data = self._split_tidy(line)
font_data = base64.b64decode(ascii_font_data)
# Get system font names
system_fonts = font_manager.findSystemFonts()
system_font_names = []
for sys_fon... |
Replaces everything in pys_file from code_array | def from_code_array(self):
"""Replaces everything in pys_file from code_array"""
for key in self._section2writer:
self.pys_file.write(key)
self._section2writer[key]()
try:
if self.pys_file.aborted:
break
except Attribu... |
Replaces everything in code_array from pys_file | def to_code_array(self):
"""Replaces everything in code_array from pys_file"""
state = None
# Check if version section starts with first line
first_line = True
# Reset pys_file to start to enable multiple calls of this method
self.pys_file.seek(0)
for line in ... |
Set editor style | def _style(self):
"""Set editor style"""
self.fold_symbols = 2
"""
Fold symbols
------------
The following styles are pre-defined:
"arrows" Arrow pointing right for contracted folders,
arrow pointing down for expanded
"p... |
Syntax highlighting while editing | def OnUpdateUI(self, evt):
"""Syntax highlighting while editing"""
# check for matching braces
brace_at_caret = -1
brace_opposite = -1
char_before = None
caret_pos = self.GetCurrentPos()
if caret_pos > 0:
char_before = self.GetCharAt(caret_pos - 1)
... |
When clicked, old and unfold as needed | def OnMarginClick(self, evt):
"""When clicked, old and unfold as needed"""
if evt.GetMargin() == 2:
if evt.GetShift() and evt.GetControl():
self.fold_all()
else:
line_clicked = self.LineFromPosition(evt.GetPosition())
if self.GetF... |
Folds/unfolds all levels in the editor | def fold_all(self):
"""Folds/unfolds all levels in the editor"""
line_count = self.GetLineCount()
expanding = True
# find out if we are folding or unfolding
for line_num in range(line_count):
if self.GetFoldLevel(line_num) & stc.STC_FOLDLEVELHEADERFLAG:
... |
Multi-purpose expand method from original STC class | def expand(self, line, do_expand, force=False, vislevels=0, level=-1):
"""Multi-purpose expand method from original STC class"""
lastchild = self.GetLastChild(line, level)
line += 1
while line <= lastchild:
if force:
if vislevels > 0:
sel... |
Called for drawing the background area of each item
Overridden from OwnerDrawnComboBox | def OnDrawBackground(self, dc, rect, item, flags):
"""Called for drawing the background area of each item
Overridden from OwnerDrawnComboBox
"""
# If the item is selected, or its item is even,
# or if we are painting the combo control itself
# then use the default rend... |
Returns code for given label string
Inverse of get_code
Parameters
----------
label: String
\tLlabel string, field 0 of style tuple | def get_style_code(self, label):
"""Returns code for given label string
Inverse of get_code
Parameters
----------
label: String
\tLlabel string, field 0 of style tuple
"""
for style in self.styles:
if style[0] == label:
retu... |
Returns string label for given code string
Inverse of get_code
Parameters
----------
code: String
\tCode string, field 1 of style tuple | def get_label(self, code):
"""Returns string label for given code string
Inverse of get_code
Parameters
----------
code: String
\tCode string, field 1 of style tuple
"""
for style in self.styles:
if style[1] == code:
return ... |
Returns the height of the items in the popup | def OnMeasureItem(self, item):
"""Returns the height of the items in the popup"""
item_name = self.GetItems()[item]
return icons[item_name].GetHeight() |
Returns the height of the items in the popup | def OnMeasureItemWidth(self, item):
"""Returns the height of the items in the popup"""
item_name = self.GetItems()[item]
return icons[item_name].GetWidth() |
Toggles state to next bitmap | def toggle(self, event):
"""Toggles state to next bitmap"""
if self.state < len(self.bitmap_list) - 1:
self.state += 1
else:
self.state = 0
self.SetBitmapLabel(self.bitmap_list[self.state])
try:
event.Skip()
except AttributeError:
... |
Toggle button event handler | def OnToggle(self, event):
"""Toggle button event handler"""
if self.selection_toggle_button.GetValue():
self.entry_line.last_selection = self.entry_line.GetSelection()
self.entry_line.last_selection_string = \
self.entry_line.GetStringSelection()
sel... |
Event handler for updating the content | def OnContentChange(self, event):
"""Event handler for updating the content"""
self.ignore_changes = True
self.SetValue(u"" if event.text is None else event.text)
self.ignore_changes = False
event.Skip() |
Event handler for grid selection in selection mode adds text | def OnGridSelection(self, event):
"""Event handler for grid selection in selection mode adds text"""
current_table = copy(self.main_window.grid.current_table)
post_command_event(self, self.GridActionTableSwitchMsg,
newtable=self.last_table)
if is_gtk():
... |
Text event method evals the cell and updates the grid | def OnText(self, event):
"""Text event method evals the cell and updates the grid"""
if not self.ignore_changes:
post_command_event(self, self.CodeEntryMsg, code=event.GetString())
self.main_window.grid.grid_renderer.cell_cache.clear()
event.Skip() |
Key event method
* Forces grid update on <Enter> key
* Handles insertion of cell access code | def OnChar(self, event):
"""Key event method
* Forces grid update on <Enter> key
* Handles insertion of cell access code
"""
if not self.ignore_changes:
# Handle special keys
keycode = event.GetKeyCode()
if keycode == 13 and not self.Get... |
Table changed event handler | def OnTableChanged(self, event):
"""Table changed event handler"""
if hasattr(event, 'updated_cell'):
# Event posted by cell edit widget. Even more up to date
# than the current cell's contents
self.ignore_changes = True
try:
self.SetVal... |
Reposition the checkbox | def Reposition(self):
"""Reposition the checkbox"""
rect = self.GetFieldRect(1)
self.safemode_staticbmp.SetPosition((rect.x, rect.y))
self.size_changed = False |
Updates to a new number of tables
Fixes current table if out of bounds.
Parameters
----------
no_tabs: Integer
\tNumber of tables for choice | def change_max(self, no_tabs):
"""Updates to a new number of tables
Fixes current table if out of bounds.
Parameters
----------
no_tabs: Integer
\tNumber of tables for choice
"""
self.no_tabs = no_tabs
if self.GetValue() >= no_tabs:
... |
Conversion function used in getting the value of the control. | def _fromGUI(self, value):
"""
Conversion function used in getting the value of the control.
"""
# One or more of the underlying text control implementations
# issue an intermediate EVT_TEXT when replacing the control's
# value, where the intermediate value is an empty ... |
IntCtrl event method that updates the current table | def OnInt(self, event):
"""IntCtrl event method that updates the current table"""
value = event.GetValue()
current_time = time.clock()
if current_time < self.last_change_s + 0.01:
return
self.last_change_s = current_time
self.cursor_pos = wx.TextCtrl.GetIns... |
Mouse wheel event handler | def OnMouseWheel(self, event):
"""Mouse wheel event handler"""
# Prevent lost IntCtrl changes
if self.switching:
time.sleep(0.1)
return
value = self.GetValue()
current_time = time.clock()
if current_time < self.last_change_s + 0.01:
... |
Table changed event handler | def OnTableChanged(self, event):
"""Table changed event handler"""
if hasattr(event, 'table'):
self.SetValue(event.table)
wx.TextCtrl.SetInsertionPoint(self, self.cursor_pos)
event.Skip() |
Item selection event handler | def OnItemSelected(self, event):
"""Item selection event handler"""
value = event.m_itemIndex
self.startIndex = value
self.switching = True
post_command_event(self, self.GridActionTableSwitchMsg, newtable=value)
self.switching = False
event.Skip() |
Event handler for grid resizing | def OnResizeGrid(self, event):
"""Event handler for grid resizing"""
shape = min(event.shape[2], 2**30)
self.SetItemCount(shape)
event.Skip() |
Table changed event handler | def OnTableChanged(self, event):
"""Table changed event handler"""
if hasattr(event, 'table'):
self.Select(event.table)
self.EnsureVisible(event.table)
event.Skip() |
Generate a dropIndex.
Process: check self.IsInControl, check self.IsDrag, HitTest,
compare HitTest value
The mouse can end up in 5 different places:
Outside the Control
On itself
Above its starting point and on another item
Below its starting point and o... | def OnMouseUp(self, event):
"""Generate a dropIndex.
Process: check self.IsInControl, check self.IsDrag, HitTest,
compare HitTest value
The mouse can end up in 5 different places:
Outside the Control
On itself
Above its starting point and on another item... |
Setup title, icon, size, scale, statusbar, main grid | def _set_properties(self):
"""Setup title, icon, size, scale, statusbar, main grid"""
self.set_icon(icons["PyspreadLogo"])
# Without minimum size, initial size is minimum size in wxGTK
self.minSizeSet = False
# Leave save mode
post_command_event(self, self.SafeModeExit... |
Enable menu bar view item checkmarks | def _set_menu_toggles(self):
"""Enable menu bar view item checkmarks"""
toggles = [
(self.main_toolbar, "main_window_toolbar", _("Main toolbar")),
(self.macro_toolbar, "macro_toolbar", _("Macro toolbar")),
(self.macro_panel, "macro_panel", _("Macro panel")),
... |
Adds widgets to the aui manager and controls the layout | def _do_layout(self):
"""Adds widgets to the aui manager and controls the layout"""
# Set background color for the toolbar via the manager
ap = self._mgr.GetArtProvider()
ap.SetColour(aui.AUI_DOCKART_BACKGROUND_GRADIENT_COLOUR,
get_color(config["background_color"]))... |
Bind events to handlers | def _bind(self):
"""Bind events to handlers"""
handlers = self.handlers
# Main window events
self.Bind(wx.EVT_MOVE, handlers.OnMove)
self.Bind(wx.EVT_SIZE, handlers.OnSize)
self.Bind(self.EVT_CMD_FULLSCREEN, handlers.OnToggleFullscreen)
# Content changed event,... |
Sets main window icon to given wx.Bitmap | def set_icon(self, bmp):
"""Sets main window icon to given wx.Bitmap"""
_icon = wx.EmptyIcon()
_icon.CopyFromBitmap(bmp)
self.SetIcon(_icon) |
Main window move event | def OnMove(self, event):
"""Main window move event"""
# Store window position in config
position = self.main_window.GetScreenPositionTuple()
config["window_position"] = repr(position) |
Main window move event | def OnSize(self, event):
"""Main window move event"""
# Store window size in config
size = event.GetSize()
config["window_size"] = repr((size.width, size.height)) |
Fullscreen event handler | def OnToggleFullscreen(self, event):
"""Fullscreen event handler"""
is_full_screen = self.main_window.IsFullScreen()
# Make sure that only the grid is shown in fullscreen mode
if is_full_screen:
try:
self.main_window.grid.SetRowLabelSize(self.row_label_size)... |
Titlebar star adjustment event handler | def OnContentChanged(self, event):
"""Titlebar star adjustment event handler"""
self.main_window.grid.update_attribute_toolbar()
title = self.main_window.GetTitle()
if undo.stack().haschanged():
# Put * in front of title
if title[:2] != "* ":
ne... |
Safe mode entry event handler | def OnSafeModeEntry(self, event):
"""Safe mode entry event handler"""
# Enable menu item for leaving safe mode
self.main_window.main_menu.enable_file_approve(True)
self.main_window.grid.Refresh()
event.Skip() |
Safe mode exit event handler | def OnSafeModeExit(self, event):
"""Safe mode exit event handler"""
# Run macros
# self.MainGrid.model.pysgrid.sgrid.execute_macros(safe_mode=False)
# Disable menu item for leaving safe mode
self.main_window.main_menu.enable_file_approve(False)
self.main_window.grid.... |
Program exit event handler | def OnClose(self, event):
"""Program exit event handler"""
# If changes have taken place save of old grid
if undo.stack().haschanged():
save_choice = self.interfaces.get_save_request_from_user()
if save_choice is None:
# Cancelled close operation
... |
Spell checking toggle event handler | def OnSpellCheckToggle(self, event):
"""Spell checking toggle event handler"""
spelltoolid = self.main_window.main_toolbar.label2id["CheckSpelling"]
self.main_window.main_toolbar.ToggleTool(spelltoolid,
not config["check_spelling"])
conf... |
Preferences event handler that launches preferences dialog | def OnPreferences(self, event):
"""Preferences event handler that launches preferences dialog"""
preferences = self.interfaces.get_preferences_from_user()
if preferences:
for key in preferences:
if type(config[key]) in (type(u""), type("")):
conf... |
New GPG key event handler.
Launches GPG choice and creation dialog | def OnNewGpgKey(self, event):
"""New GPG key event handler.
Launches GPG choice and creation dialog
"""
if gnupg is None:
return
if genkey is None:
# gnupg is not present
self.interfaces.display_warning(
_("Python gnupg not ... |
Toggles visibility of given aui pane
Parameters
----------
pane: String
\tPane name | def _toggle_pane(self, pane):
"""Toggles visibility of given aui pane
Parameters
----------
pane: String
\tPane name
"""
if pane.IsShown():
pane.Hide()
else:
pane.Show()
self.main_window._mgr.Update() |
Main window toolbar toggle event handler | def OnMainToolbarToggle(self, event):
"""Main window toolbar toggle event handler"""
self.main_window.main_toolbar.SetGripperVisible(True)
main_toolbar_info = \
self.main_window._mgr.GetPane("main_window_toolbar")
self._toggle_pane(main_toolbar_info)
event.Skip() |
Macro toolbar toggle event handler | def OnMacroToolbarToggle(self, event):
"""Macro toolbar toggle event handler"""
self.main_window.macro_toolbar.SetGripperVisible(True)
macro_toolbar_info = self.main_window._mgr.GetPane("macro_toolbar")
self._toggle_pane(macro_toolbar_info)
event.Skip() |
Widget toolbar toggle event handler | def OnWidgetToolbarToggle(self, event):
"""Widget toolbar toggle event handler"""
self.main_window.widget_toolbar.SetGripperVisible(True)
widget_toolbar_info = self.main_window._mgr.GetPane("widget_toolbar")
self._toggle_pane(widget_toolbar_info)
event.Skip() |
Format toolbar toggle event handler | def OnAttributesToolbarToggle(self, event):
"""Format toolbar toggle event handler"""
self.main_window.attributes_toolbar.SetGripperVisible(True)
attributes_toolbar_info = \
self.main_window._mgr.GetPane("attributes_toolbar")
self._toggle_pane(attributes_toolbar_info)
... |
Search toolbar toggle event handler | def OnFindToolbarToggle(self, event):
"""Search toolbar toggle event handler"""
self.main_window.find_toolbar.SetGripperVisible(True)
find_toolbar_info = self.main_window._mgr.GetPane("find_toolbar")
self._toggle_pane(find_toolbar_info)
event.Skip() |
Entry line toggle event handler | def OnEntryLineToggle(self, event):
"""Entry line toggle event handler"""
entry_line_panel_info = \
self.main_window._mgr.GetPane("entry_line_panel")
self._toggle_pane(entry_line_panel_info)
event.Skip() |
Table list toggle event handler | def OnTableListToggle(self, event):
"""Table list toggle event handler"""
table_list_panel_info = \
self.main_window._mgr.GetPane("table_list_panel")
self._toggle_pane(table_list_panel_info)
event.Skip() |
Pane close toggle event handler (via close button) | def OnPaneClose(self, event):
"""Pane close toggle event handler (via close button)"""
toggle_label = event.GetPane().caption
# Get menu item to toggle
menubar = self.main_window.menubar
toggle_id = menubar.FindMenuItem(_("View"), toggle_label)
toggle_item = menubar.Fin... |
New grid event handler | def OnNew(self, event):
"""New grid event handler"""
# If changes have taken place save of old grid
if undo.stack().haschanged():
save_choice = self.interfaces.get_save_request_from_user()
if save_choice is None:
# Cancelled close operation
... |
File open event handler | def OnOpen(self, event):
"""File open event handler"""
# If changes have taken place save of old grid
if undo.stack().haschanged():
save_choice = self.interfaces.get_save_request_from_user()
if save_choice is None:
# Cancelled close operation
... |
File save event handler | def OnSave(self, event):
"""File save event handler"""
try:
filetype = event.attr["filetype"]
except (KeyError, AttributeError):
filetype = None
filepath = self.main_window.filepath
if filepath is None:
filetype = config["default_save_filety... |
File save as event handler | def OnSaveAs(self, event):
"""File save as event handler"""
# Get filepath from user
f2w = get_filetypes2wildcards(["pys", "pysu", "xls", "all"])
filetypes = f2w.keys()
wildcards = f2w.values()
wildcard = "|".join(wildcards)
message = _("Choose filename for sa... |
File import event handler | def OnImport(self, event):
"""File import event handler"""
# Get filepath from user
wildcards = get_filetypes2wildcards(["csv", "txt"]).values()
wildcard = "|".join(wildcards)
message = _("Choose file to import.")
style = wx.OPEN
filepath, filterindex = \
... |
File export event handler
Currently, only CSV export is supported | def OnExport(self, event):
"""File export event handler
Currently, only CSV export is supported
"""
code_array = self.main_window.grid.code_array
tab = self.main_window.grid.current_table
selection = self.main_window.grid.selection
# Check if no selection is ... |
Export PDF event handler | def OnExportPDF(self, event):
"""Export PDF event handler"""
wildcards = get_filetypes2wildcards(["pdf"]).values()
if not wildcards:
return
wildcard = "|".join(wildcards)
# Get filepath from user
message = _("Choose file path for PDF export.")
sty... |
File approve event handler | def OnApprove(self, event):
"""File approve event handler"""
if not self.main_window.safe_mode:
return
msg = _(u"You are going to approve and trust a file that\n"
u"you have not created yourself.\n"
u"After proceeding, the file is executed.\n \n"
... |
Clear globals event handler | def OnClearGlobals(self, event):
"""Clear globals event handler"""
msg = _("Deleting globals and reloading modules cannot be undone."
" Proceed?")
short_msg = _("Really delete globals and modules?")
choice = self.main_window.interfaces.get_warning_choice(msg, short_msg)... |
Page setup handler for printing framework | def OnPageSetup(self, event):
"""Page setup handler for printing framework"""
print_data = self.main_window.print_data
new_print_data = \
self.main_window.interfaces.get_print_setup(print_data)
self.main_window.print_data = new_print_data |
Returns selection bounding box or visible area | def _get_print_area(self):
"""Returns selection bounding box or visible area"""
# Get print area from current selection
selection = self.main_window.grid.selection
print_area = selection.get_bbox()
# If there is no selection use the visible area on the screen
if print_a... |
Print event handler | def OnPrint(self, event):
"""Print event handler"""
print_area = self._get_print_area()
print_data = self.main_window.print_data
self.main_window.actions.printout(print_area, print_data) |
Clipboard cut event handler | def OnCut(self, event):
"""Clipboard cut event handler"""
entry_line = \
self.main_window.entry_line_panel.entry_line_panel.entry_line
if wx.Window.FindFocus() != entry_line:
selection = self.main_window.grid.selection
with undo.group(_("Cut")):
... |
Clipboard copy event handler | def OnCopy(self, event):
"""Clipboard copy event handler"""
focus = self.main_window.FindFocus()
if isinstance(focus, wx.TextCtrl):
# Copy selection from TextCtrl if in focus
focus.Copy()
else:
selection = self.main_window.grid.selection
... |
Clipboard copy results event handler | def OnCopyResult(self, event):
"""Clipboard copy results event handler"""
selection = self.main_window.grid.selection
data = self.main_window.actions.copy_result(selection)
# Check if result is a bitmap
if type(data) is wx._gdi.Bitmap:
# Copy bitmap to clipboard
... |
Clipboard paste event handler | def OnPaste(self, event):
"""Clipboard paste event handler"""
data = self.main_window.clipboard.get_clipboard()
focus = self.main_window.FindFocus()
if isinstance(focus, wx.TextCtrl):
# Paste into TextCtrl if in focus
focus.WriteText(data)
else:
... |
Clipboard paste as event handler | def OnPasteAs(self, event):
"""Clipboard paste as event handler"""
data = self.main_window.clipboard.get_clipboard()
key = self.main_window.grid.actions.cursor
with undo.group(_("Paste As...")):
self.main_window.actions.paste_as(key, data)
self.main_window.grid.For... |
Select all cells event handler | def OnSelectAll(self, event):
"""Select all cells event handler"""
entry_line = \
self.main_window.entry_line_panel.entry_line_panel.entry_line
if wx.Window.FindFocus() != entry_line:
self.main_window.grid.SelectAll()
else:
entry_line.SelectAll() |
Event handler for launching font dialog | def OnFontDialog(self, event):
"""Event handler for launching font dialog"""
# Get current font data from current cell
cursor = self.main_window.grid.actions.cursor
attr = self.main_window.grid.code_array.cell_attributes[cursor]
size, style, weight, font = \
[attr[n... |
Event handler for launching text color dialog | def OnTextColorDialog(self, event):
"""Event handler for launching text color dialog"""
dlg = wx.ColourDialog(self.main_window)
# Ensure the full colour dialog is displayed,
# not the abbreviated version.
dlg.GetColourData().SetChooseFull(True)
if dlg.ShowModal() == wx... |
Macro list load event handler | 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 =... |
Macro list save event handler | def OnMacroListSave(self, event):
"""Macro list save event handler"""
# Get filepath from user
wildcards = get_filetypes2wildcards(["py", "all"]).values()
wildcard = "|".join(wildcards)
message = _("Choose macro file.")
style = wx.SAVE
filepath, filterindex =... |
Display dependency dialog | def OnDependencies(self, event):
"""Display dependency dialog"""
dlg = DependencyDialog(self.main_window)
dlg.ShowModal()
dlg.Destroy() |
Adds items in data as a submenu to parent | def _add_submenu(self, parent, data):
"""Adds items in data as a submenu to parent"""
for item in data:
obj = item[0]
if obj == wx.Menu:
try:
__, menuname, submenu, menu_id = item
except ValueError:
__, menu... |
Menu event handler | def OnMenu(self, event):
"""Menu event handler"""
msgtype = self.ids_msgs[event.GetId()]
post_command_event(self.parent, msgtype) |
Menu state update | def OnUpdate(self, event):
"""Menu state update"""
if wx.ID_UNDO in self.id2menuitem:
undo_item = self.id2menuitem[wx.ID_UNDO]
undo_item.Enable(undo.stack().canundo())
if wx.ID_REDO in self.id2menuitem:
redo_item = self.id2menuitem[wx.ID_REDO]
re... |
Enables or disables menu item (for entering/leaving save mode) | def enable_file_approve(self, enable=True):
"""Enables or disables menu item (for entering/leaving save mode)"""
approve_item = self.shortcut2menuitem[_("&Approve file")]
approve_item.Enable(enable) |
Sets widget from code string
Parameters
----------
code: String
\tCode representation of bool value | def set_code(self, code):
"""Sets widget from code string
Parameters
----------
code: String
\tCode representation of bool value
"""
# If string representations of False are in the code
# then it has to be converted explicitly
if code == "False... |
Binds events to handlers | def __bindings(self):
"""Binds events to handlers"""
self.textctrl.Bind(wx.EVT_TEXT, self.OnText)
self.fontbutton.Bind(wx.EVT_BUTTON, self.OnFont)
self.Bind(csel.EVT_COLOURSELECT, self.OnColor) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.