In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to make a simple ordering system in Python". In daily operation, I believe many people have doubts about how to make a simple ordering system in Python. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to make a simple ordering system in Python". Next, please follow the editor to study!
Case study:
Design a user selection interface in the form of list
Tools:
Python
PyQt5
The running result of the program is as follows:
(1) initial interface
(2) Select menu items
(3) choose multiple times
The design procedure is as follows: from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_MainWindow (object): def setupUi (self, MainWindow): MainWindow.setObjectName ("MainWindow") MainWindow.resize (300,300) self.centralwidget = QtWidgets.QWidget (MainWindow) self.centralwidget.setObjectName ("centralwidget") self.listWidget = QtWidgets.QListWidget (self.centralwidget) self.listWidget.setGeometry (QtCore.QRect (20,10,260) Self.listWidget.setObjectName ("listWidget") MainWindow.setCentralWidget (self.centralwidget) self.menubar = QtWidgets.QMenuBar (MainWindow) self.menubar.setGeometry (QtCore.QRect (0,0,800) 26) self.menubar.setObjectName ("menubar") MainWindow.setMenuBar (self.menubar) self.statusbar = QtWidgets.QStatusBar (MainWindow) self.statusbar.setObjectName ("statusbar") MainWindow.setStatusBar (self.statusbar) self.retranslateUi (MainWindow) QtCore.QMetaObject.connectSlotsByName (MainWindow) # you can select multiple self.listWidget.setSelectionMode (QtWidgets.QAbstractItemView.MultiSelection) in the setting list ) # set selection method to select self.listWidget.setSelectionBehavior (QtWidgets.QAbstractItemView.SelectRows) # set to display data in list form self.listWidget.setViewMode (QtWidgets.QListView.ListMode) self.listWidget.setWordWrap (True) from collections import OrderedDict # set automatic line wrapping # define ordered dictionary As the data source of the List list, dict = OrderedDict ({'steamed lamb': '998 yuan / share', 'steamed bear's paw': '998 yuan / share', 'steamed deer tail': '998 yuan / share', 'roast duck': '288 / share' 'roast chicken': '288 / portion', 'roast goose': '288 yuan / portion', 'stewed pig': '688 yuan / portion', 'stewed duck': '188 yuan / portion' 'Chicken Seasoned with Brown Sauce bacon': '188 yuan / copy'}) for key, value in dict.items (): # ergodic dictionary And get the key value self.item = QtWidgets.QListWidgetItem (self.listWidget) # create list item self.item.setText (key+':'+ value) # setting item text self.item.setToolTip (value) # setting prompt text self.listWidget.itemClicked.connect (self.gettext) def gettext (self,item): # Custom slot function Get the value of the selected item in the list if item.isSelected (): # determine whether the item is selected from PyQt5.QtWidgets import QMessageBox QMessageBox.information (MainWindow, "prompt", "you select:" + item.text (), QMessageBox.Ok) def retranslateUi (self, MainWindow): _ translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle (_ translate ("MainWindow", "ordering system")) import sys# main method From here, the program launches the PyQt-designed form if _ _ name__ = ='_ main__': app = QtWidgets.QApplication (sys.argv) MainWindow = QtWidgets.QMainWindow () # create the form object ui = Ui_MainWindow () # create the PyQt-designed form object ui.setupUi (MainWindow) # call the PyQt form method to initialize the form object MainWindow.show () # display the form Sys.exit (app.exec_ ()) # exits the process here when the program closes The study on "how to make a simple ordering system for Python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.