當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。