示例#1
0
 def OnCopyButtonPressed(self, evt: wx.CommandEvent):
     wx.TheClipboard: wx.Clipboard
     if wx.TheClipboard.Open():
         addin = '' if wx.KeyboardState().ShiftDown() else '```'
         wx.TheClipboard.SetData(
             wx.TextDataObject(f'{addin}\n{self.text.GetValue()}{addin}'))
         wx.TheClipboard.Close()
示例#2
0
def clickcell(grid, leftright, row, col, **kw):
    """Simulate left or right mouse click over wx.grid.Grid

    Parameters
    ----------
    grid : wx.grid.Grid
        The grid object to be clicked
    leftright : str
        The button that is clicked, possible values are ("left", "right").
    row : int
        The zero-based row of the clicked cell.
    col : int
        The zero-based columnt of the clicked cell.
    kw : misc, optional
        Keyword arguments for the wx.GridEvent constructor.
        Typically a keyboard modifier for the click.
    """
    assert leftright in ('left', 'right')
    if leftright == "left":
        eventtype = wx.grid.EVT_GRID_CELL_LEFT_CLICK.typeId
    else:
        eventtype = wx.grid.EVT_GRID_CELL_RIGHT_CLICK.typeId
    kbd = {'kbd': wx.KeyboardState(**kw)}
    # TODO: remove this after deprecations of wxpython 3
    if wx.VERSION[0] == 3:
        kbd = {k.replace('Down', ''): v for k, v in kw.items()}
    e = wx.grid.GridEvent(grid.Id, eventtype, grid, row, col, **kbd)
    grid.ProcessEvent(e)
    return
示例#3
0
 def on_design_button(self):
     "Button 'Show Design Window' was pressed"
     if self.widget and config.debugging and wx.KeyboardState().ShiftDown():
         import utilities
         utilities.StructurePrinter(self.widget)
         return
     if not self.widget or not self.is_visible():
         common.app_tree.show_toplevel(None, self)
     else:
         self.hide_widget()
     self.design.update_label()
示例#4
0
 def on_preview(self, refresh=False):
     if self.preview_widget and compat.IS_PHOENIX and config.debugging and wx.KeyboardState().ShiftDown():
         # print structure for debugging
         import utilities
         utilities.StructurePrinter(self.preview_widget)
         return
     new_label = None
     if self.preview_widget is None:
         self.preview_widget = common.app_tree.app.preview(self, self._preview_position)
         if self.preview_widget:
             new_label = _('Close Preview')
     else:
         self._preview_position = self.preview_widget.GetPosition()  # remember position
         self.preview_widget.Close()
         self.preview_widget = None
         new_label = _('Show Preview')
         if refresh: wx.CallAfter(self.on_preview)
     if new_label is not None:
         self.properties["preview"].set_label(new_label)
示例#5
0
 def test_KeyboardState(self):
     ks = wx.KeyboardState(False, True, False, True)
     ks.controlDown
     ks.shiftDown
     ks.altDown
     ks.cmdDown