Working with WxClipboard

Hi All,

I have a python app running on Windows 2000 that makes use of the wxCliboard class. Using a clipboard viewer I can see that text is moving from the app to the clipboard and I'm able to paste from the clipboard into notepad, however, when I switch to Corel Draw, the paste menu is disabled. I can copy the very same text from notepad and successful paste into Corel Draw. It appears that Corel Draw is not getting the message that something has been placed on the clipboard when I put something there using wxClipboard. Here's the relevant code that is called from within a function of a wxTreeCtrl derived class:

            s = self.GetItemText(item)
            cbData = wxPyTextDataObject()
            cbData.SetText(s)

            if wxTheClipboard.Open():
                wxTheClipboard.SetData(cbData)
                wxTheClipboard.Flush()
                wxTheClipboard.Close()

Am I missing something? Has anyone else experience quirky behavior with wxClipboard?

Any thoughts would greatly be appreciated!!

Thanks,
Dave Perkins

David R. Perkins Jr. wrote:

Hi All,

I have a python app running on Windows 2000 that makes use of the wxCliboard class. Using a clipboard viewer I can see that text is moving from the app to the clipboard and I'm able to paste from the clipboard into notepad, however, when I switch to Corel Draw, the paste menu is disabled. I can copy the very same text from notepad and successful paste into Corel Draw. It appears that Corel Draw is not getting the message that something has been placed on the clipboard when I put something there using wxClipboard. Here's the relevant code that is called from within a function of a wxTreeCtrl derived class:

           s = self.GetItemText(item)
           cbData = wxPyTextDataObject()
           cbData.SetText(s)

           if wxTheClipboard.Open():
               wxTheClipboard.SetData(cbData)
               wxTheClipboard.Flush()
               wxTheClipboard.Close()

Am I missing something? Has anyone else experience quirky behavior with wxClipboard?
Any thoughts would greatly be appreciated!!

If you are using a unicode build of wxPython then I think that only unicode text is placed on the clipboard. It could be that Corel Draw is only looking for ansi text. Copying from notepad probably puts both formats on the clipboard and so Corel is able to paste the ansi version.

It would be really nice if wxWidgets put both text formats in the clipboard but nobody has stepped up to do it yet...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

David R. Perkins Jr. wrote:

Hi All,

I have a python app running on Windows 2000 that makes use of the wxCliboard class. Using a clipboard viewer I can see that text is moving from the app to the clipboard and I'm able to paste from the clipboard into notepad, however, when I switch to Corel Draw, the paste menu is disabled. I can copy the very same text from notepad and successful paste into Corel Draw. It appears that Corel Draw is not getting the message that something has been placed on the clipboard when I put something there using wxClipboard. Here's the relevant code that is called from within a function of a wxTreeCtrl derived class:

           s = self.GetItemText(item)
           cbData = wxPyTextDataObject()
           cbData.SetText(s)

           if wxTheClipboard.Open():
               wxTheClipboard.SetData(cbData)
               wxTheClipboard.Flush()
               wxTheClipboard.Close()

Am I missing something? Has anyone else experience quirky behavior with wxClipboard?
Any thoughts would greatly be appreciated!!

If you are using a unicode build of wxPython then I think that only unicode text is placed on the clipboard. It could be that Corel Draw is only looking for ansi text. Copying from notepad probably puts both formats on the clipboard and so Corel is able to paste the ansi version.

It would be really nice if wxWidgets put both text formats in the clipboard but nobody has stepped up to do it yet...

Thanks for your thoughts. I do believe the Windows 2000 machine in question is running the unicode build installed. The quick fix work around was to move the text into a wxTextCtrl and call the Copy() member function of this object which worked out fine. Perhaps this sheds a bit more light on the situation?

Does it make sense to bother with fixing wxWidgets if it is simply the case that Corel Draw is failing to look for unicode text on the clipboard? I'm real happy with wxPython and even though the quick fix above will be suiting us well for the long term, I'd like to pitch in here if it would make a difference. Any hints that might help me navigate to the right spot in the source would be great.

Cheers,
Dave

David R. Perkins Jr. wrote:

Does it make sense to bother with fixing wxWidgets if it is simply the case that Corel Draw is failing to look for unicode text on the clipboard?

It happens with some other apps too.

I'm real happy with wxPython and even though the quick fix above will be suiting us well for the long term, I'd like to pitch in here if it would make a difference.

Any and all help is appreciated.

Any hints that might help me navigate to the right spot in the source would be great.

wxTextDataObject is implemented in wxWidgets/src/common/dobjcmn.cpp. Right now it is expecting to be either DF_UNICODETEXT or DV_TEXT, it would probably have to be changed to provide both at once and to convert as necessary to/from wxString and the requested format.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi
Is there an easy way to format numbers with a thousand separator?
1,000,000.00
Thanks as always
Greg

"Greg Binns" <gregbin@bigpond.net.au> writes:

Is there an easy way to format numbers with a thousand separator?
1,000,000.00

Heh... If you're considering locales things get more complex. The
number you typed above is incorrect down here in .BR. Our thousands
separator is '.' and the decimal separator is ','. Exactly the
opposite. Also, there are other places where you write full-part##cents
(where ## is the symbol of the money).

If you're not worried with locales, you can split the cents, group the
other values 3 at a time and the append the cents back.

···

--
Godoy. <godoy@ieee.org>

Hi Greg,

Greg Binns wrote:

Hi
Is there an easy way to format numbers with a thousand separator?
1,000,000.00

Have a look at wxMaskedNumCtrl, with it you can also handle Jorge's concern, with a bit of work.

See you
Werner

···

Thanks as always
Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

> Is there an easy way to format numbers with a thousand separator?
> 1,000,000.00

Heh... If you're considering locales things get more complex. The
number you typed above is incorrect down here in .BR.

And it gets even more complex in India - 10,00,000.00 . See
http://www.free-definition.com/Lakh.html

Hugh

and 1000,00,00,000.00 (one thousand crores)

kg

···

On Thursday 30 September 2004 06:17 pm, you wrote:

> > Is there an easy way to format numbers with a thousand separator?
> > 1,000,000.00
>
> Heh... If you're considering locales things get more complex. The
> number you typed above is incorrect down here in .BR.

And it gets even more complex in India - 10,00,000.00 .