Python tkinter.Event() Examples
The following are 30
code examples of tkinter.Event().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: window.py From moderngl-window with MIT License | 6 votes |
def tk_resize(self, event) -> None: """tkinter specific window resize event. Forwards resize events to the configured resize function. Args: event (tkinter.Event): The resize event """ self._width, self._height = event.width, event.height # TODO: How do we know the actual buffer size? self._buffer_width, self._buffer_height = event.width, event.height # Race condition when going fullscreen mode. # The moderngl context might not be created yet. if not self._ctx: return self.set_default_viewport() self._resize_func(event.width, event.height)
Example #2
Source File: app.py From QM-Simulator-1D with MIT License | 6 votes |
def update_wavefunction_by_sketch_while_paused( self, event: tk.Event) -> None: """ Update the wavefunction with the mouse, while pausing the time evolution. """ x, y = self.locate_mouse(event) # Set the animation speed # Later versions of Tkinter have full support for event.type. # This is not the case in older versions of Tkinter, # but there is something similar called event.num. Therefore we use # both event.type and event.num. if (str(event.type) == "Motion" or event.num != 1) and ( self.fpi_before_pause is None): self.fpi_before_pause = self.fpi self.fpi = 0 elif (str(event.type) == "ButtonRelease" or event.num == 1) and ( self.fpi_before_pause is not None): self.fpi = self.fpi_before_pause self.fpi_before_pause = None self._update_wavefunction_by_sketch(x, y) self.update_expected_energy_level()
Example #3
Source File: app.py From QM-Simulator-1D with MIT License | 6 votes |
def update_wavefunction_to_eigenstate(self, event: tk.Event) -> None: """ Update the wavefunction to an eigenstate. """ x, y = self.locate_mouse(event) if not self.potential_is_reshaped: if np.amax(self.V_x > 0): self.scale_y = np.amax(self.V_x[1:-2])/( self.bounds[-1]*0.95) elif np.amax(self.V_x < 0): self.scale_y = np.abs(np.amin(self.V_x[1:-2]))/( self.bounds[-1]*0.95) else: self.scale_y = 1.0 energy = y*self.scale_y*self.U_t._scale self.set_to_eigenstate(energy, self.scale_y) self.update_expected_energy_level()
Example #4
Source File: app.py From QM-Simulator-1D with MIT License | 6 votes |
def update_potential_by_slider(self, *event: tk.Event) -> None: """ Update the potential by sliders. """ if not self.potential_is_reshaped: if np.amax(self.V_x > 0): self.scale_y = np.amax(self.V_x[1:-2])/( self.bounds[-1]*0.95) elif np.amax(self.V_x < 0): self.scale_y = np.abs(np.amin(self.V_x[1:-2]))/( self.bounds[-1]*0.95) else: self.scale_y = 1.0 self.potential_is_reshaped = True params = [] for i in range(len(self.sliders2)): params.append(self.sliders2[i].get()) self.V = lambda x: self.V_base(x, *params) self.V_x = scale(self.V(self.x), 15) self.U_t = UnitaryOperator1D(self.V) # Re-draw the potential self.lines[4].set_ydata(self.V_x/self.scale_y) self.update_energy_levels()
Example #5
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def rightclick_toggle_energylevel(self, *event: tk.Event) -> None: """ This function is called if toggle energy level has been selected from right click. """ if self.show_energy_levels(): self.mouse_menu_string.set("Reshape Wavefunction") self.toggle_energy_levels()
Example #6
Source File: view.py From inbac with MIT License | 5 votes |
def enable_selection_mode(self, event: Event = None): self.controller.model.enabled_selection_mode = True
Example #7
Source File: window.py From moderngl-window with MIT License | 5 votes |
def tkResize(self, event): """Should never be called. Event overridden.""" raise ValueError("tkResize should never be called. The event is overridden.")
Example #8
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def update_wavefunction_by_slider(self, *event: tk.Event) -> None: """ Update the wavefunction by sliders. """ params = [self.sliders1[i].get() for i in range(len(self.sliders1))] psi_func = lambda x: self.psi_base(x, *params) self.psi = Wavefunction1D(psi_func) self.psi.normalize() self.update_expected_energy_level()
Example #9
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def mouse_wheel_handler(self, event: tk.Event) -> None: """ Handle mouse wheel input. When the mouse is over the canvas this controls how the drawing of the potential is scaled. """ if event.delta == -120 or event.num == 5: self.rescale_potential_graph(1.1) elif event.delta == 120 or event.num == 4: self.rescale_potential_graph(0.9)
Example #10
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def popup_menu(self, event: tk.Event) -> None: """ popup menu upon right click. """ self.menu.tk_popup(event.x_root, event.y_root, 0)
Example #11
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def rightclick_reshape_potential(self, *event: tk.Event) -> None: """ This function is called if reshape wavefunction has been set. """ self.mouse_menu_string.set(self.mouse_menu_tuple[3]) if self.show_energy_levels(): self.toggle_energy_levels()
Example #12
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def rightclick_select_energylevel(self, *event: tk.Event) -> None: """ This function is called if the option select energy level has been selected from right click. """ if not self.show_energy_levels(): self.mouse_menu_string.set(self.mouse_menu_tuple[2]) self.toggle_energy_levels() elif self.show_energy_levels(): self.mouse_menu_string.set(self.mouse_menu_tuple[2])
Example #13
Source File: window.py From moderngl-window with MIT License | 5 votes |
def _handle_modifiers(self, event: tkinter.Event, press: bool) -> None: """Update internal key modifiers Args: event (tkinter.Event): The key event press (bool): Press or release event """ if event.keysym in ['Shift_L', 'Shift_R']: self._modifiers.shift = press elif event.keysym in ['Control_L', 'Control_R']: self._modifiers.ctrl = press elif event.keysym in ['Alt_L', 'Alt_R']: self._modifiers.alt = press
Example #14
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def mouse_menu_handler(self, *event: tk.Event) -> None: """ Mouse menu handler. """ if (str(self.mouse_menu_string.get()) == self.mouse_menu_tuple[2] and not self.show_energy_levels()): self.toggle_energy_levels() elif self.show_energy_levels() and ( str(self.mouse_menu_string.get()) != self.mouse_menu_tuple[2]): self.toggle_energy_levels()
Example #15
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def sketch(self, event: tk.Event) -> None: """ Respond to mouse interaction on the canvas. """ if str(self.mouse_menu_string.get()) == self.mouse_menu_tuple[0]: self.update_wavefunction_by_sketch_while_paused(event) elif str(self.mouse_menu_string.get()) == self.mouse_menu_tuple[1]: self.update_wavefunction_by_sketch(event) elif str(self.mouse_menu_string.get()) == self.mouse_menu_tuple[2]: self.update_wavefunction_to_eigenstate(event) elif str(self.mouse_menu_string.get()) == self.mouse_menu_tuple[3]: self.update_potential_by_sketch(event)
Example #16
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def update_wavefunction_by_name(self, *event: tk.Event) -> None: """ Update the wavefunction given entry input. """ self.set_wavefunction(self.enter_function.get()) self.update_expected_energy_level() self.set_widgets_after_enter_wavefunction()
Example #17
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def clear_wavefunction(self, *args: tk.Event) -> None: """ Set the wavefunction to zero. """ self.set_wavefunction("0") self.update_expected_energy_level()
Example #18
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def update_potential_by_name(self, *event: tk.Event) -> None: """ Update the potential using the potential entry input. """ self.potential_is_reshaped = False self.potential_menu_string.set("Choose Preset Potential V(x)") self.previous_potential_menu_string = "Choose Preset Potential V(x)" no_prev_param_sliders = True if len(self.V_params) == 0 else False self.set_unitary(self.enter_potential.get()) self.update_energy_levels() if not no_prev_param_sliders or len(self.V_params) > 0: self.set_widgets_after_enter_potential()
Example #19
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def change_animation_speed(self, event: tk.Event) -> None: """ Change the animation speed. """ self.fpi = self.slider_speed.get()
Example #20
Source File: app.py From QM-Simulator-1D with MIT License | 5 votes |
def quit(self, *event: tk.Event) -> None: """ Quit the application. Simply calling self.window.quit() only quits the application in the command line, while the GUI itself still runs. On the other hand, simply calling self.window.destroy() destroys the GUI but doesn't give back control of the command line. Therefore both need to be called. """ self.window.quit() self.window.destroy()
Example #21
Source File: plistwindow.py From ProperTree with BSD 3-Clause "New" or "Revised" License | 5 votes |
def next_field(self, event): # We need to determine if our other field can be edited # and if so - trigger another double click event there edit_col = None if self.column == "#0": check_type = self.master.get_check_type(self.cell).lower() # We are currently in the key column if check_type in ["array","dictionary"]: # Can't edit the other field with these - bail return 'break' edit_col = "#2" elif self.column == "#2": # It's the value column - let's see if we can edit the key parent = self.master._tree.parent(self.cell) check_type = "dictionary" if not len(parent) else self.master.get_check_type(parent).lower() if check_type == "array" or self.cell == self.master.get_root_node(): # Can't edit array keys - as they're just indexes return 'break' edit_col = "#0" if edit_col: # Let's get the bounding box for our other field x,y,width,height = self.master._tree.bbox(self.cell, edit_col) # Create an event e = tk.Event e.x = x+5 e.y = y+5 e.x_root = 0 e.y_root = 0 self.master.on_double_click(e) return 'break'
Example #22
Source File: view.py From inbac with MIT License | 5 votes |
def disable_selection_mode(self, event: Event = None): self.controller.model.enabled_selection_mode = False
Example #23
Source File: view.py From inbac with MIT License | 5 votes |
def on_mouse_down(self, event: Event): self.controller.start_selection((event.x, event.y))
Example #24
Source File: view.py From inbac with MIT License | 5 votes |
def on_mouse_drag(self, event: Event): self.controller.move_selection((event.x, event.y))
Example #25
Source File: view.py From inbac with MIT License | 5 votes |
def on_mouse_up(self, event: Event): self.controller.stop_selection()
Example #26
Source File: view.py From inbac with MIT License | 5 votes |
def previous_image(self, event: Event = None): self.controller.previous_image()
Example #27
Source File: view.py From inbac with MIT License | 5 votes |
def on_resize(self, event: Event = None): self.controller.display_image_on_canvas( self.controller.model.current_image)
Example #28
Source File: view.py From inbac with MIT License | 5 votes |
def save_next(self, event: Event = None): self.controller.save_next()
Example #29
Source File: view.py From inbac with MIT License | 5 votes |
def save(self, event: Event = None): self.controller.save()
Example #30
Source File: view.py From inbac with MIT License | 5 votes |
def rotate_image(self, event: Event = None): self.controller.rotate_image()