def __init__(self, content): super(OpenDrawer, self).__init__() Drawers.setup() self.content = content loadUi(os.path.join(UI_DIRECTORY, 'open_drawer.ui'), self) self.no_button.clicked.connect(self.back) self.yes_button.clicked.connect(self.save) self.count = 10 self.open_drawer = False self.drawer_id = '1' self.recipient_id = '' self.location_id = '' self.sender_id = '' self.success_message = 'Have you successfully placed your delivery?' self.instruction_message = 'place'
def retrieve_delivery(self): if len(Drawers.receive_drawers(self.user_id)) == 0: self.content.activate(self.content.components['error']) self.content.components['error'].message_label.setText('You have no pending deliveries') self.content.activate_after(self.content.components['welcome'], 3500) else: self.content.activate(self.content.components['retrieve_delivery'])
def add_delivery(self): if len(Drawers.available_drawers()) == 0: self.content.activate(self.content.components['error']) self.content.components['error'].message_label.setText('No more empty drawers available') self.content.activate_after(self.content.components['welcome'], 3500) else: self.content.activate(self.content.components['add_delivery'])
def retrieve_delivery(self): if len(Drawers.receive_drawers(self.user_id)) == 0: self.content.activate(self.content.components['error']) self.content.components['error'].message_label.setText( 'You have no pending deliveries') self.content.activate_after(self.content.components['welcome'], 3500) else: self.content.activate(self.content.components['retrieve_delivery'])
def add_delivery(self): if len(Drawers.available_drawers()) == 0: self.content.activate(self.content.components['error']) self.content.components['error'].message_label.setText( 'No more empty drawers available') self.content.activate_after(self.content.components['welcome'], 3500) else: self.content.activate(self.content.components['add_delivery'])
def show(self, *args, **kwargs): super(RetrieveDelivery, self).show() self.disable_drawers() self.prepare_open_drawer() for drawer in Drawers.receive_drawers(self.recipient_id): if drawer == '1': self.drawer1_button.setEnabled(True) elif drawer == '2': self.drawer2_button.setEnabled(True) elif drawer == '3': self.drawer3_button.setEnabled(True)
def show(self, *args, **kwargs): super(AddDelivery, self).show() self.prepare_open_drawer() while self.recipient_combobox.count() > 0: self.recipient_combobox.removeItem(0); for user in User.get_users(): if user.id != self.sender.id: self.recipient_combobox.addItem(user.name) # Reset the combobox fields when this form is shown #from PySide.QtGui import QComboBox ##test = QComboBox() while self.drawer_combobox.count() > 0: self.drawer_combobox.removeItem(0) #self.drawer_combobox.removeItems() for drawer in Drawers.available_drawers(): self.drawer_combobox.addItem(drawer) self.recipient_combobox.setCurrentIndex(0) self.location_combobox.setCurrentIndex(0) self.drawer_combobox.setCurrentIndex(0)
def show(self, *args, **kwargs): super(AddDelivery, self).show() self.prepare_open_drawer() while self.recipient_combobox.count() > 0: self.recipient_combobox.removeItem(0) for user in User.get_users(): if user.id != self.sender.id: self.recipient_combobox.addItem(user.name) # Reset the combobox fields when this form is shown #from PySide.QtGui import QComboBox ##test = QComboBox() while self.drawer_combobox.count() > 0: self.drawer_combobox.removeItem(0) #self.drawer_combobox.removeItems() for drawer in Drawers.available_drawers(): self.drawer_combobox.addItem(drawer) self.recipient_combobox.setCurrentIndex(0) self.location_combobox.setCurrentIndex(0) self.drawer_combobox.setCurrentIndex(0)
def save(self): Drawers.remove_delivery(self.drawer_id) self.content.activate(self.content.components['welcome'])
def save(self): Drawers.add_delivery(self.drawer_id, self.recipient_id, self.location_id) self.content.activate(self.content.components['welcome'])