112 lines
5.5 KiB
Python
112 lines
5.5 KiB
Python
|
"""Ttk Frame with rounded corners.
|
||
|
|
||
|
Based on an example by Bryan Oakley, found at: http://wiki.tcl.tk/20152"""
|
||
|
import Tkinter
|
||
|
import ttk
|
||
|
|
||
|
root = Tkinter.Tk()
|
||
|
|
||
|
img1 = Tkinter.PhotoImage("frameFocusBorder", data="""
|
||
|
R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq
|
||
|
rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO
|
||
|
zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd
|
||
|
QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA
|
||
|
sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA
|
||
|
AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI
|
||
|
5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU
|
||
|
AAAAAAAApQAAsf8Brv8AlP8AQf8Afv8AzP8A1P8AQf8AfgAArAAABAAADAAA
|
||
|
AACQDADjAAASAAAAAACAAADVABZBAAB+ALjMwOIEhxINUAAAANIgAOYAAIEA
|
||
|
AHwAAGjSAGEEABYIAAAAAEoBB+MAAIEAAHwCACABAJsAAFAAAAAAAGjJAGGL
|
||
|
AAFBFgB+AGmIAAAQAABHAAB+APQoAOE/ABIAAAAAAADQAADjAAASAAAAAPiF
|
||
|
APcrABKDAAB8ABgAGO4AAJAAqXwAAHAAAAUAAJEAAHwAAP8AAP8AAP8AAP8A
|
||
|
AG0pIwW3AJGSAHx8AEocI/QAAICpAHwAAAA0SABk6xaDEgB8AAD//wD//wD/
|
||
|
/wD//2g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CbYKcyyEwGDBgQwa2tTlBBAhYIQMFejC5AgQAWJNDABK3y
|
||
|
loEDEjCgV6/aOcYBAwp4kIF6rVkXgAEc8IQZVifCBRQHGqya23HGIpsTBgSU
|
||
|
OsFX/PbrVVjpYsCABA4kQCxHu11ogAQUIOAwATpBLDFQFE9sccUYS0wAxD5h
|
||
|
4DACFEggbAHk3jVBA/gtTIHHEADg8sswxyzzzDQDAAEECGAQsgHiTisZResN
|
||
|
gLIHBijwLQEYePzx0kw37fTSSjuMr7ZMzfcgYZUZi58DGsTKwbdgayt22GSP
|
||
|
bXbYY3MggQIaONDzAJ8R9kFlQheQQAAOWGCAARrwdt23Bn8H7vfggBMueOEG
|
||
|
WOBBAAkU0EB9oBGUdXIFZJBABAEEsPjmmnfO+eeeh/55BBEk0Ph/E8Q9meQq
|
||
|
bbDABAN00EADFRRQ++2254777rr3jrvjFTTQwQCpz7u6QRut5/oEzA/g/PPQ
|
||
|
Ry/99NIz//oGrZpUUEAAOw==""")
|
||
|
|
||
|
img2 = Tkinter.PhotoImage("frameBorder", data="""
|
||
|
R0lGODlhQABAAPcAAHx+fMTCxKSipOTi5JSSlNTS1LSytPTy9IyKjMzKzKyq
|
||
|
rOzq7JyanNza3Ly6vPz6/ISChMTGxKSmpOTm5JSWlNTW1LS2tPT29IyOjMzO
|
||
|
zKyurOzu7JyenNze3Ly+vPz+/OkAKOUA5IEAEnwAAACuQACUAAFBAAB+AFYd
|
||
|
QAC0AABBAAB+AIjMAuEEABINAAAAAHMgAQAAAAAAAAAAAKjSxOIEJBIIpQAA
|
||
|
sRgBMO4AAJAAAHwCAHAAAAUAAJEAAHwAAP+eEP8CZ/8Aif8AAG0BDAUAAJEA
|
||
|
AHwAAIXYAOfxAIESAHwAAABAMQAbMBZGMAAAIEggJQMAIAAAAAAAfqgaXESI
|
||
|
5BdBEgB+AGgALGEAABYAAAAAAACsNwAEAAAMLwAAAH61MQBIAABCM8B+AAAU
|
||
|
AAAAAAAApQAAsf8Brv8AlP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wo9nL9I8evjWsdOX6D59
|
||
|
fPH71Xeef/kFyB93/sln4EP2Ebjegg31B5+CEDLUIH4PVqiQhOABqKFCF6qn
|
||
|
34cHcfjffCQaFOJtGaZYkIkUuljQigXK+CKCE3po40A0trgjjDru+EGPI/6I
|
||
|
Y4co7kikkAMBmaSNSzL5gZNSDjkghkXaaGIBHjwpY4gThJeljFt2WSWYMQpZ
|
||
|
5pguUnClehS4tuMEDARQgH8FBMBBBExGwIGdAxywXAUBKHCZkAIoEEAFp33W
|
||
|
QGl47ZgBAwZEwKigE1SQgAUCUDCXiwtQIIAFCTQwgaCrZeCABAzIleIGHDD/
|
||
|
oIAHGUznmXABGMABT4xpmBYBHGgAKGq1ZbppThgAG8EEAW61KwYMSOBAApdy
|
||
|
pNp/BkhAAQLcEqCTt+ACJW645I5rLrgEeOsTBtwiQIEElRZg61sTNBBethSw
|
||
|
CwEA/Pbr778ABywwABBAgAAG7xpAq6mGUUTdAPZ6YIACsRKAAbvtZqzxxhxn
|
||
|
jDG3ybbKFHf36ZVYpuE5oIGhHMTqcqswvyxzzDS/HDMHEiiggQMLDxCZXh8k
|
||
|
BnEBCQTggAUGGKCB0ktr0PTTTEfttNRQT22ABR4EkEABDXgnGUEn31ZABglE
|
||
|
EEAAWaeN9tpqt832221HEEECW6M3wc+Hga3SBgtMODBABw00UEEBgxdO+OGG
|
||
|
J4744oZzXUEDHQxwN7F5G7QRdXxPoPkAnHfu+eeghw665n1vIKhJBQUEADs=""")
|
||
|
|
||
|
style = ttk.Style()
|
||
|
|
||
|
style.element_create("RoundedFrame", "image", "frameBorder",
|
||
|
("focus", "frameFocusBorder"), border=16, sticky="nsew")
|
||
|
|
||
|
style.layout("RoundedFrame", [("RoundedFrame", {"sticky": "nsew"})])
|
||
|
style.configure("TEntry", borderwidth=0)
|
||
|
|
||
|
frame = ttk.Frame(style="RoundedFrame", padding=10)
|
||
|
frame.pack(fill='x')
|
||
|
|
||
|
frame2 = ttk.Frame(style="RoundedFrame", padding=10)
|
||
|
frame2.pack(fill='both', expand=1)
|
||
|
|
||
|
entry = ttk.Entry(frame, text='Test')
|
||
|
entry.pack(fill='x')
|
||
|
entry.bind("<FocusIn>", lambda evt: frame.state(["focus"]))
|
||
|
entry.bind("<FocusOut>", lambda evt: frame.state(["!focus"]))
|
||
|
|
||
|
text = Tkinter.Text(frame2, borderwidth=0, bg="white", highlightthickness=0)
|
||
|
text.pack(fill='both', expand=1)
|
||
|
text.bind("<FocusIn>", lambda evt: frame2.state(["focus"]))
|
||
|
text.bind("<FocusOut>", lambda evt: frame2.state(["!focus"]))
|
||
|
|
||
|
root.mainloop()
|