Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tkcalendar/dateentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,22 @@ def drop_down(self):
date = self.parse_date(self.get())
x = self.winfo_rootx()
y = self.winfo_rooty() + self.winfo_height()

# Adjust position if calendar toplevel goes out of screen.
# The screen area occupied by the taskbar/dock
# is currently not taken into account.
xmin = 0
xmax = self.winfo_screenwidth()
ymax = self.winfo_screenheight()
width = self._top_cal.winfo_width()
height = self._top_cal.winfo_height()
if y+height >= ymax:
y = self.winfo_rooty()-height;
if x+width >= xmax:
x = xmax-width;
elif x < xmin:
x = xmin

if self.winfo_toplevel().attributes('-topmost'):
self._top_cal.attributes('-topmost', True)
else:
Expand Down