On Fri, 2012-07-13 at 18:05 +0200, Marcus von Appen wrote: > What external application? What underlying UI toolkit does it use? How > do you put text into the clipboard with it? Where do you paste the > content to? How do you paste the content (middle mouse button, special > other operation, application-builtin command)? This particular application was gedit, so a GTK+ application. Copied normally using Ctrl+C. The output is from pushing 'p' in the previous program which displays the available types and content from scrap. > > And, this is the output from pasting something from pygame: > > > > UTF8_STRING Test string > > TEXT Test string > > STRING Test string > > text/plain Test string > > Am I right that you refer to the test program above? Where do you paste > the content to and how do you do it? This output is from simply pushing 'c' then 'p' in the previous program. > > The problem, is that the SCAP_TEXT constant is "text/plain". As can be > > seen, this is None from an external application. > > If the external application does not set the mime-type text/plain, then > it is None, correct. Of course, but it did set text/plain, but added charset information to the type, so it counts as something separate as far as Pygame is concerned. > TEXT is quite strict in its definition within the X11 libraries, > especially when it comes to the encoding (woohay, multibyte...). It > might be better to change the SCRAP_TEXT definition to > "text/plain;charset=utf-8" as default - if most other applications > support it already. > Otherwise I'd recommend to query the available types first and then pick > the content for the type that suits the application-specific needs best. Whatever you think is best. If nothing is changed, it should atleast be mentioned in the documentation. It confused me for awhile, as to why I couldn't paste stuff from another application. Now I realise I can if I avoid the SCRAP_TEXT constant. Program repeated for convenience: import pygame from pygame.locals import * pygame.display.init() screen = pygame.display.set_mode((600,480)) pygame.scrap.init() while True: e = pygame.event.wait() if e.type == KEYDOWN: if e.key == K_c: pygame.scrap.put(SCRAP_TEXT, "Test string") elif e.key == K_p: types = pygame.scrap.get_types() for t in types: print t, pygame.scrap.get(t) elif e.key == K_ESCAPE: break
Attachment:
signature.asc
Description: This is a digitally signed message part