Skip to content

Commit

Permalink
made code runnable on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
j4321 committed Apr 28, 2017
1 parent 3cfccc5 commit 029ef07
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tkColorPicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ def __init__(self, parent, **kwargs):
("focus",))
tk.Spinbox.__init__(self, self.frame, **kwargs)
tk.Spinbox.pack(self, padx=1, pady=1)
self.frame.spinbox = self

self.bind_class("ttkSpinbox", "<FocusIn>", self.focusin, True)
self.bind_class("ttkSpinbox", "<FocusOut>", self.focusout, True)

@staticmethod
def focusout(event):
w = event.widget.children["!spinbox"]
w = event.widget.spinbox
bc = w.style.lookup("TEntry", "bordercolor", ("!focus",))
dc = w.style.lookup("TEntry", "darkcolor", ("!focus",))
lc = w.style.lookup("TEntry", "lightcolor", ("!focus",))
Expand All @@ -112,7 +113,7 @@ def focusout(event):

@staticmethod
def focusin(event):
w = event.widget.children["!spinbox"]
w = event.widget.spinbox
w.old_value = w.get()
bc = w.style.lookup("TEntry", "bordercolor", ("focus",))
dc = w.style.lookup("TEntry", "darkcolor", ("focus",))
Expand Down Expand Up @@ -362,6 +363,7 @@ def __init__(self, parent=None, color=(255, 0, 0), title=_("Color Chooser")):
style = Style(self)
style.map("palette.TFrame", relief=[('focus', 'sunken')],
bordercolor=[('focus', "#4D4D4D")])
self.configure(background=style.lookup("TFrame", "background"))

if isinstance(color, str):
if re.match(r"^#[0-9A-F]{6}$", color):
Expand Down Expand Up @@ -714,6 +716,6 @@ def askcolor(color="red", parent=None, title=_("Color Chooser")):
if __name__ == "__main__":
root = tk.Tk()
s = Style(root)
s.theme_use('clam')
# s.theme_use('clam')
print(askcolor("sky blue", parent=root))
root.mainloop()
root.mainloop()

0 comments on commit 029ef07

Please sign in to comment.