943,653 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 642
  • Python RSS
Nov 28th, 2008
0

Using the wxClipboard

Expand Post »
Hi, Iv been playing about trying to get a string onto the clipboard, but Iv had no luck at all.

Iv done quite a bit of searching, but Iv only ever seen any examples that relate to Windows, and I'm using Ubuntu here.

Any ideas anyone?

Max
Reputation Points: 10
Solved Threads: 1
Light Poster
MaxVK is offline Offline
46 posts
since Nov 2008
Nov 29th, 2008
0

Re: Using the wxClipboard

Okay, Iv spent hours hunting for something to help me and so far nothing has come even close! All the code seems to be either for Windows only, or it simply does not work under Ubuntu 7.10, which is what I'm using.

So, frustrated, Iv opted for a workaround:

I'm using wxGlade to design the interface of the program, so I simply dropped a text control onto the frame and made it invisible. This is called txtCopyBuffer, and I'm sure you can now see where I'm, going with this!

python Syntax (Toggle Plain Text)
  1. #first get the text
  2. x = [The text I want to Copy]
  3. #place this text into the hidden control
  4. self.txtCopyBuffer.SetValue(x)
  5. #select all
  6. self.txtCopyBuffer.SetSelection(-1,-1)
  7. #copy to the clipboard
  8. self.txtCopyBuffer.Copy()
  9. #clear it for next time
  10. self.txtCopyBuffer.Clear()

My apologies to any purists out there, I know it doesn't look pretty, but it does the job, at least until someone, somewhere can tell me how to use the wxClipboard under Linux!

Regards

Max
Reputation Points: 10
Solved Threads: 1
Light Poster
MaxVK is offline Offline
46 posts
since Nov 2008
Nov 29th, 2008
0

Re: Using the wxClipboard

Since I don't have any of the many versions of Linux, I can not test wx.Clipboard. I think it would be easier to store your text in a file for use across programs.

If you use a wx.TextCtrl, can you highlight, rightclick and copy/cut and paste from the popup menu? That would use the clipboard.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Nov 29th, 2008
0

Re: Using the wxClipboard

Thanks sneekula, the problem that I have is that the selected text in a wx.HTML control, and while its possible to select the text, creating a popup menu is very hard because there is no way to get the mouse location from the HTML control, and of course, it doesn't pick up keyboard events for itself either.

That means that any solution will require custom event handlers to try and get keyboard input (CTRL + C) from the HTML control, and if a popup menu is used, also some method of getting the mouse position from it as well.

Iv kind of cheated by getting the selected text and using a button to copy it (and a text control while I'm doing it). I know its a workaround, but it works and it seems less complex than following any other methods.

Max
Reputation Points: 10
Solved Threads: 1
Light Poster
MaxVK is offline Offline
46 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: sequence problem
Next Thread in Python Forum Timeline: python config files zip





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC