Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python 2 This assignment is to use wxPython to make a shipping calculator. Th

ID: 3890555 • Letter: I

Question

In python 2

This assignment is to use wxPython to make a shipping calculator. The total cost will vary with package weight, shipping speed, and any extras the user might request. The layout should look something like this.

This is the default state of the interface (first radio of each radio button selected, everything else clear). Nothing has been calculated or else the Clear Form button has just been clicked.

The prices for various weights and shipping speeds are shown. (0 - 1.9 lbs add $5, 2-day air shipping add 10.80, etc.).

Your layout does not have to look exactly like this, but it should contain the widgets shown, and it should be sensible so someone using it can easily tell what is happening when a button is clicked.

You'll need these wxPython widgets.

3, TextCtrl widgets; one for name, one for address, and one for city-state-zip

7, radio buttons total, with a group of 3 for package weight, and a group of 4 for package delivery speed

2, check boxes for selecting options

2, buttons, one to trigger calculating the total, the other to reset the form in its default position.

a number of StaticText widgets to make sure everything is labeled clearly

a label at the bottom of the frame where the results will be printed. Since the form has been cleared in the image above you cannot see the summary label until something is actually calculated. (see the image later on this page)

Please start early in the week that this program is due; this gives you plenty of time to ponder how is should work. Moreover, there will be more to ponder as the course progresses. I am glad to help troubleshoot programs, but I go to bed reasonably early and am unlikely to stay up until midnight of the due date.

Shown next is an example calculation for a gift-wrapped 3 lb. package shipped 3-day air. Note the 4-line summary printed at the bottom of the form which includes the content of all three TextCtrl widgets plus the calculated total shipping cost. This summary was printed in a single StaticText widget designated for displaying the results when the Calculate Total button was clicked.

Shipping Calculator x 1 Name Address City, State and Zip Weight Speed O overland $2.75 U 3-day air S615 Options 0-19 lbs. S5 Extra padding. S5 O2-49 lbs. $8 [-] Gift wrapping S8 O5-10 lbs. $12.25 2-day air $10.80 Oovernight $15.25 Calculate TotalClesr Form Shipping Summary

Explanation / Answer

import wx    # including a module

class Test(wx.Frame):    # creating a class

    def __init__(self, parent, id=wx.ID_ANY, title='CheggApp's - Shipping Calculator', pos=wx.DefaultPosition, size=wx.DefaultSize):

        super(Test, self).__init__(parent, id, title, pos, size=(600, 600))

      # creating Gui panel

        self.panel = wx.Panel(self)

        # 3 Text Entry boxes

        self.txt_input0 = wx.TextCtrl(self.panel, pos=(100, 20), size=(220, 22))

        self.txt_input1 = wx.TextCtrl(self.panel, pos=(100, 60), size=(330, 22))

        self.txt_input2 = wx.TextCtrl(self.panel, pos=(100, 100), size=(280, 22))

        # 3 Labels for Name, Address, and City State Zip

        self.lbl0 = wx.StaticText(self.panel, label="Name", pos=(330, 24))

        self.lbl1 = wx.StaticText(self.panel, label="Address", pos=(440, 66))

        self.lbl2 = wx.StaticText(self.panel, label="City, State, Zip Code", pos=(390, 100))

        # 1st GROUP Radio Labels for Weight, Speed, and Options

        self.lbl3 = wx.StaticText(self.panel, label="Weight",pos=(30, 150))

        self.lbl4 = wx.StaticText(self.panel, label="Speed", pos=(180, 150))

        self.lbl5 = wx.StaticText(self.panel, label="Options", pos=(350, 150))

        # 2nd Group Radio Buttons Displayed on Panel

        self.Radio0 = wx.RadioButton(self.panel, label="0 - 1.9 lbs. $5",style = wx.RB_GROUP, pos=(20, 180))

        self.Radio1 = wx.RadioButton(self.panel, label="2 - 4.9 lbs. $8", pos=(20, 200))

        self.Radio2 = wx.RadioButton(self.panel, label="5 - 10 lbs. $12.25", pos=(20, 220))

        self.Radio3 = wx.RadioButton(self.panel, label="overland $2.75", style = wx.RB_GROUP, pos=(170, 180))

        self.Radio4 = wx.RadioButton(self.panel, label="3-day air $6.15", pos=(170, 200))

        self.Radio5 = wx.RadioButton(self.panel, label="2-day air $10.80", pos=(170, 220))

        self.Radio6 = wx.RadioButton(self.panel, label="overnight $15.25", pos=(170, 240))

        # Option Checkboxes

        self.cb0 = wx.CheckBox(self.panel, label="Extra padding. $5", pos=(350, 180))

        self.cb1 = wx.CheckBox(self.panel, label="Gift wrapping. $8", pos=(350, 200))

        # Buttons: Enter, Clear

        self.btn_enter = wx.Button(self.panel, label="Enter", pos=(160, 320))

        self.btn_clear = wx.Button(self.panel, label="Clear Form", pos=(300, 320))

        # Shipping Summary Label

        self.lbl5 = wx.StaticText(self.panel, label="Shipping Summary", pos=(220, 380))

        # Button Events Enter, Clear

        self.btn_enter.Bind(wx.EVT_BUTTON, self.myInfo)

       self.btn_clear.Bind(wx.EVT_BUTTON, self.clear_all)

        # Output Labels info from Name, Address, and State

        self.Line0 = wx.StaticText(self.panel, id = -1, pos=(100, 430), label="", )

        self.Line1 = wx.StaticText(self.panel, id = -1, pos=(100, 450), label="")

        self.Line2 = wx.StaticText(self.panel, id = -1, pos=(100, 470), label="")

        self.Line3 = wx.StaticText(self.panel, id = -1, pos=(100, 490), label="")

    # defining methods for form functionality

    def myInfo(self, event):

        cost = 0

        # creating conditions for Radio button 0 and 3

        if self.Radio0.GetValue() and self.Radio3.GetValue():

            cost = "$7.75"

            if self.cb0.GetValue():

                cost = "$12.75"

            if self.cb1.GetValue():

                cost = "$15.75"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$20.75"

        # creating conditions for Radio button 0 and 4

        if self.Radio0.GetValue() and self.Radio4.GetValue():

            cost = "$11.15"

            if self.cb0.GetValue():

                cost = "$16.15"

            if self.cb1.GetValue():

                cost = "$19.15"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$24.15"

        # creating conditions for Radio button 0 and 5

        if self.Radio0.GetValue() and self.Radio5.GetValue():

            cost = "$15.80"

            if self.cb0.GetValue():

                cost = "$20.80"

            if self.cb1.GetValue():

                cost = "$23.80"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$28.80"

        # creating conditions for Radio button 0 and 6

        if self.Radio0.GetValue() and self.Radio6.GetValue():

            cost = "$20.25"

            if self.cb0.GetValue():

                cost = "$25.25"

            if self.cb1.GetValue():

                cost = "$28.25"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$33.25"

        # creating conditions for Radio button 1 and 3

        if self.Radio1.GetValue() and self.Radio3.GetValue():

            cost = "$10.75"

            if self.cb0.GetValue():

                cost = "$15.75"

            if self.cb1.GetValue():

                cost = "$18.75"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$23.75"

        # creating conditions for Radio button 1 and 4

        if self.Radio1.GetValue() and self.Radio4.GetValue():

            cost = "$14.15"

            if self.cb0.GetValue():

                cost = "$19.15"

            if self.cb1.GetValue():

                cost = "$22.15"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$27.15"

        # creating conditions for Radio button 1 and 5

        if self.Radio1.GetValue() and self.Radio5.GetValue():

            cost = "$18.80"

            if self.cb0.GetValue():

                cost = "$23.80"

            if self.cb1.GetValue():

                cost = "$26.80"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$31.80"

        # creating conditions for Radio button 1 and 6

        if self.Radio1.GetValue() and self.Radio6.GetValue():

            cost = "$23.25"

            if self.cb0.GetValue():

                cost = "$28.25"

            if self.cb1.GetValue():

                cost = "$31.25"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$36.25"

        # creating conditions for Radio button 2 and 3

        if self.Radio2.GetValue() and self.Radio3.GetValue():

            cost = "$15.00"

            if self.cb0.GetValue():

                cost = "$18.00"

            if self.cb1.GetValue():

               cost = "$21.00"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$26.00"

        # creating conditions for Radio button 2 and 4

        if self.Radio2.GetValue() and self.Radio4.GetValue():

            cost = "$18.40"

            if self.cb0.GetValue():

                cost = "$23.40"

            if self.cb1.GetValue():

                cost = "$26.40"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$31.40"

        # creating conditions for Radio button 2 and 5

        if self.Radio2.GetValue() and self.Radio5.GetValue():

            cost = "$23.05"

            if self.cb0.GetValue():

                cost = "$28.05"

            if self.cb1.GetValue():

               cost = "$31.05"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$36.05"

        # creating conditions for Radio button 2 and 6

        if self.Radio2.GetValue() and self.Radio6.GetValue():

            cost = "$27.50"

            if self.cb0.GetValue():

                cost = "$32.50"

            if self.cb1.GetValue():

                cost = "$35.50"

            if self.cb0.GetValue() and self.cb1.GetValue():

                cost = "$40.50"

        # creating object variables

        data0 = self.txt_input0.GetValue()

        data1 = self.txt_input1.GetValue()

        data2 = self.txt_input2.GetValue()

        data3 = cost

        # calling functions with objects

        self.Line0.SetLabel(data0)

        self.Line1.SetLabel(data1)

        self.Line2.SetLabel(data2)

        self.Line3.SetLabel(data3)

   # defining a method to clear data in form

    def clear_all(self, event):

        self.txt_input0.SetValue("")

        self.txt_input1.SetValue("")

        self.txt_input2.SetValue("")

        self.Radio0.SetValue(1)

        self.Radio1.SetValue(0)

        self.Radio2.SetValue(0)

self.Radio3.SetValue(1)

        self.Radio4.SetValue(0)

        self.Radio5.SetValue(0)

        self.Radio6.SetValue(0)

        self.cb0.SetValue(0)

        self.cb1.SetValue(0)

        clsData = ""

        self.Line0.SetLabel(clsData)

        self.Line1.SetLabel(clsData)

        self.Line2.SetLabel(clsData)

        self.Line3.SetLabel(clsData)

if __name__ == "__main__":

    app = wx.App()

    fr = Test(None, -1)

    fr.Show()

    app.MainLoop()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote