I would like to limit digit input value in PyQt5 QLineEdit Gui in Python.
The explanation photo is below.
Wind direction is from 0 to 359 degree.
so, the value to be able to input is from 0 to 359.
The code that I made is below.
class Ship_Use_Tug_Input_Program(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
wd = QLabel('Wind Direction', self)
wd.move(40, 300)
wd_ent = QLineEdit(self)
wd_ent.move(180, 295)
wd_ent.resize(80, 25)
wd_font = wd.font()
wd_font.setBold(False)
wd.setFont(wd_font)
QToolTip.setFont(QFont('Times New Roman', 8))
wd.setToolTip('Please type 000 form\nExample)090 degree direction->"Type 090"')
file = pathlib.Path('C:/Users/woody/OneDrive/Desktop/Python Workspace/Ship_Use_Tug_Input_Program.xlsx')
if file.exists():
pass
else:
file=Workbook()
sheet = file.active
file.save('C:/Users/woody/OneDrive/바탕 화면/Python Workspace/Ship_Use_Tug_Input_Program.xlsx')
def save_to_excel(self):
file = openpyxl.load_workbook('C:/Users/woody/OneDrive/바탕 화면/Python Workspace/Ship_Use_Tug_Input_Program.xlsx')
sheet = file.active
file.save('C:/Users/woody/OneDrive/바탕 화면/Python Workspace/Ship_Use_Tug_Input_Program.xlsx')
btn_save = QPushButton('Save', self)
btn_save.clicked.connect(save_to_excel)
btn_save.move(380,520)
self.setWindowTitle('Ship use tug input program')
self.setFixedSize(945, 570)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Ship_Use_Tug_Input_Program()
sys.exit(app.exec_())