←  [EN] Test Feedback

Forums

»

Instant recording (with custom duration) f...

Dimitrij's Photo Dimitrij 19 Aug 2023

>>> a = ' 5 5 '
>>> a.strip()
'5 5'
>>> int(a.strip())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '5 5'
>>> a = ' 5 5 '
>>> int(a.replace(" ", ""))
55
>>>

 


Edited by Dimitrij, 19 August 2023 - 16:36.
Quote

WanWizard's Photo WanWizard 19 Aug 2023

Yes, I understand the difference.

 

My question is how on earth is this valid input? And who inputs this, you have to bend over backwards go get a space in there, let alone three...

Quote

ims's Photo ims 19 Aug 2023

As I saw, for Input box has definition of default text and length in one. In this case used text="5  " means 5 minuts as default number and length 3 chars. And user, unfortunately, can in this input box with < and > move cursor and then set f.eg. "5 1"... due it using useableChars is for nothing.

And then .replace(" ", "") is simplest way of fixing it (may be used  "".join(text.split() too, but why ...) 

Quote

littlesat's Photo littlesat 19 Aug 2023

Instill do not understand why we get space 5 space 5 and then we need to make it 55? What is this about? Can’t it be resolved at the input by not allowing unusable characters instead of work-a-round it afterwards… somehow they are already replaced by spaces?


Edited by littlesat, 19 August 2023 - 18:19.
Quote

ims's Photo ims 19 Aug 2023

read once again my first line ...

text="5  "   => input length is 3, default text is "5  ".  User then can use ">"  (keys for edit, it cannot be disabled) and type 1  => "5 1"


Edited by ims, 19 August 2023 - 18:23.
Quote

littlesat's Photo littlesat 19 Aug 2023

I did indeed… with strip you remove already the extra spaces. But when the field should be a number than arrange that is could only be a number… and arrange that at the input you cannot get spaces at all… solve the cause instead of hiding the symptom.


Edited by littlesat, 19 August 2023 - 18:24.
Quote

ims's Photo ims 19 Aug 2023

then must be rebuilded whole input box in E2 ... user cannot add spaces, he can type numbers only, but spaces are there as definition field length and user can move cursor to end and type number.

 

btw - strip(char) removing char on start or on end ...


Edited by ims, 19 August 2023 - 18:29.
Quote

littlesat's Photo littlesat 19 Aug 2023

Yep indeed strip is start and end. But there should be no space in the middle and indeed the input stuff needs revision… maybe add parameter that a number is expected? The original code here still comes from DMMs ‘attic’. When you expect to enter numbers you should not have spaces in between….’and 5 space 5 is actually bad input…. This should be made impossible. Why is it ‘fixed’ on three characters is also crazy..
Edited by littlesat, 19 August 2023 - 19:42.
Quote

ims's Photo ims 19 Aug 2023

The InputBox is an old text field. You can specify which characters are accepted during input, but once you delete something, spaces are inserted there anyway. Even entering something like text="005" doesn't help. Try it.

Quote

ims's Photo ims 19 Aug 2023

it could be fixed in InputBox:

	def go(self):
+		if self.useableChars and " " not in self.useableChars:
+			self.close(self["input"].getText().replace(" ",""))
+		else:
			self.close(self["input"].getText())

and in InstantRecording in call InputBox add

useableChars='0123456789' 

 

 

 
 
 

Quote

littlesat's Photo littlesat 20 Aug 2023

Again work a round… unless it might work. The issue is that you reserved 3 characters for the input… so it starts with “   “. Why? You want to enter a number…. It should not have length of string… maybe only when we want a max number…

as far I know in config stuff we have number options… use that instead?


Edited by littlesat, 20 August 2023 - 07:57.
Quote

ims's Photo ims 20 Aug 2023

Once you set a fixed length (maxSize=True), the field length is determined by the length of the string 'text,' and it cannot be changed.
So, without spaces (text="5"), only a single-digit number will be accepted. Because that's how the InputBox works.

We can call InputBox with: text="5", maxSize=False. Then it will be without spaces, but then is not limited length of typed number. Does the size of the number need to be limited?

PR is created on github.

 


Edited by ims, 20 August 2023 - 09:04.
Quote

Stan's Photo Stan 20 Aug 2023

Werbezapper uses this inputbox too. It has maxSize=False and crashes with long inputs.

 

Is there really no suited input mask that can be used instead?

Quote

littlesat's Photo littlesat 20 Aug 2023

Sounds like InputBox need a real revision/fix to allow to enter numbers (integers). instead of work-a-round and work-a-round work-a-rounds… for me at least no it is clear what is going on here… doing 5 space 5 should be made impossible here. So doing > when you have numbers only and you skip a space is also something you can do to make this not possible… if type is a number…
Edited by littlesat, 20 August 2023 - 13:02.
Quote

ims's Photo ims 20 Aug 2023

maxsize=False is not work-a-round ... I give up...

Quote

littlesat's Photo littlesat 20 Aug 2023

Add feature to enter number to InputBox is a fix
Quote

ims's Photo ims 20 Aug 2023

If you want rebuild string inputBox, you have the option... InputBox.py, respective Input.py
Btw - I dont know, who merged my PR, but it seems, it is merged...

Quote

WanWizard's Photo WanWizard 20 Aug 2023

I did. Shouldn't I have done that?

Quote

ims's Photo ims 20 Aug 2023

I did. Shouldn't I have done that?

It can be ...

Quote

littlesat's Photo littlesat 23 Aug 2023

I just tried to verify the issue with the 5 space 5... but I tried with instant recording but I was not able to get it. How did you arrange to get 5 space 5... I can't.

Quote