10 examples of 'to set the dimension/size of tkinter window you will use' in Python

Every line of 'to set the dimension/size of tkinter window you will use' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
216def resize(self, width, height):
217 """
218 Resizes the widget.
219
220 :param int width:
221 The width of the widget.
222
223 :param int height:
224 The height of the widget.
225 """
226 self._width = width
227 self._height = height
228 if width != "fill":
229 self._set_tk_config("width", width)
230 if height != "fill":
231 self._set_tk_config("height", height)
232 if width == "fill" or height == "fill":
233 self.master.display_widgets()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

74def set_size(self, width, height):
75 self.SetSize((width, height))
86def set_canvas_size(
87 self, canvas_x=None, canvas_y=None,
88 resize_window=True, fullscreen=False
89 ):
90 """Change the logical canvas size and determine window/display sizes."""
91 if canvas_x is not None and canvas_y is not None:
92 self._canvas_logical = canvas_x, canvas_y
93 self._calculate_border_shift()
94 old_display_size = self._display_size
95 old_window_size = self._window_size
96 if resize_window or self._force_native_pixel:
97 # comply with requested size
98 if self._force_window_size:
99 self._window_size = self._force_window_size
100 else:
101 slack_ratio = _SLACK_RATIO if not fullscreen else 1.
102 if not self._force_native_pixel:
103 self._window_size = self._find_nonnative_window_size(slack_ratio)
104 else:
105 self._window_size = self._find_native_window_size(slack_ratio)
106 if fullscreen:
107 self._display_size = self._screen_size
108 else:
109 self._display_size = self._window_size
110 self._calculate_scale()
111 self._calculate_letterbox_shift()
112 return self._display_size != old_display_size or self._window_size != old_window_size
140def resize_canvas(event):
141 self.canvas.create_window(0, 0, anchor=NW, window=self.frame, width = int(event.width)-int(self.vscrollbar.config()['width'][4]))
839def _resize_canvas(self, event, canvas):
840 """Resize canvas to fit all contents"""
841 canvas.configure(scrollregion=canvas.bbox('all'))
107def on_configure(self, event):
108 logger.debug("MainFrame.on_configure")
109 if self.browser_frame:
110 width = event.width
111 height = event.height
112 if self.navigation_bar:
113 height = height - self.navigation_bar.winfo_height()
114 self.browser_frame.on_mainframe_configure(width, height)
714def _on_size(self, window, width, height):
715 self.size = (width, height)
716 self.aspect = float(width) / height
717 self.call('on_size', width, height)
8def __init__(
9 self,
10 master,
11 title="guizero",
12 width=500,
13 height=500,
14 layout="auto",
15 bg=None,
16 visible=True):
17
18 description = "[Window] oject"
19
20 self._modal = False
21 tk = Toplevel(master.tk)
22
23 super(Window, self).__init__(
24 master,
25 tk,
26 description,
27 title,
28 width,
29 height,
30 layout,
31 bg,
32 visible)
263def _DoSize(self, cx, cy, repaint=1):
264 # right-justify the textbox.
265 ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
266 l, t, r, b = win32gui.GetWindowRect(ctrl)
267 l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
268 r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
269 win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
270 # The button.
271 ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_OK)
272 l, t, r, b = win32gui.GetWindowRect(ctrl)
273 l, t = win32gui.ScreenToClient(self.hwnd, (l, t))
274 r, b = win32gui.ScreenToClient(self.hwnd, (r, b))
275 w = r - l
276 win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)
126def set_dimension(self, width=None, height=None, use_scroll_height=True):
127 """Helper function to set browser window dimensions"""
128 current_dimensions = self.driver.get_window_size()
129 if width is None:
130 width = current_dimensions['width']
131 if height is None:
132 height = (
133 current_dimensions['height']
134 if not use_scroll_height
135 else self.driver.execute_script("return document.body.scrollHeight")
136 )
137 self.driver.set_window_size(width, height)

Related snippets