当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.Event方法代码示例

本文整理汇总了Python中tkinter.Event方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Event方法的具体用法?Python tkinter.Event怎么用?Python tkinter.Event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter的用法示例。


在下文中一共展示了tkinter.Event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tk_resize

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
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) 
开发者ID:moderngl,项目名称:moderngl-window,代码行数:20,代码来源:window.py

示例2: update_potential_by_slider

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
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() 
开发者ID:marl0ny,项目名称:QM-Simulator-1D,代码行数:25,代码来源:app.py

示例3: update_wavefunction_to_eigenstate

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
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() 
开发者ID:marl0ny,项目名称:QM-Simulator-1D,代码行数:19,代码来源:app.py

示例4: update_wavefunction_by_sketch_while_paused

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
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() 
开发者ID:marl0ny,项目名称:QM-Simulator-1D,代码行数:26,代码来源:app.py

示例5: enable_selection_mode

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def enable_selection_mode(self, event: Event = None):
        self.controller.model.enabled_selection_mode = True 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例6: disable_selection_mode

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def disable_selection_mode(self, event: Event = None):
        self.controller.model.enabled_selection_mode = False 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例7: on_mouse_down

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def on_mouse_down(self, event: Event):
        self.controller.start_selection((event.x, event.y)) 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例8: on_mouse_drag

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def on_mouse_drag(self, event: Event):
        self.controller.move_selection((event.x, event.y)) 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例9: on_mouse_up

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def on_mouse_up(self, event: Event):
        self.controller.stop_selection() 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例10: previous_image

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def previous_image(self, event: Event = None):
        self.controller.previous_image() 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例11: on_resize

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def on_resize(self, event: Event = None):
        self.controller.display_image_on_canvas(
            self.controller.model.current_image) 
开发者ID:weclaw1,项目名称:inbac,代码行数:5,代码来源:view.py

示例12: save_next

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def save_next(self, event: Event = None):
        self.controller.save_next() 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例13: save

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def save(self, event: Event = None):
        self.controller.save() 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例14: rotate_image

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
def rotate_image(self, event: Event = None):
        self.controller.rotate_image() 
开发者ID:weclaw1,项目名称:inbac,代码行数:4,代码来源:view.py

示例15: next_field

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Event [as 别名]
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' 
开发者ID:corpnewt,项目名称:ProperTree,代码行数:32,代码来源:plistwindow.py


注:本文中的tkinter.Event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。