Skip to content

Commit

Permalink
at least can use? now
Browse files Browse the repository at this point in the history
  • Loading branch information
littlewhitecloud committed Aug 11, 2023
1 parent 839b5da commit 1ff1f5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 2 additions & 3 deletions notepad/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ def __init__(self) -> None:
self.geometry("1275x665")
self.iconbitmap("notepad.ico")

self.theme = (
"dark" if isDark() else "light"
) # TODO: move it to the settings later
self.theme = "dark" if isDark() else "light"
# TODO: move it to the settings later

set_theme(self.theme)
if self.theme == "dark":
Expand Down
22 changes: 15 additions & 7 deletions notepad/widgets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tkinter import Button, Event, Frame, Misc, Text
from tkinter import Event, Frame, Misc, Text
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import showerror
from tkinter.ttk import Label, Scrollbar, Separator
from tkinter.ttk import Label, Scrollbar, Separator, Button, Style

from darkdetect import isDark

Expand All @@ -24,13 +24,19 @@ def __init__(
) -> None:
super().__init__(master, background=background)

self.style = Style()
self.style.configure(
"Menu.TButton",
background=self.master.backgroundcolor,
)

self.filebutton = Button(self, text="File")
self.editbutton = Button(self, text="Edit")
self.viewbutton = Button(self, text="View")

for target_button in (self.filebutton, self.editbutton, self.viewbutton):
target_button.pack(fill="x", side="left", padx=5, pady=2)
target_button.config(background=self.master.backgroundcolor, relief="flat")
target_button.config(style="Menu.TButton")


class Editor(Frame):
Expand All @@ -44,12 +50,13 @@ def __init__(self, master: Misc | None = None) -> None:
self.changed = False
self.filepath = ""

self.backgroundcolor = "#020202" if isDark() else "#F8F8F8"
self.backgroundcolor = "#020202" if isDark() else "#FAFAFA"
self.foregroundcolor = "#CCCCCC" if isDark() else "#595959"
self.themecolor = "#2A2A2A" if isDark() else "white"

# Create the widgets
self.editmenu = EditMenubar(self, background=self.backgroundcolor)
self.editmenu.pack(side="top", fill="x")
# self.editmenu = EditMenubar(self, background=self.backgroundcolor)
# self.editmenu.pack(side="top", fill="x")

self.edit = Frame(self)
self.text = Text(
Expand Down Expand Up @@ -115,7 +122,8 @@ def update(self, event: Event) -> None:
"""update the statusbar"""
self.ln, self.col = self.text.index("insert").split(".")
self.insertindex.config(text="Ln %s, Col %s" % (self.ln, int(self.col) + 1))
self.changed = True
if event:
self.changed = True

def savefile(self, event: Event | None = None, filepath: str = "") -> None:
"""Save file to target filepath"""
Expand Down

0 comments on commit 1ff1f5a

Please sign in to comment.