Note that there are some explanatory texts on larger screens.

plurals
  1. POSelf contained classes with Qt
    primarykey
    data
    text
    <p>I've been trying to make my classes completely self contained, but I'm having some problems, which are probably coming from my missing something that everybody else knew first off...</p> <p>Anyway, take this example:</p> <pre><code>class Main_Window (QtGui.QMainWindow): def __init__ (self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_bookingSystemMain() self.ui.setupUi(self) # Connect slots QtCore.QObject.connect(self.ui.submitRecord, QtCore.SIGNAL("clicked()"), self.__clickSubmitRecord) QtCore.QObject.connect(self.ui.btnListBookings, QtCore.SIGNAL("clicked()"), self.__show_list) def __clickSubmitRecord (self): global bookings name = self.ui.edtName.text() event = str(self.ui.comEvent.currentText()) amount = self.ui.spinBox.value() if name == '': QtGui.QMessageBox.warning(self, "Error", "Please enter a name!") elif amount == 0: QtGui.QMessageBox.warning(self, "Error", "You can't reserve 0 tickets!") elif event == '': QtGui.QMessageBox.warning(self, "Error", "Please choose an event!") else: bookings.append(Booking(name, event, amount)) QtGui.QMessageBox.information(self, "Booking added", "Your booking for " + str(amount) + " ticket(s) to see " + event + " in the name of " + name + " was sucessful.") self.__clear_widgets() def __clear_widgets (self): self.ui.edtName.clear() self.ui.comEvent.setCurrentIndex(-1) self.ui.spinBox.setValue(0) def __show_list (self): listdialog = List_Window(self) listdialog.show() </code></pre> <p>Which implements a UI described in another module. The clickSubmitRecord() method uses the global 'booking' list and adds to it - now surely this class shouldn't have anything to do with anything other than that UI?</p> <p>How would I implement this in a good ood way? As I said I'm probably missing some kind of technique or obvious design feature...</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload