Python Forum
i want to write symbole as varibales in python to make translator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i want to write symbole as varibales in python to make translator
#7
(Feb-01-2021, 08:22 PM)deanhystad Wrote: Let's make sure I understand.

You have a game. It takes input. The input has to have a certain format. You cannot change the game to accept a different format.

You have a website that provides input for your game. The information from the website is not in the correct format for your game.

You want a translator that will take the output from the website and convert it to a format that can be input to the game.

Is that correct?

If that is correct, I would write a really small GUI application (using tkinter for example). There would be a control for pasting text from the website, a function that translates the text, and a control that displays the translated text so it could be copied and pasted into your game.
import tkinter as tk

translation = {'[':'(', ']':')', ';':','}

def translate(*args):
    outstr.set(''.join([translation.get(c, c) for c in inpstr.get()]))
    
root = tk.Tk()
inpstr = tk.StringVar()
outstr = tk.StringVar()

inpstr.trace('w', translate)

tk.Label(root, text='From Website:').pack(padx=5, pady=5)
tk.Entry(root, textvariable=inpstr, width=20).pack(padx=5, pady=5)

tk.Label(root, text='To Game:').pack(padx=5, pady=5)
tk.Entry(root, textvariable=outstr, width=20).pack(padx=5, pady=5)

tk.mainloop()

yes you understood my idea ^^ and that is what i want exactlly. thank you soo much bro i apreciate your help and your time
thank you ^^
Reply


Messages In This Thread
RE: i want to write symbole as varibales in python to make translator - by rachidel07 - Feb-01-2021, 09:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 7 1,680 Sep-12-2022, 02:55 AM
Last Post: AlexPython
  letter translator (or someting) Obsilion 4 2,548 Apr-28-2020, 12:40 PM
Last Post: deanhystad
  I want to filter out words with one letter in a string (pig latin translator) po0te 1 2,154 Jan-08-2020, 08:02 AM
Last Post: perfringo
  Trouble with Regex Translator skrivver99 3 2,853 Dec-15-2018, 03:55 PM
Last Post: Gribouillis
  Output discrepancy when building Translator skrivver99 17 6,807 Nov-26-2018, 01:22 AM
Last Post: ichabod801
  Help with pig latin translator DragonG 1 2,314 Nov-01-2018, 03:57 AM
Last Post: ichabod801
  PigLatin Sentence Translator Help 2skywalkers 7 5,937 Jun-23-2018, 12:46 AM
Last Post: 2skywalkers
  Pig Latin Translator RickyWilson 1 3,224 Dec-02-2017, 08:20 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020