PyQt5 QSpinBox – Checking if it is visible using isVisible
Last Updated :
17 May, 2020
In this article we will see how we can check if the spin box visible with the help of isVisible
method. We can hide the spin box using hide
method or setHidden
method. By default spin box is visible.
Note : If we use this method inside the window class it will return false as the window is created at that time and it didn’t know if it is visible or not therefore it is used outside the class
In order to do so we use isVisible
method.
Syntax : classs_object.spin_box.isVisible()
Argument : It takes no argument
Return : It returns bool
Below is the implementation
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 600 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
self .spin = QSpinBox( self )
self .spin.setGeometry( 100 , 100 , 250 , 40 )
self .spin.setPrefix( "Prefix " )
self .spin.setSuffix( " Suffix" )
App = QApplication(sys.argv)
window = Window()
check = window.spin.isVisible()
print (check)
sys.exit(App. exec ())
|
Output :
True
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...