Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from guizero import App, TextBox, PushButton, Box, Combo, CheckBox, Slider
- def open_file():
- with open(file_name.value, "r") as f:
- editor.value = f.read()
- def save_file():
- with open(file_name.value, "w") as f:
- f.write(editor.value)
- def change_font():
- editor.font = font.value
- def change_text_size():
- editor.text_size = size.value
- editor.resize(1, 1)
- editor.resize("fill", "fill")
- def change_colour():
- editor.text_color = colour.value
- app = App(title="textzero")
- file_controls = Box(app, align="top", width="fill", border=True)
- file_name = TextBox(file_controls, text="hello_world.txt", width=50, align="left")
- save_button = PushButton(file_controls, text="Save", command=save_file, align="right")
- open_button = PushButton(file_controls, text="Open", command=open_file, align="right")
- preferences_controls = Box(app, align="left", border=True, layout="auto")
- font = Combo(preferences_controls, options=["courier", "times new roman", "verdana"], command=change_font)
- colour = Combo(preferences_controls, options=["black","red", "blue", "green"], command=change_colour)
- size = Slider(preferences_controls, align="left", start = 8, end = 42, command=change_text_size)
- editor = TextBox(app, multiline=True, height="fill", width="fill")
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement