move() method in PyQt5
Last Updated :
26 Mar, 2020
In order to move (changing the position) any widget like buttons or label move()
method is used in PyQt5 application. By default, all the widgets are on top left corner therefore, there is a need of changing the position of the widgets.
Syntax : move( x, y )
Arguments : It takes two arguments :
1. X co-ordinate
2. Y co-ordinate
Below is the implementation of this method.
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Move" )
self .setGeometry( 0 , 0 , 400 , 300 )
self .widget = QLabel( 'Moved' , self )
self .widget.move( 50 , 50 )
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...