from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.animation import Animation
from kivy.clock import Clock
from kivy.config import Config
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.core import audio
from kivy.core.audio import SoundLoader
#import socket
#sock = socket.socket()
#sock.bind(('', 9090))
#sock.listen(1)
Config.set('graphics', 'resizable', '0')
Config.set('graphics', 'width', '1280')
Config.set('graphics', 'height', '720')
class MainApp(App):
def build(self):
main_layout = FloatLayout()
return main_layout
if __name__ == '__main__':
app = MainApp()
app.run()
def build(self):
main_layout = FloatLayout()
#тут
your_new_code="""
print(123)
return False
"""
...
updated_text = """
...
class MainApp(App):
def build(self):
main_layout = FloatLayout()
{some_text}
...
""".format(some_text=your_new_code)
class MainApp(App):
def build(self):
main_layout = FloatLayout()
# INSERT CODE HERE
return main_layout
if __name__ == '__main__':
app = MainApp()
app.run()
with open('file.py', 'rt', encoding='utf-8') as src:
data = src.read()
with open('file2.py', 'wt', encoding='utf-8') as dest:
dest.write(data.replace('# INSERT CODE HERE', 'тут твой код'))