aboutsummaryrefslogtreecommitdiff
path: root/eindopdracht/applicatie/main.py
blob: 222d785cfce528b3fd725c0a4cf040e30106a7e5 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/python3

import sys
import json
from PyQt6.QtCore import QDateTime, Qt, QTimer
from PyQt6.QtWidgets import *

def get_car_brands():
  return ["brand a", "brand b"]

def get_brand_info(brand):
  return { "key": "value", "models": ["model a", "model b"] }

def get_model_info(model):
  return { "power": 123 }

class MainWindow(QDialog):
  def __init__(self, parent=None):
    super(MainWindow, self).__init__(parent)

    self.brand = None
    self.brand_info = get_brand_info(self.brand)
    self.model = None
    self.model_info = get_model_info(self.model)

    brand_dropdown = QComboBox()
    brand_dropdown.addItems(get_car_brands())
    brand_dropdown_label = QLabel("Merk:")
    brand_dropdown_label.setBuddy(brand_dropdown)

    brand_facts = QPlainTextEdit()
    brand_facts.setReadOnly(True)
    brand_facts.setPlainText(json.dumps(self.brand_info))
    brand_facts_label = QLabel("Merkinfo:")
    brand_facts_label.setBuddy(brand_facts)

    model_dropdown = QComboBox()
    model_dropdown.addItems(self.brand_info["models"])
    model_dropdown_label = QLabel("Model:")
    model_dropdown_label.setBuddy(model_dropdown)

    model_facts = QPlainTextEdit()
    model_facts.setPlainText(json.dumps(self.model_info))
    model_facts.setReadOnly(True)
    model_facts_label = QLabel("Modelinfo:")
    model_facts_label.setBuddy(model_facts)
    model_facts_units_kw = QRadioButton("kW")
    model_facts_units_hp = QRadioButton("PK")
    model_facts_units_label = QLabel("Eenheden:")
    model_facts_units_layout = QHBoxLayout()
    model_facts_units_layout.addWidget(model_facts_units_label)
    model_facts_units_layout.addWidget(model_facts_units_hp)
    model_facts_units_layout.addWidget(model_facts_units_kw)

    select_layout = QVBoxLayout()
    select_layout.addWidget(brand_dropdown_label)
    select_layout.addWidget(brand_dropdown)
    select_layout.addWidget(brand_facts_label)
    select_layout.addWidget(brand_facts)
    select_layout.addWidget(model_dropdown_label)
    select_layout.addWidget(model_dropdown)
    select_layout.addLayout(model_facts_units_layout)
    select_layout.addWidget(model_facts_label)
    select_layout.addWidget(model_facts)

    viewer_layout = QVBoxLayout()

    layout = QHBoxLayout()
    layout.addLayout(select_layout)
    layout.addLayout(viewer_layout)
    layout.setStretch(1, 2)

    self.setLayout(layout)

if __name__ == '__main__':
  app = QApplication(sys.argv)
  win = MainWindow()
  win.show()
  app.exec()