def add_label(self, instance):
# lines.insert(39, 'Text\n')
#
#
#
layout = BoxLayout(orientation="vertical")
textinput_name = TextInput(text='name', background_normal='man3.png', font_size='12sp')
textinput_posX = TextInput(text='pos X', background_normal='man3.png', font_size='12sp')
textinput_posY = TextInput(text='pos Y', background_normal='man3.png', font_size='12sp')
object_settings_lbl = Label(text="Object type: Label", font_size='12sp')
object_name_lbl = Label(text="object name:", font_size='12sp')
object_pos_lbl = Label(text="position:", font_size='12sp')
object_size_lbl = Label(text="size:", font_size='12sp')
object_text_lbl = Label(text="text:", font_size='12sp')
textinput_width = TextInput(text='width', background_normal='man3.png', font_size='12sp')
textinput_height = TextInput(text='height', background_normal='man3.png', font_size='12sp')
textinput_text = TextInput(text='text', background_normal='man3.png', font_size='12sp')
lbl_font_size = Label(text="font size:", font_size='12sp')
textinput_font_size = TextInput(text='15sp', background_normal='man3.png', font_size='12sp')
button = Button(text='Create & close')
layout.add_widget(object_settings_lbl)
layout.add_widget(object_name_lbl)
layout.add_widget(textinput_name)
layout.add_widget(object_pos_lbl)
layout.add_widget(textinput_posX)
layout.add_widget(textinput_posY)
layout.add_widget(object_size_lbl)
layout.add_widget(textinput_width)
layout.add_widget(textinput_height)
layout.add_widget(object_text_lbl)
layout.add_widget(textinput_text)
layout.add_widget(lbl_font_size)
layout.add_widget(textinput_font_size)
layout.add_widget(button)
popup = Popup(title='New Label Property', content=layout, size_hint=(None, None), size=(700, 600))
button.bind(on_press=popup.dismiss)
popup.open()
################################################
global FILE_NAME
inp = askopenfile(mode="r", title="add Label")
if inp is None:
return
FILE_NAME = inp.name
print(FILE_NAME)
print(inp)
with open(FILE_NAME, 'rt', encoding='utf-8') as src:
data = src.read()
with open(FILE_NAME, 'wt', encoding='utf-8') as dest:
dest.write(data.replace('# CODE', '# Label\n '+textinput_name.text+"=Label(text ="+"'"+textinput_text.text+"'"+", font_size="+textinput_font_size.text+", size_hint =("+textinput_width.text+","+textinput_height.text+"), pos_hint = {'center_x': "+textinput_posX.text+", 'center_y':"+textinput_posY.text+"})\n main_layout.add_widget("+textinput_name.text+")\n# CODE\n"))