GUI-Guider: Center alignment can crash Micropython

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

GUI-Guider: Center alignment can crash Micropython

956 次查看
MitchBradley
Contributor I

I am prototyping a GUI design using the simulator under Windows.  Running it under C worked, but MicroPython crashed, displaying a blank window that immediately disappeared.  I ran "micropython gui_guider.py:" in a terminal window to find this message:

File "/Users/wmb/Documents/Tablet7/generated/gui_guider.py", line 430, in <module>
TypeError: can't convert float to int

The offending line of code was:

screen_label_state.set_pos(10, 19.5)

That non-integral position 19.5 resulted from the VerticalAlignCenter command, where I tried to align a first item of height 33 to a second item with Y position 11, height 50.  The calculation resulted in a first item Y position of 19.5, which appeared in the Attributes:Position display in GUI-Guider.

The C compiler demoted the floating point value 19.5 to integer, so the C version worked.  MicroPython errored out.

I believe that GUI Guider should round calculated positions to integer to avoid such problems.

It is easy to workaround this problem if you happen to notice it.  You can just hit the decrement button on the Position and it will remove the .5 .

0 项奖励
回复
1 回复

917 次查看
WenbinYuan
NXP Employee
NXP Employee

Hi @MitchBradley,

 

Thanks for your feedback, this problem does exist in V1.8.0, we will trying to fix it in the future release.

 

Best Regards,

Wenbin 

0 项奖励
回复