Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:16:51+00:00 2026-05-28T08:16:51+00:00

I want to cut, paste, copy, and select the text from textcrtl to textcrtl.

  • 0

I want to cut, paste, copy, and select the text from textcrtl to textcrtl. Can anyone help me please, my mind has stack for hours. Look the code below, thanks for your help…

import wx
import os

class Editor(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 500))

        # setting up menubar
        menubar = wx.MenuBar()

        edit = wx.Menu()
        cut = wx.MenuItem(edit, 106, '&Cut\tCtrl+X', 'Cut the Selection')
        edit.AppendItem(cut)

        copy = wx.MenuItem(edit, 107, '&Copy\tCtrl+C', 'Copy the Selection')
        edit.AppendItem(copy)

        paste = wx.MenuItem(edit, 108, '&Paste\tCtrl+V', 'Paste text from clipboard')
        edit.AppendItem(paste)

        delete = wx.MenuItem(edit, 109, '&Delete', 'Delete the selected text')
        edit.AppendItem(delete)

        edit.Append(110, 'Select &All\tCtrl+A', 'Select the entire text')

        menubar.Append(edit, '&Edit')
        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, self.OnCut, id=106)
        self.Bind(wx.EVT_MENU, self.OnCopy, id=107)
        self.Bind(wx.EVT_MENU, self.OnPaste, id=108)
        self.Bind(wx.EVT_MENU, self.OnDelete, id=109)
        self.Bind(wx.EVT_MENU, self.OnSelectAll, id=110)

        self.text = wx.TextCtrl(self, -1, '', (110,55),(120, -1))
        self.text = wx.TextCtrl(self, -1, '', (110,95),(120, -1))
        self.text.SetFocus()

        self.Centre()
        self.Show(True)

    def OnCut(self, event):
         self.text.Cut()

    def OnCopy(self, event):
         self.text.Copy()

    def OnPaste(self, event):
        self.text.Paste()

    def OnDelete(self, event):
        frm, to = self.text.GetSelection()
        self.text.Remove(frm, to)

    def OnSelectAll(self, event):
       self.text.SelectAll()


app = wx.App()
Editor(None, -1, 'Editor')
app.MainLoop() 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:16:52+00:00Added an answer on May 28, 2026 at 8:16 am

    You need to know the wx.TextCtrl instance from which to cut, copy or where to paste text. In the code snippet you provided, you tried to do it with self.text, but as Velociraptors has already said, you initialized self.text twice, so you lost the access to the first wx.TextCtrl by name. Therefore, first you have to get wx.TextCtrl instance you are working with, and then use its methods. This could be done with wx.Frame.FindFocus() class, which returns the widget in a frame which has the focus (or None).

    So, for Cut we get something like this:

    def OnCut(self, event):
        text = self.FindFocus()
        if text is not None:
            text.Cut()
    

    Other methods can be modified the same way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to suppress Cut, Copy and Paste operations in Text Box. I don't
I have a mysql table. I want to cut and paste a value from
I have a situation where i want to copy the text from UILabel as
I want to add an Cut/Copy/Paste ContextMenuStrip in a RichTextBox, but the problem is,
In my App I want to disable the Copy/Paste/Cut of contents that are showed
In emacs, when I want to cut/copy and paste (kill and yank) to or
When I want to implement ViewModel I should cut everything c# code from my
Do you know any way for safe copy cut operation in Android? I want
Anyone want to help make me a better programmer? I have an application where
I want to copy tabular data to Excel from my app. The most simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.