Help with Tkinter Label Widget

Guilherme Polo ggpolo at gmail.com
Thu Sep 4 02:26:27 CEST 2008


On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723 at yahoo.com> wrote:
> Below i've put the code for a program that i wrote.  I need help on lines 384-403.  If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with {$}.  How can i get rid of that?

Come on.. "help on lines 384-403", that is not a good way to look for
help. You are supposed to post some minimal code that demonstrates the
problem.

Anyway, this demonstrates what you are getting (independent of python version):

import Tkinter

label = Tkinter.Label()
label['text'] = '$', 2.0
label.pack()
label.mainloop()

The problem is that you are relying on something that is not supposed
to be done. Note how you are passing a tuple to the "text" option,
while you are actually supposed to pass a single value. You should be
passing something like this instead:

label['text'] = '$%f' % 2.0

>
>
>
> from Tkinter import *
>
> class MyApp:
>    def __init__(self, parent):
>        self.myparent = parent
>
>        self.frame1 = Frame(parent)
>        self.frame1.grid(row=0,  column=0)
>
>        self.frame2 = Frame(parent)
>        self.frame2.grid(row=0,  column=0)
>
>        self.frame3 = Frame(parent)
>        self.frame3.grid(row=0,  column=0)
>
>        self.frame4 = Frame(parent)
>        self.frame4.grid(row=0,  column=0)
>
>        self.a = self.b = self.c = self.d = 0
>
>        self.COG1 = DoubleVar(); self.COG2 = DoubleVar(); self.COG3 = DoubleVar(); self.COG4 = DoubleVar()
>        self.GP1 = DoubleVar(); self.PrInc = DoubleVar(); self.markupPrice = DoubleVar()
>
>        self.tab1Func(1)
>
>    def tab1Func(self, event):
>        self.tab1 = Button(self.frame1, width=14, relief=FLAT, bg="white", text="Multi-Markup")
>        self.tab1.bind("<Button-1>", self.switch1)
>        self.tab1.grid(row=0, column=0)
>
>        self.tab2 = Button(self.frame1, width=14, relief=SUNKEN, bg="dark grey", text="Single Markup")
>        self.tab2.bind("<Button-1>", self.switch2)
>        self.tab2.grid(row=0, column=1)
>
>        self.tab3 = Button(self.frame1, width=14, relief=SUNKEN, bg="dark grey", text="Product Increase")
>        self.tab3.bind("<Button-1>", self.switch3)
>        self.tab3.grid(row=0, column=2)
>
>        self.tab4 = Button(self.frame1, width=14, relief=SUNKEN, bg="dark grey", text="Calculate GP")
>        self.tab4.bind("<Button-1>", self.switch4)
>        self.tab4.grid(row=0, column=3)
>
>        self.tab1Title = Label(self.frame1, font="bold", relief=GROOVE, text="Multi-Markup Calculator")
>        self.tab1Title.grid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)
>
>        self.tab1Entry1 = Entry(self.frame1, textvariable=self.COG1)
>        self.tab1Entry1.select_range(0, END)
>        self.tab1Entry1.bind("<Return>", self.multiMarkup)
>        self.tab1Entry1.focus_force()
>        self.tab1Entry1.grid(padx=2, pady=2, row=2, column=2,  columnspan=2, sticky=W)
>
>        self.tab1Entry1Title= Label(self.frame1, text="Enter COG:")
>        self.tab1Entry1Title.grid(padx=2, pady=2, row=2, column=1, sticky=E)
>
>        self.tab1CalcButton = Button(self.frame1, text="Calculate")
>        self.tab1CalcButton.bind("<Button-1>", self.multiMarkup)
>        self.tab1CalcButton.bind("<Return>", self.multiMarkup)
>        self.tab1CalcButton.grid(padx=2, pady=2, row=3, column=1, columnspan=2, sticky=W+E)
>
>        self.tab1Header = Label(self.frame1, font="bold", relief=GROOVE, text="Gross Profit %       Markup Price")
>        self.tab1Header.grid(padx=2, pady=2, row=4, column=0, columnspan=4, sticky=W+E)
>
>        self.tab1GP1 = Label(self.frame1, width=4,relief=RIDGE, bg="white",  text="5%")
>        self.tab1GP1.grid(padx=2, pady=2, row=5, column=1)
>
>        self.tab1GP2 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="10%")
>        self.tab1GP2.grid(padx=2, pady=2, row=6, column=1)
>
>        self.tab1GP3 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="15%")
>        self.tab1GP3.grid(padx=2, pady=2, row=7, column=1)
>
>        self.tab1GP4 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="18%")
>        self.tab1GP4.grid(padx=2, pady=2, row=8, column=1)
>
>        self.tab1GP5 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="20%")
>        self.tab1GP5.grid(padx=2, pady=2, row=9, column=1)
>
>        self.tab1GP6 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="21%")
>        self.tab1GP6.grid(padx=2, pady=2, row=10, column=1)
>
>        self.tab1GP7 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="22%")
>        self.tab1GP7.grid(padx=2, pady=2, row=11, column=1)
>
>        self.tab1GP8 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="23%")
>        self.tab1GP8.grid(padx=2, pady=2, row=12, column=1)
>
>        self.tab1GP9 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="24%")
>        self.tab1GP9.grid(padx=2, pady=2, row=13, column=1)
>
>        self.tab1GP10 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="25%")
>        self.tab1GP10.grid(padx=2, pady=2, row=14, column=1)
>
>        self.tab1GP11 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="26%")
>        self.tab1GP11.grid(padx=2, pady=2, row=15, column=1)
>
>        self.tab1GP12 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="27%")
>        self.tab1GP12.grid(padx=2, pady=2, row=16, column=1)
>
>        self.tab1GP13 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="28%")
>        self.tab1GP13.grid(padx=2, pady=2, row=17, column=1)
>
>        self.tab1GP14 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="29%")
>        self.tab1GP14.grid(padx=2, pady=2, row=18, column=1)
>
>        self.tab1GP15 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="30%")
>        self.tab1GP15.grid(padx=2, pady=2, row=19, column=1)
>
>        self.tab1GP16 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="31%")
>        self.tab1GP16.grid(padx=2, pady=2, row=20, column=1)
>
>        self.tab1GP17 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="33%")
>        self.tab1GP17.grid(padx=2, pady=2, row=21, column=1)
>
>        self.tab1GP18 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="35%")
>        self.tab1GP18.grid(padx=2, pady=2, row=22, column=1)
>
>        self.tab1GP19 = Label(self.frame1, width=4, relief=RIDGE, bg="white", text="40%")
>        self.tab1GP19.grid(padx=2, pady=2, row=23, column=1)
>
>        self.tab1GP20 = Label(self.frame1, width=4, relief=RIDGE, bg="light grey", text="45%")
>        self.tab1GP20.grid(padx=2, pady=2, row=24, column=1)
>
>        self.tab1Markup1 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup1.grid(padx=2, pady=2, row=5, column=2, sticky=E)
>
>        self.tab1Markup2 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup2.grid(padx=2, pady=2, row=6, column=2, sticky=E)
>
>        self.tab1Markup3 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup3.grid(padx=2, pady=2, row=7, column=2, sticky=E)
>
>        self.tab1Markup4 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup4.grid(padx=2, pady=2, row=8, column=2, sticky=E)
>
>        self.tab1Markup5 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup5.grid(padx=2, pady=2, row=9, column=2, sticky=E)
>
>        self.tab1Markup6 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup6.grid(padx=2, pady=2, row=10, column=2, sticky=E)
>
>        self.tab1Markup7 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup7.grid(padx=2, pady=2, row=11, column=2, sticky=E)
>
>        self.tab1Markup8 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup8.grid(padx=2, pady=2, row=12, column=2, sticky=E)
>
>        self.tab1Markup9 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup9.grid(padx=2, pady=2, row=13, column=2, sticky=E)
>
>        self.tab1Markup10 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup10.grid(padx=2, pady=2, row=14, column=2, sticky=E)
>
>        self.tab1Markup11 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup11.grid(padx=2, pady=2, row=15, column=2, sticky=E)
>
>        self.tab1Markup12 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup12.grid(padx=2, pady=2, row=16, column=2, sticky=E)
>
>        self.tab1Markup13 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup13.grid(padx=2, pady=2, row=17, column=2, sticky=E)
>
>        self.tab1Markup14 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup14.grid(padx=2, pady=2, row=18, column=2, sticky=E)
>
>        self.tab1Markup15 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup15.grid(padx=2, pady=2, row=19, column=2, sticky=E)
>
>        self.tab1Markup16 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup16.grid(padx=2, pady=2, row=20, column=2, sticky=E)
>
>        self.tab1Markup17 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup17.grid(padx=2, pady=2, row=21, column=2, sticky=E)
>
>        self.tab1Markup18 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup18.grid(padx=2, pady=2, row=22, column=2, sticky=E)
>
>        self.tab1Markup19 = Label(self.frame1, width=12, relief=RIDGE, bg="white")
>        self.tab1Markup19.grid(padx=2, pady=2, row=23, column=2, sticky=E)
>
>        self.tab1Markup20 = Label(self.frame1, width=12, relief=RIDGE, bg="light grey")
>        self.tab1Markup20.grid(padx=2, pady=2, row=24, column=2, sticky=E)
>
>    def tab2Func(self, event):
>        self.tab1 = Button(self.frame2, width=14, relief=SUNKEN, bg="dark grey", text="Multi-Markup")
>        self.tab1.bind("<Button-1>", self.switch1)
>        self.tab1.grid(row=0, column=0)
>
>        self.tab2 = Button(self.frame2, width=14, relief=FLAT, bg="white", text="Single Markup")
>        self.tab2.bind("<Button-1>", self.switch2)
>        self.tab2.grid(row=0, column=1)
>
>        self.tab3 = Button(self.frame2, width=14, relief=SUNKEN, bg="dark grey", text="Product Increase")
>        self.tab3.bind("<Button-1>", self.switch3)
>        self.tab3.grid(row=0, column=2)
>
>        self.tab4 = Button(self.frame2, width=14, relief=SUNKEN, bg="dark grey", text="Calculate GP")
>        self.tab4.bind("<Button-1>", self.switch4)
>        self.tab4.grid(row=0, column=3)
>
>        self.tab2Title = Label(self.frame2, font="bold", relief=GROOVE, text="Single Markup Calculator")
>        self.tab2Title.grid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)
>
>        self.tab2Entry1 = Entry(self.frame2, textvariable=self.COG2)
>        self.tab2Entry1.select_range(0, END)
>        self.tab2Entry1.bind("<Return>", self.singleMarkup)
>        self.tab2Entry1.focus_force()
>        self.tab2Entry1.grid(padx=2, pady=2, row=2, column=2,  columnspan=2, sticky=W)
>
>        self.tab2Entry2 = Entry(self.frame2, textvariable=self.GP1)
>        self.tab2Entry2.select_range(0, END)
>        self.tab2Entry2.bind("<Return>", self.singleMarkup)
>        self.tab2Entry2.focus_force()
>        self.tab2Entry2.grid(padx=2, pady=2, row=3, column=2,  columnspan=2, sticky=W)
>
>        self.tab2Entry1Title= Label(self.frame2, text="Enter COG:")
>        self.tab2Entry1Title.grid(padx=2, pady=2, row=2, column=1, sticky=E)
>
>        self.tab2Entry2Title= Label(self.frame2, text="Enter GP %:")
>        self.tab2Entry2Title.grid(padx=2, pady=2, row=3, column=1, sticky=E)
>
>        self.tab2CalcButton = Button(self.frame2, text="Calculate")
>        self.tab2CalcButton.bind("<Button-1>", self.singleMarkup)
>        self.tab2CalcButton.bind("<Return>", self.singleMarkup)
>        self.tab2CalcButton.grid(padx=2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)
>
>        self.tab2Header = Label(self.frame2, font="bold", relief=GROOVE)
>        self.tab2Header["text"] = self.GP1.get(), "%","Markup"
>        self.tab2Header.grid(padx=2, pady=2, row=5, column=0, columnspan=4, sticky=W+E)
>
>        self.tab2Markup1 = Label(self.frame2, width=10, font="bold", relief=GROOVE, bg="white")
>        self.tab2Markup1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)
>
>    def tab3Func(self, event):
>        self.tab1 = Button(self.frame3, width=14, relief=SUNKEN, bg="dark grey", text="Multi-Markup")
>        self.tab1.bind("<Button-1>", self.switch1)
>        self.tab1.grid(row=0, column=0)
>
>        self.tab2 = Button(self.frame3, width=14, relief=SUNKEN, bg="dark grey", text="Single Markup")
>        self.tab2.bind("<Button-1>", self.switch2)
>        self.tab2.grid(row=0, column=1)
>
>        self.tab3 = Button(self.frame3, width=14, relief=FLAT, bg="white", text="Product Increase")
>        self.tab3.bind("<Button-1>", self.switch3)
>        self.tab3.grid(row=0, column=2)
>
>        self.tab4 = Button(self.frame3, width=14, relief=SUNKEN, bg="dark grey", text="Calculate GP")
>        self.tab4.bind("<Button-1>", self.switch4)
>        self.tab4.grid(row=0, column=3)
>
>        self.tabTitle = Label(self.frame3, font="bold",relief=GROOVE, text="Product Increase Calculator")
>        self.tabTitle.grid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)
>
>        self.tab3Entry1 = Entry(self.frame3, textvariable=self.COG3)
>        self.tab3Entry1.select_range(0, END)
>        self.tab3Entry1.bind("<Return>", self.priceIncrease)
>        self.tab3Entry1.focus_force()
>        self.tab3Entry1.grid(padx=2, pady=2, row=2, column=2,  columnspan=2, sticky=W)
>
>        self.tab3Entry2 = Entry(self.frame3, textvariable=self.PrInc)
>        self.tab3Entry2.select_range(0, END)
>        self.tab3Entry2.bind("<Return>", self.priceIncrease)
>        self.tab3Entry2.focus_force()
>        self.tab3Entry2.grid(padx=2, pady=2, row=3, column=2,  columnspan=2, sticky=W)
>
>        self.tab3Entry1Title= Label(self.frame3, text="Enter COG:")
>        self.tab3Entry1Title.grid(padx=2, pady=2, row=2, column=1, sticky=E)
>
>        self.tab3Entry2Title= Label(self.frame3, text="Enter Increase %:")
>        self.tab3Entry2Title.grid(padx=2, pady=2, row=3, column=1, sticky=E)
>
>        self.tab3CalcButton = Button(self.frame3, text="Calculate")
>        self.tab3CalcButton.bind("<Button-1>", self.priceIncrease)
>        self.tab3CalcButton.bind("<Return>", self.priceIncrease)
>        self.tab3CalcButton.grid(padx=2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)
>
>        self.tab3Header = Label(self.frame3, font="bold", relief=GROOVE)
>        self.tab3Header["text"] = self.PrInc.get(), "%","Price","Increase"
>        self.tab3Header.grid(padx=2, pady=2, row=5, column=0, columnspan=4, sticky=W+E)
>
>        self.tab3Markup1 = Label(self.frame3, width=10, font="bold", relief=GROOVE, bg="white")
>        self.tab3Markup1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)
>
>    def tab4Func(self, event):
>        self.tab1 = Button(self.frame4, width=14, relief=SUNKEN, bg="dark grey", text="Multi-Markup")
>        self.tab1.bind("<Button-1>", self.switch1)
>        self.tab1.grid(row=0, column=0)
>
>        self.tab2 = Button(self.frame4, width=14, relief=SUNKEN, bg="dark grey", text="Single Markup")
>        self.tab2.bind("<Button-1>", self.switch2)
>        self.tab2.grid(row=0, column=1)
>
>        self.tab3 = Button(self.frame4, width=14, relief=SUNKEN, bg="dark grey", text="Product Increase")
>        self.tab3.bind("<Button-1>", self.switch3)
>        self.tab3.grid(row=0, column=2)
>
>        self.tab4 = Button(self.frame4, width=14, relief=FLAT, bg="white", text="Calculate GP")
>        self.tab4.bind("<Button-1>", self.switch4)
>        self.tab4.grid(row=0, column=3)
>
>        self.tabTitle = Label(self.frame4, font="bold",relief=GROOVE, text="Calculate GP")
>        self.tabTitle.grid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)
>
>        self.tab4Entry1 = Entry(self.frame4, textvariable=self.COG4)
>        self.tab4Entry1.select_range(0, END)
>        self.tab4Entry1.bind("<Return>", self.GpCalc)
>        self.tab4Entry1.focus_force()
>        self.tab4Entry1.grid(padx=2, pady=2, row=2, column=2,  columnspan=2, sticky=W)
>
>        self.tab4Entry2 = Entry(self.frame4, textvariable=self.markupPrice)
>        self.tab4Entry2.select_range(0, END)
>        self.tab4Entry2.bind("<Return>", self.GpCalc)
>        self.tab4Entry2.focus_force()
>        self.tab4Entry2.grid(padx=2, pady=2, row=3, column=2,  columnspan=2, sticky=W)
>
>        self.tab4Entry1Title= Label(self.frame4, text="Enter COG:")
>        self.tab4Entry1Title.grid(padx=2, pady=2, row=2, column=1, sticky=E)
>
>        self.tab4Entry2Title= Label(self.frame4, text="Enter Markup $:")
>        self.tab4Entry2Title.grid(padx=2, pady=2, row=3, column=1, sticky=E)
>
>        self.tab4CalcButton = Button(self.frame4, text="Calculate")
>        self.tab4CalcButton.bind("<Button-1>", self.GpCalc)
>        self.tab4CalcButton.bind("<Return>", self.GpCalc)
>        self.tab4CalcButton.grid(padx=2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)
>
>        self.tab4Header = Label(self.frame4, font="bold", relief=GROOVE)
>        self.tab4Header["text"] = "Gross Profit"
>        self.tab4Header.grid(padx=2, pady=2, row=5, column=0, columnspan=4, sticky=W+E)
>
>        self.tab4Markup1 = Label(self.frame4, width=10, font="bold", relief=GROOVE, bg="white")
>        self.tab4Markup1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)
>
>    def switch1(self, event):
>        self.frame1.grid(sticky=N+S+E+W)
>        self.frame2.grid_forget()
>        self.frame3.grid_forget()
>        self.frame4.grid_forget()
>        self.tab1Entry1.focus_force()
>        self.tab1Entry1.select_range(0, END)
>
>
>    def switch2(self, event):
>        if self.b == 0:
>            self.tab2Func(1)
>            self.b = 1
>        self.frame1.grid_forget()
>        self.frame2.grid(sticky=N+S+E+W)
>        self.frame3.grid_forget()
>        self.frame4.grid_forget()
>        self.tab2Entry1.focus_force()
>        self.tab2Entry1.select_range(0, END)
>
>    def switch3(self, event):
>        if self.c == 0:
>            self.tab3Func(1)
>            self.c = 1
>        self.frame1.grid_forget()
>        self.frame2.grid_forget()
>        self.frame3.grid(sticky=N+S+E+W)
>        self.frame4.grid_forget()
>        self.tab3Entry1.focus_force()
>        self.tab3Entry1.select_range(0, END)
>
>    def switch4(self, event):
>        if self.d == 0:
>            self.tab4Func(1)
>            self.d = 1
>        self.frame1.grid_forget()
>        self.frame2.grid_forget()
>        self.frame3.grid_forget()
>        self.frame4.grid(sticky=N+S+E+W)
>        self.tab4Entry1.focus_force()
>        self.tab4Entry1.select_range(0, END)
>
>    def multiMarkup(self, event):
>        try:
>            value = self.COG1.get()
>        except ValueError:
>            self.COG1 = DoubleVar()
>            self.tab1Entry1["textvariable"] = self.COG1
>
>        self.tab1Entry1.select_range(0, END)
>
>        self.tab1Markup1["text"] = "$", round(self.COG1.get()/.95, 2)
>        self.tab1Markup2["text"] = "$", round(self.COG1.get()/.90, 2)
>        self.tab1Markup3["text"] = "$", round(self.COG1.get()/.85, 2)
>        self.tab1Markup4["text"] = "$", round(self.COG1.get()/.82, 2)
>        self.tab1Markup5["text"] = "$", round(self.COG1.get()/.80, 2)
>        self.tab1Markup6["text"] = "$", round(self.COG1.get()/.79, 2)
>        self.tab1Markup7["text"] = "$", round(self.COG1.get()/.78, 2)
>        self.tab1Markup8["text"] = "$", round(self.COG1.get()/.77, 2)
>        self.tab1Markup9["text"] = "$", round(self.COG1.get()/.76, 2)
>        self.tab1Markup10["text"] = "$", round(self.COG1.get()/.75, 2)
>        self.tab1Markup11["text"] = "$", round(self.COG1.get()/.74, 2)
>        self.tab1Markup12["text"] = "$", round(self.COG1.get()/.73, 2)
>        self.tab1Markup13["text"] = "$", round(self.COG1.get()/.72, 2)
>        self.tab1Markup14["text"] = "$", round(self.COG1.get()/.71, 2)
>        self.tab1Markup15["text"] = "$", round(self.COG1.get()/.70, 2)
>        self.tab1Markup16["text"] = "$", round(self.COG1.get()/.69, 2)
>        self.tab1Markup17["text"] = "$", round(self.COG1.get()/.67, 2)
>        self.tab1Markup18["text"] = "$", round(self.COG1.get()/.65, 2)
>        self.tab1Markup19["text"] = "$", round(self.COG1.get()/.60, 2)
>        self.tab1Markup20["text"] = "$", round(self.COG1.get()/.55, 2)
>
>    def singleMarkup(self, event):
>        try:
>            value = self.COG2.get()
>        except ValueError:
>            self.COG2 = DoubleVar()
>            self.tab2Entry1["textvariable"] = self.COG2
>
>        try:
>            value = self.GP1.get()
>        except ValueError:
>            self.GP1 = DoubleVar()
>            self.tab2Entry2["textvariable"] = self.GP1
>
>        self.tab2Entry1.focus_force()
>        self.tab2Entry1.select_range(0, END)
>
>        GP = 1 - (round((self.GP1.get()/100),2))
>
>        self.tab2Markup1["text"] = "$",round(self.COG2.get()/GP, 2)
>        self.tab2Header["text"] = self.GP1.get(), "%","Markup"
>
>    def priceIncrease(self, event):
>        try:
>            value = self.COG3.get()
>        except ValueError:
>            self.COG3 = DoubleVar()
>            self.tab3Entry1["textvariable"] = self.COG3
>
>        try:
>            value = self.PrInc.get()
>        except ValueError:
>            self.PrInc = DoubleVar()
>            self.tab3Entry2["textvariable"] = self.PrInc
>
>        self.tab3Entry1.focus_force()
>        self.tab3Entry1.select_range(0, END)
>
>        increase = 1+(self.PrInc.get()/100)
>
>        self.tab3Markup1["text"] = "$",round((self.COG3.get()*increase),2)
>        self.tab3Header["text"] = self.PrInc.get(), "%","Price","Increase"
>
>    def GpCalc(self, event):
>        try:
>            value = self.COG4.get()
>        except ValueError:
>            self.COG4 = DoubleVar()
>            self.tab4Entry1["textvariable"] = self.COG4
>
>        try:
>            value = self.markupPrice.get()
>        except ValueError:
>            self.markupPrice = DoubleVar()
>            self.tab4Entry2["textvariable"] = self.markupPrice
>
>        self.tab4Entry1.focus_force()
>        self.tab4Entry1.select_range(0, END)
>
>        COG4 = self.COG4.get()
>        markup = self.markupPrice.get()
>
>        if COG4==0.0 or markup==0.0:
>            self.tab4Markup1["text"] = ""
>        else:
>            GP = 100*(1-(self.COG4.get()/self.markupPrice.get()))
>            self.tab4Markup1["text"] = round(GP, 2),"%"
>
>
> root = Tk()
> myapp = MyApp(root)
> root.mainloop()
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
-- Guilherme H. Polo Goncalves



More information about the Python-list mailing list