Skip to content

Commit

Permalink
set focus
Browse files Browse the repository at this point in the history
  • Loading branch information
promto-c committed Aug 18, 2023
1 parent 95ae7e2 commit 2619cc6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions player.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from typing import Callable

from PyQt5 import QtCore, QtGui, QtWidgets, uic

Expand Down Expand Up @@ -81,6 +82,10 @@ def _setup_ui(self):

self.center_layout.addWidget(self.viewer)

# Set the focus policy to accept focus, and set the initial focus
self.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus)
self.setFocus()

def _setup_signal_connections(self):

self.playback_speed_combo_box.currentTextChanged.connect(self.set_playback_speed)
Expand All @@ -99,6 +104,12 @@ def _setup_signal_connections(self):
self.current_frame_spin_box.valueChanged.connect(self.set_frame)
self.frame_slider.valueChanged.connect(self.set_frame)

def key_bind(self, key_sequence: str, function: Callable):
# Create a shortcut
shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(key_sequence), self)
# Connect the activated signal of the shortcut to the slot
shortcut.activated.connect(function)

def set_playback_speed(self, playback_fps: float = 48.0):
playback_fps = float(playback_fps)

Expand Down

0 comments on commit 2619cc6

Please sign in to comment.