[SOLVED] pygame.scrap Not implemented?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Bruni Multimedia
Regular
Posts: 114
Joined: Mon May 15, 2017 12:23 pm
Projects: Yomi Alliance
Organization: Bruni Multimedia
itch: brunimultimedia
Contact:

[SOLVED] pygame.scrap Not implemented?

#1 Post by Bruni Multimedia »

Hi guys. I'm having this issue:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_other.rpy", line 517, in __call__
    rv = self.callable(*self.args, **self.kwargs)
  File "game/script.rpy", line 18, in copytext
    pygame.scrap.put(SCRAP_TEXT, copiedtext.encode("utf-8"))
error: Not implemented.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\ast.py", line 881, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\python.py", line 1913, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\ui.py", line 289, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\core.py", line 2672, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\core.py", line 3477, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\screen.py", line 697, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 244, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 244, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\viewport.py", line 305, in event
    rv = super(Viewport, self).event(ev, x, y, st)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 244, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\behavior.py", line 910, in event
    return handle_click(self.clicked)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\behavior.py", line 845, in handle_click
    rv = run(action)
  File "C:\Program Files\renpy-6.99.14.3-sdk\renpy\display\behavior.py", line 315, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_other.rpy", line 517, in __call__
    rv = self.callable(*self.args, **self.kwargs)
  File "game/script.rpy", line 18, in copytext
    pygame.scrap.put(SCRAP_TEXT, copiedtext.encode("utf-8"))
  File "src/pygame_sdl2/scrap.pyx", line 46, in pygame_sdl2.scrap.put
error: Not implemented.

Windows-8-6.2.9200
Ren'Py 7.1.3.1092
General Practitioner 0.0.21_001
Tue Dec 25 12:13:24 2018
I want players to click on a textbutton and to copy into the clipboard a number sequence (i.e. 1234567)
Then I want a variable to memorize such a sequence reading it from the clipboard.

This issue happens when I click on the "Copy to clipboard" textbutton:

Code: Select all

textbutton "{size=-2}Copy to Clipboard" action Function(copytext, copiedtext="4499258234")

Code: Select all

init python:
    import pygame.scrap
    
    def copytext(copiedtext):
        pygame.scrap.put(SCRAP_TEXT, copiedtext.encode("utf-8"))
        testocopiato = pygame.scrap.get(SCRAP_TEXT)
Can you help me please?
Last edited by Bruni Multimedia on Tue Dec 25, 2018 12:00 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: pygame.scrap Not implemented?

#2 Post by Alex »

Sorry for the question, but why do you need to copy anything anywhere - why not just set a variable and use it later in game?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: pygame.scrap Not implemented?

#3 Post by PyTom »

That should work - you can see the implementation of the function at https://github.com/renpy/pygame_sdl2/bl ... /scrap.pyx . Where are you getting the value of SCRAP_TEXT from? It would fail if that's set incorrectly.

The right way is to use pygame_sdl2.SCRAP_TEXT .
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Bruni Multimedia
Regular
Posts: 114
Joined: Mon May 15, 2017 12:23 pm
Projects: Yomi Alliance
Organization: Bruni Multimedia
itch: brunimultimedia
Contact:

Re: pygame.scrap Not implemented?

#4 Post by Bruni Multimedia »

Alex wrote: Tue Dec 25, 2018 9:47 am Sorry for the question, but why do you need to copy anything anywhere - why not just set a variable and use it later in game?
Because I need players to input a 10-digit code to fast-access medical examinations, which are coded this way to avoid duplicates and which starting labels are made like this: P28948882388_start, so they can input the code and the examination starts.

Since the Codex of the game contains such codes it's easier for players to just click a textbutton in the Codex to have the code copied in the clipboard, hence it can be used to call the label when I put it into the variable (and to check if such a code exists by checking the starting label's own existence).

@pytom might work in fact, I was using pygame.scrap.get(SCRAP_TEXT) by reading the python.pygame documentation, haven't seen _sdl2 in use by googling around ;) I'll let you know once I try it.

User avatar
Bruni Multimedia
Regular
Posts: 114
Joined: Mon May 15, 2017 12:23 pm
Projects: Yomi Alliance
Organization: Bruni Multimedia
itch: brunimultimedia
Contact:

Re: pygame.scrap Not implemented?

#5 Post by Bruni Multimedia »

Thanks Tom, worked like a charm!

And I almost forgot (being at work even today must have made it slip my mind!)! Merry Christmas to all of you guys!!

Post Reply

Who is online

Users browsing this forum: Andredron