踏实的汉堡包 · 小红书同款蘑菇猫猫羊毛毡手机链秋冬钥匙扣cc ...· 3 周前 · |
面冷心慈的花卷 · 北京东方红航天生物技术股份有限公司-网站首页· 2 月前 · |
玩命的大象 · How to Avoid the ...· 2 月前 · |
豪气的沙滩裤 · Meet-the-All-New-Kindl ...· 2 月前 · |
礼貌的炒饭 · 马斯克自曝猛料:曾被两次暗杀!· 5 月前 · |
In this article we will see how we can get effective window system identifier of the spin box. Effective identifier means the native parent’s window system identifier(ID) of the spin box.
In order to do this we use effectiveWinId method
Syntax : spin_box.effectiveWinId()
Argument : It takes no argument
Return : If the spin box is native, this function returns the native widget ID. Otherwise, the window ID of the first native parent widget, i.e., the top-level widget that contains this spin box, is returned.
Note : This method should be called after the opening of the main window i.e outside the main window class
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__()
# setting title
self
.setWindowTitle(
"Python "
)
# setting geometry
self
.setGeometry(
100
,
100
,
600
,
400
)
# calling method
self
.UiComponents()
# showing all the widgets
self
.show()
# method for widgets
def
UiComponents(
self
):
# creating spin box
self
.spin
=
QSpinBox(
self
)
# setting geometry to spin box
self
.spin.setGeometry(
100
,
100
,
250
,
40
)
# setting range to the spin box
self
.spin.setRange(
0
,
999999
)
# setting prefix to spin
self
.spin.setPrefix(
"Prefix "
)
# setting suffix to spin
self
.spin.setSuffix(
" Suffix"
)
# create pyqt5 app
App
=
QApplication(sys.argv)
# create the instance of our Window
window
=
Window()
# getting system identifier of spin box
identifier
=
window.spin.effectiveWinId()
# print the identifier
print
(identifier)
# start the app
sys.exit(App.
exec
())
面冷心慈的花卷 · 北京东方红航天生物技术股份有限公司-网站首页 2 月前 |
豪气的沙滩裤 · Meet-the-All-New-Kindle-Oasis-Featuring-a-7-inch-300-ppi-Display-Waterproof-Design-and-Audible - US 2 月前 |
礼貌的炒饭 · 马斯克自曝猛料:曾被两次暗杀! 5 月前 |