|
| 1 | +from PyQt5.QtWidgets import QPushButton, QGridLayout, QGroupBox, QWidget, QSizePolicy |
| 2 | +# from PyQt5.QtGui import QPixmap |
| 3 | +# from PyQt5 import QtCore |
| 4 | +# import os |
| 5 | +# import sys |
| 6 | + |
| 7 | +# import counter |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +class ButtonWindow(QWidget): |
| 12 | + def __init__(self): |
| 13 | + super().__init__() |
| 14 | + self.setWindowTitle("Ground Truthing") |
| 15 | + # self.gridstruct() |
| 16 | + # print("created button widget") |
| 17 | + sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) |
| 18 | + sizePolicy.setHeightForWidth(True) |
| 19 | + self.setSizePolicy(sizePolicy) |
| 20 | + # self.show() |
| 21 | + def gridstruct(self, frame_counter, printer): |
| 22 | + |
| 23 | + self.groupbox = QGroupBox("Counter") |
| 24 | + # print (self.sizeHint()) |
| 25 | + # self.groupbox.resize(640, 240) |
| 26 | + gridlayout = QGridLayout() |
| 27 | + |
| 28 | + small_car_plus = QPushButton("small car +") |
| 29 | + small_car_plus.setStatusTip("Add Small Car (Shortcut : 1)") |
| 30 | + small_car_plus.setShortcut("1") |
| 31 | + gridlayout.addWidget(small_car_plus, 0, 0) |
| 32 | + small_car_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "small_car", True)) |
| 33 | + |
| 34 | + big_car_plus = QPushButton("big car +") |
| 35 | + big_car_plus.setStatusTip("Add Big car (Shortcut : 2)") |
| 36 | + big_car_plus.setShortcut("2") |
| 37 | + gridlayout.addWidget(big_car_plus, 0, 1) |
| 38 | + big_car_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "big_car", True)) |
| 39 | + |
| 40 | + bus_plus = QPushButton("bus +") |
| 41 | + bus_plus.setStatusTip("Add Bus (Shortcut : 3)") |
| 42 | + bus_plus.setShortcut("3") |
| 43 | + gridlayout.addWidget(bus_plus, 0, 2) |
| 44 | + bus_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "buses", True)) |
| 45 | + |
| 46 | + two_wheeler_plus = QPushButton("two wheeler +") |
| 47 | + two_wheeler_plus.setStatusTip("Add Two-Wheeler (Shortcut : 4)") |
| 48 | + two_wheeler_plus.setShortcut("4") |
| 49 | + gridlayout.addWidget(two_wheeler_plus, 0, 3) |
| 50 | + two_wheeler_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "two_wheeler", True)) |
| 51 | + |
| 52 | + three_wheeler_plus = QPushButton("three wheeler +") |
| 53 | + three_wheeler_plus.setStatusTip("Add Three-Wheeler (Shortcut : q)") |
| 54 | + three_wheeler_plus.setShortcut("q") |
| 55 | + gridlayout.addWidget(three_wheeler_plus, 3, 0) |
| 56 | + three_wheeler_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "three_wheeler", True)) |
| 57 | + |
| 58 | + LCV_plus = QPushButton("LCV +") |
| 59 | + LCV_plus.setStatusTip("Add LCV (Shortcut : w)") |
| 60 | + LCV_plus.setShortcut("w") |
| 61 | + gridlayout.addWidget(LCV_plus, 3, 1) |
| 62 | + LCV_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "LCV", True)) |
| 63 | + |
| 64 | + trucks_plus = QPushButton("trucks +") |
| 65 | + trucks_plus.setStatusTip("Add Truck (Shortcut : e)") |
| 66 | + trucks_plus.setShortcut("e") |
| 67 | + gridlayout.addWidget(trucks_plus, 3, 2) |
| 68 | + trucks_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "trucks", True)) |
| 69 | + |
| 70 | + bicycle_plus = QPushButton("bicycle +") |
| 71 | + bicycle_plus.setStatusTip("Shortcut : r") |
| 72 | + bicycle_plus.setShortcut("r") |
| 73 | + gridlayout.addWidget(bicycle_plus, 3, 3) |
| 74 | + bicycle_plus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "bicycle", True)) |
| 75 | + |
| 76 | + |
| 77 | + small_car_minus = QPushButton("small car -") |
| 78 | + small_car_minus.setStatusTip("Shortcut : Shift+1") |
| 79 | + small_car_minus.setShortcut("!") |
| 80 | + gridlayout.addWidget(small_car_minus, 1, 0) |
| 81 | + small_car_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "small_car", False)) |
| 82 | + |
| 83 | + big_car_minus = QPushButton("big car -") |
| 84 | + big_car_minus.setStatusTip("Shortcut : Shift+2") |
| 85 | + big_car_minus.setShortcut("@") |
| 86 | + gridlayout.addWidget(big_car_minus, 1, 1) |
| 87 | + big_car_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "big_car", False)) |
| 88 | + |
| 89 | + bus_minus = QPushButton("bus -") |
| 90 | + bus_minus.setStatusTip("Shortcut : Shift+3") |
| 91 | + bus_minus.setShortcut("#") |
| 92 | + gridlayout.addWidget(bus_minus, 1, 2) |
| 93 | + bus_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "buses", False)) |
| 94 | + |
| 95 | + two_wheeler_minus = QPushButton("two wheeler -") |
| 96 | + two_wheeler_minus.setStatusTip("Shortcut : Shift+4") |
| 97 | + two_wheeler_minus.setShortcut("$") |
| 98 | + gridlayout.addWidget(two_wheeler_minus, 1, 3) |
| 99 | + two_wheeler_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "two_wheeler", False)) |
| 100 | + |
| 101 | + three_wheeler_minus = QPushButton("three wheeler -") |
| 102 | + three_wheeler_minus.setStatusTip("Shortcut : Shift+q") |
| 103 | + three_wheeler_minus.setShortcut("Shift+Q") |
| 104 | + gridlayout.addWidget(three_wheeler_minus, 4, 0) |
| 105 | + three_wheeler_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "three_wheeler", False)) |
| 106 | + |
| 107 | + LCV_minus = QPushButton("LCV -") |
| 108 | + LCV_minus.setStatusTip("Shortcut : Shift+w") |
| 109 | + LCV_minus.setShortcut("Shift+W") |
| 110 | + gridlayout.addWidget(LCV_minus, 4, 1) |
| 111 | + LCV_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "LCV", False)) |
| 112 | + |
| 113 | + trucks_minus = QPushButton("trucks -") |
| 114 | + trucks_minus.setStatusTip("Shortcut : Shift+e") |
| 115 | + trucks_minus.setShortcut("Shift+E") |
| 116 | + gridlayout.addWidget(trucks_minus, 4, 2) |
| 117 | + trucks_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "trucks", False)) |
| 118 | + |
| 119 | + bicycle_minus = QPushButton("bicycle -") |
| 120 | + bicycle_minus.setStatusTip("Shortcut : Shift+r") |
| 121 | + bicycle_minus.setShortcut("Shift+R") |
| 122 | + gridlayout.addWidget(bicycle_minus, 4, 3) |
| 123 | + bicycle_minus.clicked.connect(lambda: self.button_is_clicked(frame_counter, printer, "bicycle", False)) |
| 124 | + |
| 125 | + print("button block size", self.size()) |
| 126 | + # self.resize(640, 240) |
| 127 | + self.groupbox.setLayout(gridlayout) |
| 128 | + |
| 129 | + def button_is_clicked(self, frame_counter, printer, entity, add_or_minus): |
| 130 | + if add_or_minus == True: |
| 131 | + frame_counter.add_entity(entity) |
| 132 | + elif add_or_minus == False: |
| 133 | + frame_counter.remove_entity(entity) |
| 134 | + printer.show_data(frame_counter) |
0 commit comments