Advertisement
robjones90

Untitled

Jun 30th, 2022
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.64 KB | None | 0 0
  1. import sys
  2. from tkinter import *
  3. from SC_interpreter import *
  4. import subprocess
  5. import os
  6.  
  7. root=Tk()
  8. root.title('MOD_Python Interpreter')
  9. canvas= Canvas(root, height= 700, width= 800)
  10. canvas.pack()
  11.  
  12.  
  13.  
  14. ## frame
  15. top_frame= Frame(root, bg='#80c1ff', bd=5)
  16. top_frame.place(relx=0.1, rely=0.01, relwidth=0.75, relheight=0.4, anchor='n')
  17.  
  18. background= PhotoImage(file='new402.png')
  19. background_label=Label(root, image=background)
  20. background_label.place(x=0, y=0, relwidth=1, relheight=1)
  21.  
  22. top_frame= Frame(root, bg='#80c1ff', bd=5)
  23. top_frame.place(relx=0.5, rely=0.01, relwidth=0.4, relheight=0.05, anchor='n')
  24. top_label= Label(top_frame, text="Welcome Engineer",font= 30)
  25. top_label.place(relwidth=1, relheight=1)
  26.  
  27. frame= Frame(root, bg='#80c1ff', bd=5)
  28. frame.place(relx=0.5, rely=0.08, relwidth=0.75, relheight=0.4, anchor='n')
  29. ##
  30.  
  31. ## textbox input
  32. text_int= Text(frame, font=("Arial", 13 ) )
  33. text_int.place(relx=0.03, rely= 0.05,  relheight=0.4, relwidth=0.65)
  34. ##
  35. text_out= Text(frame, font=("Arial", 13 ) )
  36. text_out.place(relx=0.03, rely= 0.6,  relheight=0.4, relwidth=0.65)
  37.  
  38.  
  39. ## save text
  40. def save_text():
  41.    text_file = open( 'test.txt', 'w')
  42.    text_file.write(text_int.get("1.0",'end-1c'))
  43.    text_file.close()
  44.  
  45. ##
  46.  
  47. ## ospopeopen
  48.  
  49. outputfile = os.popen("python SC_interpreter.py test.txt")
  50. output= outputfile.read()
  51. outputfile.close()
  52.  
  53.  
  54.  
  55. def my_clear():
  56.    text_int.delete(1.0, END)
  57.    input_label.pack_forget()
  58.  
  59.  
  60.  
  61. def my_get():
  62.    global input_label
  63.    global g_data
  64.    g_data= text_int.get("1.0",'end-1c')
  65.    f = open("temp.txt", "w+")
  66.    f.write(g_data)
  67.    f.close()
  68.    process = subprocess.Popen(['python3', 'SC_interpreter.py', 'temp.txt'], shell=False, stdout=subprocess.PIPE)
  69.    subprocess_return = process.stdout.read()
  70.    text_out.insert(END, subprocess_return)
  71.    man = "python" + 'SC_interpreter.py' + g_data
  72.  
  73.    input_label=Label(lower_label, text= output, bg='#80c1ff', bd=5, font=50)
  74.    input_label.pack()
  75.  
  76.  
  77. ## run
  78. button = Button(frame, text= "Run", command= my_get, font=15)
  79. button.place(relx=0.75, rely= 0.7,  relheight=0.1, relwidth=0.2)
  80. ##
  81.  
  82. ##save
  83. button_save = Button(frame, text= "Save", command= save_text, font=15)
  84. button_save.place(relx=0.75, rely= 0.2,  relheight=0.1, relwidth=0.2)
  85.  
  86. ## clear
  87. clear_button = Button(frame, text= "Clear", command=my_clear, font=15)
  88. clear_button.place(relx=0.75, rely= 0.45,  relheight=0.1, relwidth=0.2)
  89. ##
  90.  
  91. ##
  92. lower_frame= Frame(root, bg='#80c1ff', bd=5)
  93. lower_frame.place(relx=0.5, rely=0.5, relwidth=0.4, relheight=0.4, anchor='n')
  94. lower_label= Label(lower_frame, bg='#80c1ff', bd=5)
  95. lower_label.place(relwidth=1, relheight=1)
  96.  
  97.  
  98.  
  99.  
  100. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement