bruh_nye

python notepad clone

Jun 29th, 2020
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. #~~~~imports~~~~
  2. import PySimpleGUI as sg
  3.  
  4. import pathlib
  5.  
  6. WIN_W = 90
  7. WIN_H = 25
  8.  
  9. '''
  10. sg.ChangeLookAndFeel('SystemDefault')
  11. '''
  12. #~~~~layout~~~~
  13. #/settings
  14. menu_def = [['File', ['New    Ctrl+N', 'Open...    Ctrl+O', 'Save    Ctrl+S','Save As...', '---', 'Page Setup...', 'Print...    Ctrl+P', '---', 'Exit'  ]],      
  15.                 ['Edit', ['Undo    Ctrl+Z', '---', 'cut    Ctrl+X', 'copy    Ctrl+C', 'Paste    Ctrl+V', 'delete    Del', '---', 'find...    Ctrl+F', 'Find Next    F3', 'Replace...    Ctrl+H', 'Go To...    Ctrl+G', '---', 'Select All    Ctrl+A', 'Time/Date    F5'], ],
  16.                 ['format', ['Word Wrap', 'font...'], ],
  17.                 ['view', ['Status Bar'], ],      
  18.                 ['Help', ['View Help', '---', 'About memopad'], ], ]
  19.  
  20. Ln_numb = 1
  21. Col_numb = 1
  22. #/the layout
  23. layout = [[sg.Menu(menu_def)],
  24.           [sg.Multiline(font=('Consolas', 12), size=(WIN_W, WIN_H-1), key='_BODY_')],
  25.           [sg.StatusBar( text=f'| Ln{Ln_numb},Col{Col_numb}', size=(WIN_W,1), pad=(0,0), text_color='black', background_color='white', relief=sg.RELIEF_FLAT, justification='right', visible=False, key='status_bar' )]
  26.           ]
  27.  
  28. #/window
  29. window = sg.Window('untitled - notepad', icon=['D:/python/memopad/Notepad.ICO'], border_depth=0, layout=layout, element_padding=(0, 0), margins=(0, 0), resizable=True, return_keyboard_events=True, finalize=True)
  30. window['_BODY_'].expand(expand_x=True, expand_y=True)
  31. window['status_bar'].expand(expand_x=True, expand_y=True)
  32. window['status_bar'].update(visible=False)
  33. #~~~~event loop~~~~
  34. status_bar_switch = True
  35. while True:
  36.     event, values = window.read()
  37.     if event in (None, 'Exit'):
  38.         break
  39.  
  40.     if event in ('Status Bar'):
  41.         if status_bar_switch:
  42.             window['status_bar'].update(visible=True)
  43.             status_bar_switch = False
  44.         else:
  45.             window['status_bar'].update(visible=False)
  46.             status_bar_switch = True
Add Comment
Please, Sign In to add comment