Get the current location of the window's top left corner. Sometimes, depending on the environment, the value returned does not include the titlebar,etc A new option, more_accurate, can be used to get the theoretical upper leftmost corner of the window. The titlebar a
(self, more_accurate=False, without_titlebar=False)
| 11815 | warnings.warn('Problem in Window.keep_on_top_clear trying to clear wm_attributes topmost' + str(e), UserWarning) |
| 11816 | |
| 11817 | def current_location(self, more_accurate=False, without_titlebar=False): |
| 11818 | """ |
| 11819 | Get the current location of the window's top left corner. |
| 11820 | Sometimes, depending on the environment, the value returned does not include the titlebar,etc |
| 11821 | A new option, more_accurate, can be used to get the theoretical upper leftmost corner of the window. |
| 11822 | The titlebar and menubar are crated by the OS. It gets really confusing when running in a webpage (repl, trinket) |
| 11823 | Thus, the values can appear top be "off" due to the sometimes unpredictable way the location is calculated. |
| 11824 | If without_titlebar is set then the location of the root x,y is used which should not include the titlebar but |
| 11825 | may be OS dependent. |
| 11826 | |
| 11827 | :param more_accurate: If True, will use the window's geometry to get the topmost location with titlebar, menubar taken into account |
| 11828 | :type more_accurate: (bool) |
| 11829 | :param without_titlebar: If True, return location of top left of main window area without the titlebar (may be OS dependent?) |
| 11830 | :type without_titlebar: (bool) |
| 11831 | :return: The x and y location in tuple form (x,y) |
| 11832 | :rtype: Tuple[int, int] | Tuple[None, None] |
| 11833 | """ |
| 11834 | |
| 11835 | if not self._is_window_created('tried Window.current_location'): |
| 11836 | return (None, None) |
| 11837 | try: |
| 11838 | if without_titlebar is True: |
| 11839 | x, y = self.TKroot.winfo_rootx(), self.TKroot.winfo_rooty() |
| 11840 | elif more_accurate: |
| 11841 | geometry = self.TKroot.geometry() |
| 11842 | location = geometry[geometry.find('+') + 1:].split('+') |
| 11843 | x, y = int(location[0]), int(location[1]) |
| 11844 | else: |
| 11845 | x, y = int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y()) |
| 11846 | except Exception as e: |
| 11847 | warnings.warn('Error in Window.current_location. Trouble getting x,y location\n' + str(e), UserWarning) |
| 11848 | x, y = (None, None) |
| 11849 | return (x,y) |
| 11850 | |
| 11851 | def current_size_accurate(self): |
| 11852 | """ |
no test coverage detected