화면의 아무 곳에 나 창을 배치하는 메서드가 포함 된 클래스를 만들었습니다. GUI 프로그래밍을 위해 PyQt4를 사용하고 있습니다. 다음과 같은 수업을 썼습니다 :클래스에 매개 변수로 창 이름 전달
from PyQt4 import QtGui
class setWindowPosition:
def __init__(self, xCoord, yCoord, windowName, parent = None):
self.x = xCoord
self.y = yCoord
self.wName = windowName;
def AdjustWindow(self):
screen = QtGui.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
이 코드는 수정해야합니다. 이 클래스를 가져 오는 모든 파일은 desired_X_Position
, desired_Y_position
및이 클래스의 고유 한 이름의 세 가지 매개 변수를 전달합니다. AdjustWindow
메서드는이 세 개의 매개 변수를 받아 호출 창을 원하는 좌표에 배치해야합니다.
위 코드에서 매개 변수를 전달했지만 AdjustWindow
메서드를 수정하는 방법을 따르지는 않습니다.
들여 쓰기가 깨졌습니다. –