diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/__pycache__/config.cpython-35.pyc b/__pycache__/config.cpython-35.pyc index 01bfb86..7967a00 100644 Binary files a/__pycache__/config.cpython-35.pyc and b/__pycache__/config.cpython-35.pyc differ diff --git a/__pycache__/note_reader.cpython-35.pyc b/__pycache__/note_reader.cpython-35.pyc index 97d978a..b6a6119 100644 Binary files a/__pycache__/note_reader.cpython-35.pyc and b/__pycache__/note_reader.cpython-35.pyc differ diff --git a/config.py b/config.py index 755a2d1..9e967e8 100644 --- a/config.py +++ b/config.py @@ -36,11 +36,13 @@ ICONS= {"GREEN": "green.png", "RED": "red.png"} MENU_OPTIONS = { "SINGLE": "Set Single Layout", "DOUBLE": "Set Double Layout", - "LOAD": "Load Notes" + "LOAD": "Load Notes", + "BIG": "Big Font", + "SMALL": "Small Font" } #Error messages -ERRORS = {"NOTES_EMPTY": ("Error", "Notes empty or can not be loaded!")} +ERRORS = {"NOTES_EMPTY": ("Error", "Notes empty or can't be loaded!")} #Max file size for notes MAX_FILE_SIZE = 1000000000 #1 Giga-Byte @@ -48,3 +50,15 @@ MAX_FILE_SIZE = 1000000000 #1 Giga-Byte #TO be added to title to alert user that timer is running RUNNING_ALERT = "RUNNING" +#Font for notes +FONT = {"NAME": "Arial", "SMALL": 12, "BIG": 16} + +#Color scheme +COLOR = {"TEXT": "black", "TEXT_BG": "ivory"} + +#Files tht should be displayed and opened a notes +TEXT_FILES = [ + ("Text Files", ("*.txt", "*.log", "*.asc", "*.conf", "*.cfg")), + ('All','*') + ] + diff --git a/main_window.py b/main_window.py index f6a7035..bc65969 100644 --- a/main_window.py +++ b/main_window.py @@ -1,5 +1,6 @@ import tkinter from tkinter import messagebox +from tkinter import font import socket import os @@ -14,7 +15,8 @@ runtime_info = { "icon_active": False, "active_split": -1, "notes": [], - "double_layout": False + "double_layout": False, + "big_font": False } root = tkinter.Tk() @@ -327,6 +329,25 @@ def set_title_notes(window, index, split_name = False): update_title(title, window) + +def menu_font_size(text_font, menu): + if runtime_info["big_font"]: + runtime_info["big_font"] = False + menu.entryconfig(1, label=config.MENU_OPTIONS["BIG"]) + else: + runtime_info["big_font"] = True + menu.entryconfig(1, label=config.MENU_OPTIONS["SMALL"]) + + update_font_size(text_font) + +def update_font_size(text_font): + if runtime_info["big_font"]: + font_size = config.FONT["BIG"] + else: + font_size = config.FONT["SMALL"] + + text_font.config(size=font_size) + def init_UI(root): """Draws default UI and creates event bindings.""" @@ -349,7 +370,8 @@ def init_UI(root): text1 = tkinter.Text( box1, yscrollcommand=scroll1.set, - wrap=tkinter.WORD + wrap=tkinter.WORD, + cursor="arrow" ) text1.insert(tkinter.END, config.DEFAULT_MSG) text1.config(state=tkinter.DISABLED) @@ -358,7 +380,8 @@ def init_UI(root): text2 = tkinter.Text( box2, yscrollcommand=scroll2.set, - wrap=tkinter.WORD + wrap=tkinter.WORD, + cursor="arrow" ) text2.insert(tkinter.END, config.DEFAULT_MSG) text2.config(state=tkinter.DISABLED) @@ -367,6 +390,16 @@ def init_UI(root): scroll1.config(command=text1.yview) scroll2.config(command=text2.yview) + #Set font and color for text + text_font = font.Font( + family=config.FONT["NAME"], + size=config.FONT["SMALL"] + ) + text1.config(font=text_font) + text2.config(font=text_font) + text1.config(fg=config.COLOR["TEXT"], bg=config.COLOR["TEXT_BG"]) + text2.config(fg=config.COLOR["TEXT"], bg=config.COLOR["TEXT_BG"]) + set_single_layout(root, box1, box2) #create popup menu @@ -377,6 +410,12 @@ def init_UI(root): lambda: menu_change_layout(root, box1, box2, popup) ) ) #Needs to be at index 0 + popup.add_command( + label=config.MENU_OPTIONS["BIG"], + command=( + lambda: menu_font_size(text_font, popup) + ) + ) #Needs to be at index 1 popup.add_command( label=config.MENU_OPTIONS["LOAD"], command=(lambda: menu_load_notes(root, text1, text2, com_socket)) diff --git a/note_reader.py b/note_reader.py index 8a57647..373e02c 100644 --- a/note_reader.py +++ b/note_reader.py @@ -114,7 +114,7 @@ def select_file(): Otherwise returns absolute path to selected file. """ - file = file_dia.askopenfilename() + file = file_dia.askopenfilename(filetypes=config.TEXT_FILES) if file: return file