-
Notifications
You must be signed in to change notification settings - Fork 0
/
test3.py
63 lines (50 loc) · 1.49 KB
/
test3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
from typing import Dict, Any, Callable
from PyQt5.QtWidgets import QApplication
from dialog import DictBindingDialog
from models import TableItem, DictTableRow
dic = {
'str': 'bin ein String',
'nr': '123',
'spin': '7'
}
class TestInputDialog(DictBindingDialog):
def __init__(self):
super(TestInputDialog, self).__init__("testInput.ui")
self.__tableRow: DictTableRow = None
def setTableRow(self, row: DictTableRow):
self.__tableRow = row
self.__bind()
def __bind(self):
self.bind("inStr",
self.inStr.text,
self.inStr.setText,
'str',
dic['str'])
self.bind("inNr",
self.inNr.text,
self.inNr.setText,
'nr',
dic['nr'])
self.bind("inSpin",
self.inSpin.value,
self.inSpin.setValue,
'spin',
int(dic['spin']))
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
#create the model assuming it's a table's row
tableRow = DictTableRow(dic)
#create dialog
dlg = TestInputDialog()
#set dialog's model
dlg.setTableRow(tableRow)
dlg.inCombo.addItem("")
dlg.inCombo.addItem("red")
dlg.inCombo.addItem("yellow")
dlg.inCombo.addItem("green")
dlg.inCombo.addItem("blue")
dlg.inCombo.setCurrentIndex(2)
dlg.show()
sys.exit(app.exec_())