Python Extension

@savardo I just tried the py-env tag and that is not working. I set it up like you

<body>
  <py-env>
    - colored
    - sys
    <py-script>
      colorR = fg('red')
      colorO = fg('light_red')
      colorL = fg('yellow')
      colorG = fg('green')
      colorB = fg('blue')
      colorP = fg('purple_1a')
      colorW = fg('white')
      colorBl = fg('black')
      
      def typingPrint(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        
      def typingInput(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        value = input()  
        return value
      
      def br(times):
        for i in range(times):
          print()
    </py-script>
  <script src="main.js"></script>
  </py-env>  
  </body>

According to what @savardo said, I think this would be the correct format:

<body>
  <py-env>
    - colored
    - sys
  </py-env>  
  <py-script>
      colorR = fg('red')
      colorO = fg('light_red')
      colorL = fg('yellow')
      colorG = fg('green')
      colorB = fg('blue')
      colorP = fg('purple_1a')
      colorW = fg('white')
      colorBl = fg('black')
      
      def typingPrint(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        
      def typingInput(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        value = input()  
        return value
      
      def br(times):
        for i in range(times):
          print()
  </py-script>
  <script src="main.js"></script>
  </body>
3 Likes

@Firepup650 when I run it it give me a page not found error.

You will still need to add the import statements inside the <py-script> though

2 Likes

@savardo like this?

<py-script>
    <py-env>
      - colored
      - sys  
    </py-env>
      colorR = fg('red')
      colorO = fg('light_red')
      colorL = fg('yellow')
      colorG = fg('green')
      colorB = fg('blue')
      colorP = fg('purple_1a')
      colorW = fg('white')
      colorBl = fg('black')
      
      def typingPrint(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        
      def typingInput(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        value = input()  
        return value
      
      def br(times):
        for i in range(times):
  </py-script>
  <script src="main.js"></script>
1 Like

Like this I believe:

<body>
  <py-env>
    - colored
    - sys
  </py-env> 
  <py-script>
      import sys
      from colored import fg
      colorR = fg('red')
      colorO = fg('light_red')
      colorL = fg('yellow')
      colorG = fg('green')
      colorB = fg('blue')
      colorP = fg('purple_1a')
      colorW = fg('white')
      colorBl = fg('black')
      
      def typingPrint(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        
      def typingInput(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        value = input()  
        return value
      
      def br(times):
        for i in range(times):
          print()
  </py-script>
  <script src="main.js"></script>
</body>
2 Likes

Hmm, it still doesn’t seem to work.

1 Like

You will need to do &pip install colored and $pip install sys in your shell, like how you do in a regular Python Repl.

1 Like

@savardo it is telling me to update it since a new version is available. How would I do that?

1 Like

I believe it will still work for older versions, unless it hinders your code to stop working.

1 Like

@savardo I keep trying everything I can but it still isn’t working (it gives me a not found page)

here is my code,

<body>
  <py-env>
    - colored
    - sys
  </py-env>
  <py-script>
      import sys
      from colored import fg
    
      colorR = fg('red')
      colorO = fg('orange_4a')
      colorY = fg('yellow')
      colorG = fg('green')
      colorB = fg('blue')
      colorP = fg('purple_1a')
      colorW = fg('white')
      colorBl = fg('black')
      colorGr = fg('light_gray')
      
      def typingPrint(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        
      def typingInput(text):
        for character in text:
          sys.stdout.write(character)
          sys.stdout.flush()
          time.sleep(0.06)
        value = input()  
        return value
      
      def br(times):
        for i in range(times):
          print()
  </py-script>
  <script src="main.js"></script>
</body>
1 Like

Is your index.html in the same folder as you specified in extensions dev tools? Did you load your extension properly?

3 Likes

@dragonhunter1 Yes, and I don’t know. https://replit.com/@SalladShooter/Versatile-Text-Extension-1#output/index.html

1 Like

Add a tool that opens your index.html, and then click it in the toolbar.

1 Like

How would I do that?

2 Likes

https://docs.replit.com/extensions/devtools#tools
And then open it from the tools section on the bottom left of your workspace.

How would I do the glob pattern?

That is for the file handle, not a tool. A tool should not need a glob, but will need a url (in your case it should be "/")

Oh, I did the tool thing. Do I need a file handle?

2 Likes

Not unless you need it! (File handles let you open the extension from a file, providing the path to your extension)