rfid tag write
This commit is contained in:
parent
fee192f805
commit
d5d4d654e8
|
|
@ -16,41 +16,6 @@ from lib.db.models import Recipes , Users
|
|||
test_scan="xxx\nyyy\nzzz"
|
||||
|
||||
|
||||
class TagWindow(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setWindowTitle("Scrittura NFC")
|
||||
self.setFixedSize(400, 300)
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
|
||||
self.text_edit = QPlainTextEdit(self)
|
||||
self.text_edit.setPlaceholderText("Scanerizza il QRcode della Dima")
|
||||
self.text_edit.setFixedHeight(100)
|
||||
|
||||
|
||||
layout.addWidget(self.text_edit)
|
||||
button_layout = QHBoxLayout()
|
||||
|
||||
|
||||
self.ok_button = QPushButton("Conferma Tag", self)
|
||||
self.ok_button.clicked.connect(self.on_ok_clicked)
|
||||
|
||||
# Create the Close button
|
||||
self.close_button = QPushButton("Chiudi", self)
|
||||
self.close_button.clicked.connect(self.close)
|
||||
|
||||
button_layout.addWidget(self.ok_button)
|
||||
button_layout.addWidget(self.close_button)
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
def on_ok_clicked(self):
|
||||
entered_text = self.text_edit.toPlainText()
|
||||
print(f"Text Entered: {entered_text}")
|
||||
self.accept()
|
||||
|
||||
|
||||
class Barcode_Recipe_Selection(Test_Test):
|
||||
def __init__(self, parent):
|
||||
|
|
@ -159,35 +124,24 @@ class Barcode_Recipe_Selection(Test_Test):
|
|||
self.parent_assembly_widget().set_text("SCANSIONARE BARCODE SELEZIONE RICETTA")
|
||||
|
||||
|
||||
|
||||
def open_tag_window(self):
|
||||
|
||||
# Open the tag writing window
|
||||
self.tag_window = TagWindow(self)
|
||||
result = self.tag_window.exec_() # Get the result of the dialog (OK or Cancel)
|
||||
if result != QDialog.Accepted:
|
||||
return # If canceled, return
|
||||
|
||||
entered_text = self.tag_window.text_edit.toPlainText().strip()
|
||||
if not entered_text:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"Warning",
|
||||
"The text is empty. Please enter text to write to the tag.",
|
||||
)
|
||||
self.parent_assembly_widget().set_text(
|
||||
"SCRITTURA TAG NFC ",bg_color=" yellow")
|
||||
tag_data = self.barcode_input_l.toPlainText().strip()
|
||||
if not tag_data:
|
||||
QMessageBox.warning(self, "Warning", "Il campo di input è vuoto. Scansiona un QR code o un tag NFC per conTINUARE")
|
||||
return
|
||||
|
||||
# Check if the tag is empty
|
||||
if self.parent.components["fixture_id"].current_data:
|
||||
# Tag already contains data, ask for confirmation to overwrite
|
||||
confirmation_result = QMessageBox.question(
|
||||
self,
|
||||
"Tag Already Written",
|
||||
"The tag already contains data. Do you want to overwrite it?",
|
||||
"Tag già scritto",
|
||||
"Il tag contiene già dei dati. Vuoi sovrascriverli?",
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
)
|
||||
if confirmation_result == QMessageBox.No:
|
||||
return # User does not want to overwrite, so return without writing
|
||||
return
|
||||
|
||||
# Write the entered text to the tag
|
||||
self.parent.components["fixture_id"].write_tag(entered_text)
|
||||
QMessageBox.information(self, "Success", "The tag has been successfully written.")
|
||||
self.parent.components["fixture_id"].write_tag(tag_data)
|
||||
QMessageBox.information(self, "Successo", "Il tag è stato scritto correttamente.")
|
||||
|
|
|
|||
|
|
@ -15,113 +15,139 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>308</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QPushButton" name="recipe_selection_b">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TORNA ALLA TABELLA RICETTE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="barcode_input_l">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>78</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>378</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>78</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>168</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>282</width>
|
||||
<height>93</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>351</width>
|
||||
<height>93</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>78</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>168</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="barcode_input_l">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>78</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QPushButton" name="recipe_selection_b">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TORNA ALLA TABELLA RICETTE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="tag_b">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
|
@ -139,15 +165,28 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>28</height>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user