Set OK button permanently OK bypassing the dialogue

849 views
Skip to first unread message

d chung

unread,
May 30, 2019, 5:01:31 AM5/30/19
to wxPython-users

I am the programmer with a learner plate. There is a dialogue in the same wxpython programme which I posted on 28 Apr. By calling the dialogue, the original design allows:

         the price and quantity be changed by the cashier,

         the system would check 2 dictionaries for duplicates and adjust the prices and quantity.


Is it possible to set LN 15 OK button to OK permanently? There will be no need for human intervention for each input. To dismantle the dialogue would need a lot of programming beyond my capability now.TKS

onselect.py

Robin Dunn

unread,
May 30, 2019, 12:11:35 PM5/30/19
to wxPython-users
I'm not sure I understand "set LN 15 OK button to OK permanently". Does that mean that you want to display the dialog and then have it exit immediately with an OK status as if the OK button was clicked? That seems fairly terrible from a UX perspective, but if you really want to go that way then the dialog code could do it by calling `self.EndModal(wx.ID_OK)` when it decides it's ready to exit.

--
Robin

d chung

unread,
Jun 22, 2019, 5:23:26 AM6/22/19
to wxPython-users
Dear masters,
I am moving on.
I cut away the dlg part and replaced it with some fixed values.
Everything works fine except that the bar code has been read 248 times and there is no loop in the codes. It was entered only once. What went wrong?

Chung 

Tim Roberts

unread,
Jun 23, 2019, 2:52:05 AM6/23/19
to 'Khanh D Dang' via wxPython-users
On Jun 22, 2019, at 2:23 AM, d chung <domm...@gmail.com> wrote:

I cut away the dlg part and replaced it with some fixed values.
Everything works fine except that the bar code has been read 248 times and there is no loop in the codes. It was entered only once. What went wrong?

You haven't shown us anything about a bar code, so we can't possibly address that.  You did

I do want to point out that this line will never succeed:

            if self.input[2] != 0 and not self.input[2]:

That says "if input 2 is not 0 and input 2 is 0."  It can never be both.  I can't guess what you really intended there.

I'm also concerned about these linesL
                self.m1, self.t1 = '', ''
                self.Language()
                wx.MessageBox(self.m1, self.t1)

Is the "self.Language()" call going to modify the values of self.m1 and self.t1?  If so, that's a very poor design, because you're relying on side effects.  A person looking at your code would have no way to know that the function call is modifying other variables.  If that's looking up a language translation, it would be much better to pass them as parameters:
                m1, t1 = self.Language( '', '' )

Now it's absolutely clear what goes in, and what comes out.
— 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

d chung

unread,
Jun 27, 2019, 12:00:56 AM6/27/19
to wxPython-users

Dear Tim,


I pirated a kind-hearted man’s open-source programme for my own use.

The bar code is entered here.

Line 229 self.search_text = (self.search_bar.GetValue()).split()


The original design was bring up a dialogue. All data would be stored in self.input [ ]. I deleted the dialogue.


Line 258 self.input = [self.selected_info[0],self.selected_info[1],self.selected_info[3],'1']

The barcode has been read 248 times or more although it was entered once.
TKS
Dom

On Thursday, 30 May 2019 17:01:31 UTC+8, d chung wrote:
pnl_pos.py
posdup.jpg

Karsten Hilbert

unread,
Jun 27, 2019, 3:21:32 AM6/27/19
to wxPython-users
On Wed, Jun 26, 2019 at 09:00:56PM -0700, d chung wrote:

> I pirated a kind-hearted man’s open-source programme for my own use.
>
> The bar code is entered here.
>
> Line 229 self.search_text = (self.search_bar.GetValue()).split()
>
>
> The original design was bring up a dialogue. All data would be stored in
> self.input [ ]. I deleted the dialogue.
>
>
> Line 258 self.input =
> [self.selected_info[0],self.selected_info[1],self.selected_info[3],'1']
> The barcode has been read 248 times or more although it was entered once.

Given that description I would look for code which receives a
string from the barcode reader and then erroneously loops
over each of the characters in the string rather than
treating it as a whole.

Since you

> I deleted the dialogue.

you need to be 100% sure what the program logic is.

Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

d chung

unread,
Jun 27, 2019, 3:41:26 AM6/27/19
to wxpytho...@googlegroups.com
Dear Karsten,
Thank you.
I have worked on the wxpython programme for 4 months and understood
the logic very well.The barcode entry and everything was working fine.
I only had the courage to cut away the dlg last week without changing
anything.
regards,
Dom
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to wxpython-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wxpython-users/20190627072122.GA3188%40hermes.hilbert.loc.
> For more options, visit https://groups.google.com/d/optout.
>

Tim Roberts

unread,
Jun 27, 2019, 11:12:37 PM6/27/19
to 'Khanh D Dang' via wxPython-users
On Jun 26, 2019, at 9:00 PM, d chung <domm...@gmail.com> wrote:

The bar code is entered here.

Line 229 self.search_text = (self.search_bar.GetValue()).split()

..

Line 258 self.input = [self.selected_info[0],self.selected_info[1],self.selected_info[3],'1']

The barcode has been read 248 times or more although it was entered once.

Of course, because this is in self.OnSearch, which is bound to the wx.EVT_TEXT event.  EVT_TEXT is fired every time the textbox changes.  If the bar code reader enters 248 characters, the textbox will change 248 times, and the event will be fired 248 times.  If you type "12345", you'll get an EVT_TEXT for "1", and then for "12", and then for "123", and then for "1234", and then for "12345".

Does the barcode reader have any special character at the end of the string?  Or, do you know how long the string is supposed to be?  You can just call evt.Skip and return if self.search_bar.GetValue() is not long enough, or does not have the proper ending character. 

d chung

unread,
Jul 4, 2019, 12:35:51 PM7/4/19
to wxPython-users
Dear masters,
The original design for the search was to look for anything. There was a split( ). I fixed the input to only bar code. The whole world collapsed with the bar code truncated Thank you guys.


On Thursday, 30 May 2019 17:01:31 UTC+8, d chung wrote:
Reply all
Reply to author
Forward
0 new messages