from
PyQt5.QtWidgets
import
*
from
PyQt5
import
QtCore, QtGui
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
import
sys
class
StringBox(QSpinBox):
def
__init__(
self
, parent
=
None
):
super
(StringBox,
self
).__init__(parent)
strings
=
[
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
]
self
.setStrings(strings)
def
setStrings(
self
, strings):
strings
=
list
(strings)
self
._strings
=
tuple
(strings)
self
._values
=
dict
(
zip
(strings,
range
(
len
(strings))))
self
.setRange(
0
,
len
(strings)
-
1
)
def
textFromValue(
self
, value):
return
self
._strings[value]
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle(
"Python "
)
self
.setGeometry(
100
,
100
,
600
,
400
)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
string_spin_box
=
StringBox(
self
)
string_spin_box.setGeometry(
100
,
100
,
200
,
40
)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())