Re: [Tutor] Query about using Pmw entry widget...
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > The dialog box, what I think is better than a 'visual warning' ; > because it > forces the user to correct the input error that he has made. A > visual > warning might be omitted by the user. I disagree. A dialog box in this situation has two bad effects: 1) It forces the users attention away from where the error occurs (ie in the entry box) and in an extreme case could even hide the error by popping up on top of the box beintg edited! 2) It is not specific enough - the dialog could be from another application in the background or about some other error - a network lost for example. You have to read it to interpret it. Whereas if the entry box you are typing into beeps and goes red, say, it is obvious where the error is and it's very easy to fix. As to forcing the user to correct the error a doalog is no better than a coloured entry widget since the user can just OK it and carry on filling I the other fields. In that situation you have to do a submit time check on the fields too or else refuse to allow access to any other field while the error persists. Designing a good UI is frought with difficulty. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
Hey Luke, The dialog box, what I think is better than a 'visual warning' ; because it forces the user to correct the input error that he has made. A visual warning might be omitted by the user. REgards, Asrarahmed On 1/7/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Alan Gauld wrote: > "Luke Paireepinart" <[EMAIL PROTECTED]> wrote > > OP>> Can some one help me how to add validation : only integers are > allowed > OP>> and minimum value should be 1. > OP>> > OP>> timeInterval = Pmw.EntryField(label_text='Time Interval(in > OP>> sec.):',labelpos='w',validate = 'numeric') > > I don;t have PMW installed. I tend to use Tix now that its part > of standard Python. However Grayson says this: > > "validation is [performed by a function which takes > as its first argument the entered text and returns > one of three standard values... > Pmw.OK, Pmw.ERROR, Pmw.PARTIAL" > > So it seems you need > > def numeric(val): > try: float(val) > except ValueError: return Pmw.ERROR > else: return Pmw.OK > > timeinterval = Pmw.EntryField(.validate=numeric) > > At least that's how I read it, obviously without Pmw I can't try it... > > >>> Also I want to validate date and time? I know that there is a way >>> to >>> do it but I dont know the exact syntax.. >>> > > I'd use a similar technique as above. parse the string and try > to create a datetime object then handle the exceptions. > > Luke> it's a lot easier to validate the input when you're using it > instead of > Luke> trying to restrict their input. > > Its easier for the programmer but much worse for the user. > We should always catch erroneous input as early as possible. > Early CGI Web pages were the classic example of late error > handling and there is nothing more annoying than filling in a form, > submitting it and then being told you filled in a field wrong right > at the start! > The difference between a webpage and an application here is that if the user enters something incorrectly, he'll know as soon as he tries to submit it, without having to wait for the page to reload, and he won't lose all of his information just to go back and change one field. But I guess I don't know anything about UI design. That's why I just purchased 'The Essential Guide To User Interface Design' from Half-Price Books! Yes, a bit of a strange coincidence that I bought it just today. Anyway, I know it's frustrating to have to go back to fix entries, but it's also annoying to have something restrict your input. That seems sort of like the programmer didn't want to take the time to have a robust user input parser :D I think the ideal situation for me would be that whenever an entry widget loses focus, the validate() function is called, and I get some kind of visual warning that my entry is incorrect. NOT a dialog box, I hope, but some kind of red warning label next to the entry widget or something. However, this doesn't work for the last entry on the page, because most likely focus will switch straight from the entry to the submit button, but then the whole 'check on submit' thing would catch the error. Basically I don't want to see an entry box that behaves differently than a normal entry box (only accepts integers, for example). -Luke > HTH, > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
On 07/01/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > I don;t have PMW installed. I tend to use Tix now that its part > of standard Python. However Grayson says this: Does Tix work with py2exe? That's why I gave up on it, a while ago.. > So it seems you need > > def numeric(val): > try: float(val) > except ValueError: return Pmw.ERROR > else: return Pmw.OK > > timeinterval = Pmw.EntryField(.validate=numeric) >From memory, you have to do something like "validate={'validator':numeric}" if you're not using one of the built-in validators. (which Asrarahmed would need to do, since he wants to restrict the range of numbers available) Also, this will not work quite right; you need something like: def numeric(val): try: float(val) except ValueError: if val == '': return Pmw.PARTIAL return Pmw.ERROR return Pmw.OK -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote >> Its easier for the programmer but much worse for the user. >> We should always catch erroneous input as early as possible. > > The difference between a webpage and an application here is that if > the > user enters something incorrectly, he'll know as soon as he tries to > submit it, without having to wait for the page to reload, Only a few seconds difference, he's still done all the work of filling in 10 or more fields and now has to back to look for the error. > That's why I just purchased 'The Essential Guide To User Interface > Design' from Half-Price Books! I haven't seen that one, but I do like Abbout Face by Cooper - the guy who wrote the first version of Visual Basic before MS bought it. > but it's also annoying to have something restrict your input. But if the input is wronmg better to get it right first time rather than have the same error flagged to you after you've stopped thinking about that bit of data. > and I get some kind of visual warning that my entry is incorrect. > NOT a dialog box, I hope, but some kind of red warning label next to > the > entry widget or something. I agree, dialogs are a pain for this. But as I understand it (without having used it!) PMW actually does give a visual indication by changing the colour of the field to indicate an error rather than a dialog.. Also the validator is called on each keystroke *as well as* when it loses focus. > Basically I don't want to see an entry box that behaves differently > than > a normal entry box (only accepts integers, for example). But there are quite a few like that in Windows. Several of the config tools regulate input. Think if the entry fields for inputting an IP address.They autommatically jump to the next box after 3 digits, and they won't let you enter a number above 255. Similarly password entries are diffeerent to normal because they show up asstars or blobs or sometimes as nothing at all (I don't like those even though they are more secure!) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
Alan Gauld wrote: > "Luke Paireepinart" <[EMAIL PROTECTED]> wrote > > OP>> Can some one help me how to add validation : only integers are > allowed > OP>> and minimum value should be 1. > OP>> > OP>> timeInterval = Pmw.EntryField(label_text='Time Interval(in > OP>> sec.):',labelpos='w',validate = 'numeric') > > I don;t have PMW installed. I tend to use Tix now that its part > of standard Python. However Grayson says this: > > "validation is [performed by a function which takes > as its first argument the entered text and returns > one of three standard values... > Pmw.OK, Pmw.ERROR, Pmw.PARTIAL" > > So it seems you need > > def numeric(val): > try: float(val) > except ValueError: return Pmw.ERROR > else: return Pmw.OK > > timeinterval = Pmw.EntryField(.validate=numeric) > > At least that's how I read it, obviously without Pmw I can't try it... > > >>> Also I want to validate date and time? I know that there is a way >>> to >>> do it but I dont know the exact syntax.. >>> > > I'd use a similar technique as above. parse the string and try > to create a datetime object then handle the exceptions. > > Luke> it's a lot easier to validate the input when you're using it > instead of > Luke> trying to restrict their input. > > Its easier for the programmer but much worse for the user. > We should always catch erroneous input as early as possible. > Early CGI Web pages were the classic example of late error > handling and there is nothing more annoying than filling in a form, > submitting it and then being told you filled in a field wrong right > at the start! > The difference between a webpage and an application here is that if the user enters something incorrectly, he'll know as soon as he tries to submit it, without having to wait for the page to reload, and he won't lose all of his information just to go back and change one field. But I guess I don't know anything about UI design. That's why I just purchased 'The Essential Guide To User Interface Design' from Half-Price Books! Yes, a bit of a strange coincidence that I bought it just today. Anyway, I know it's frustrating to have to go back to fix entries, but it's also annoying to have something restrict your input. That seems sort of like the programmer didn't want to take the time to have a robust user input parser :D I think the ideal situation for me would be that whenever an entry widget loses focus, the validate() function is called, and I get some kind of visual warning that my entry is incorrect. NOT a dialog box, I hope, but some kind of red warning label next to the entry widget or something. However, this doesn't work for the last entry on the page, because most likely focus will switch straight from the entry to the submit button, but then the whole 'check on submit' thing would catch the error. Basically I don't want to see an entry box that behaves differently than a normal entry box (only accepts integers, for example). -Luke > HTH, > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote OP>> Can some one help me how to add validation : only integers are allowed OP>> and minimum value should be 1. OP>> OP>> timeInterval = Pmw.EntryField(label_text='Time Interval(in OP>> sec.):',labelpos='w',validate = 'numeric') I don;t have PMW installed. I tend to use Tix now that its part of standard Python. However Grayson says this: "validation is [performed by a function which takes as its first argument the entered text and returns one of three standard values... Pmw.OK, Pmw.ERROR, Pmw.PARTIAL" So it seems you need def numeric(val): try: float(val) except ValueError: return Pmw.ERROR else: return Pmw.OK timeinterval = Pmw.EntryField(.validate=numeric) At least that's how I read it, obviously without Pmw I can't try it... >> Also I want to validate date and time? I know that there is a way >> to >> do it but I dont know the exact syntax.. I'd use a similar technique as above. parse the string and try to create a datetime object then handle the exceptions. Luke> it's a lot easier to validate the input when you're using it instead of Luke> trying to restrict their input. Its easier for the programmer but much worse for the user. We should always catch erroneous input as early as possible. Early CGI Web pages were the classic example of late error handling and there is nothing more annoying than filling in a form, submitting it and then being told you filled in a field wrong right at the start! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Query about using Pmw entry widget...
Asrarahmed Kadri wrote: > Hello Folks, > > I am using Pmw mdoule to develop a User interface and in that I am > using entry widget. > > Can some one help me how to add validation : only integers are allowed > and minimum value should be 1. > > timeInterval = Pmw.EntryField(label_text='Time Interval(in > sec.):',labelpos='w',validate = 'numeric') > > Also I want to validate date and time? I know that there is a way to > do it but I dont know the exact syntax.. Asrarahmed - From what I remember (PMW is just an extension of TKinter so this should apply here) it's a lot easier to validate the input when you're using it instead of trying to restrict their input. I.E. when they hit 'submit' give them a little warning saying 'sorry, you can't submit unless you have an integer in field "fieldname" .' That's most likely the easiest way to do this. If you just google for tkinter validate entry you should come up with the other way, IIRC (where they can't input incorrect values). HTH, -Luke. > > -- > To HIM you shall return. > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor