Advertisement
felaris

Untitled

Mar 30th, 2020
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. from guizero import App, TextBox, PushButton, Box, Combo, CheckBox, Slider,MenuBar
  2.  
  3. def open_file():
  4.     with open(file_name.value, "r") as f:
  5.                 editor.value = f.read()
  6.  
  7. def save_file():
  8.     with open(file_name.value, "w") as f:
  9.             f.write(editor.value)
  10.  
  11. def change_font():
  12.     editor.font = font.value
  13.    
  14. def change_color():
  15.     editor.font = font_color  
  16.  
  17. def change_text_size():
  18.     editor.text_size = size.value
  19.     editor.resize(1, 1)
  20.     editor.resize("fill", "fill")
  21. def highlight():
  22.     editor.bg = "light blue"
  23.  
  24. def lowlight():
  25.     editor.bg = None
  26. app = App(title="Felix's Notepad")
  27.  
  28. def file_function():
  29.     print("File option")
  30.  
  31. def edit_function():
  32.     print("Edit option")
  33. def exit_app():
  34.     app.destroy()
  35.  
  36.  
  37.  
  38. file_controls = Box(app, align="top", width="fill", border=True)
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. file_name = TextBox(file_controls, text="text_file.txt", width=50, align="left")
  46.  
  47.  
  48.  
  49. save_button = PushButton(file_controls, text="Save", command=save_file, align="right")
  50. open_button = PushButton(file_controls, text="Open", command=open_file, align="right")
  51. exit_button = PushButton(file_controls, text="Exit", command=exit_app, align="right")
  52.  
  53. editor = TextBox(app, multiline=True, height="fill", width="fill")
  54.  
  55.  
  56.  
  57. preferences_controls = Box(app, align="bottom", width="fill", border=True)
  58. font = Combo(preferences_controls, options=["courier", "times new roman", "verdana","calibri","algerian","arial","broadway","impact","ravie","rockwell","arial black","",""], align="left", command=change_font)
  59. size = Slider(preferences_controls,  align="left", start = 11, end = 150, command=change_text_size)
  60. font_color = Combo(preferences_controls,options=['pink','red','orange','green','black','yellow'],align='left',command=change_color)
  61. editor.when_mouse_enters = highlight
  62.    
  63.  
  64. editor.when_mouse_leaves = lowlight
  65.  
  66.  
  67. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement