简体   繁体   English

Python:Pyqt仅从纯文本接收十六进制格式整数

[英]Python: Pyqt Receive Hex format integer only from Plaintext

I want to receive single byte data from user from a plaintext_edit but i want to make sure it is entered in hex format, 0x with prefix or else will result in unknown type 我想从plaintext_edit接收用户的单字节数据,但我想确保以十六进制格式输入,带前缀的0x,否则将导致未知类型

Example : 0x3f 范例:0x3f

-Thanks -谢谢

You didn't say but I am guessing you are using pyqt . 您没有说,但我猜您正在使用pyqt Define a handler for the control's keyPressEvent and filter the user input there. 为控件的keyPressEvent定义一个处理程序,并在那里过滤用户输入。 That won't raise a type error. 那不会引发类型错误。 Instead you ensure that only valid data gets entered. 相反,您确保仅输入有效数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM