473,790 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Help with Tkinter Label Widget

On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <ke*****@yahoo. comwrote:
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.gri d(row=0, column=0)

self.frame2 = Frame(parent)
self.frame2.gri d(row=0, column=0)

self.frame3 = Frame(parent)
self.frame3.gri d(row=0, column=0)

self.frame4 = Frame(parent)
self.frame4.gri d(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.markupPric e = DoubleVar()

self.tab1Func(1 )

def tab1Func(self, event):
self.tab1 = Button(self.fra me1, 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.fra me1, 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.fra me1, 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.fra me1, 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.fram e1, 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.fram e1, textvariable=se lf.COG1)
self.tab1Entry1 .select_range(0 , END)
self.tab1Entry1 .bind("<Return> ", self.multiMarku p)
self.tab1Entry1 .focus_force()
self.tab1Entry1 .grid(padx=2, pady=2, row=2, column=2, columnspan=2, sticky=W)

self.tab1Entry1 Title= Label(self.fram e1, text="Enter COG:")
self.tab1Entry1 Title.grid(padx =2, pady=2, row=2, column=1, sticky=E)

self.tab1CalcBu tton = Button(self.fra me1, text="Calculate ")
self.tab1CalcBu tton.bind("<But ton-1>", self.multiMarku p)
self.tab1CalcBu tton.bind("<Ret urn>", self.multiMarku p)
self.tab1CalcBu tton.grid(padx= 2, pady=2, row=3, column=1, columnspan=2, sticky=W+E)

self.tab1Header = Label(self.fram e1, 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.fram e1, width=4,relief= RIDGE, bg="white", text="5%")
self.tab1GP1.gr id(padx=2, pady=2, row=5, column=1)

self.tab1GP2 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="10%")
self.tab1GP2.gr id(padx=2, pady=2, row=6, column=1)

self.tab1GP3 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="15%")
self.tab1GP3.gr id(padx=2, pady=2, row=7, column=1)

self.tab1GP4 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="18%")
self.tab1GP4.gr id(padx=2, pady=2, row=8, column=1)

self.tab1GP5 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="20%")
self.tab1GP5.gr id(padx=2, pady=2, row=9, column=1)

self.tab1GP6 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="21%")
self.tab1GP6.gr id(padx=2, pady=2, row=10, column=1)

self.tab1GP7 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="22%")
self.tab1GP7.gr id(padx=2, pady=2, row=11, column=1)

self.tab1GP8 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="23%")
self.tab1GP8.gr id(padx=2, pady=2, row=12, column=1)

self.tab1GP9 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="24%")
self.tab1GP9.gr id(padx=2, pady=2, row=13, column=1)

self.tab1GP10 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="25%")
self.tab1GP10.g rid(padx=2, pady=2, row=14, column=1)

self.tab1GP11 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="26%")
self.tab1GP11.g rid(padx=2, pady=2, row=15, column=1)

self.tab1GP12 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="27%")
self.tab1GP12.g rid(padx=2, pady=2, row=16, column=1)

self.tab1GP13 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="28%")
self.tab1GP13.g rid(padx=2, pady=2, row=17, column=1)

self.tab1GP14 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="29%")
self.tab1GP14.g rid(padx=2, pady=2, row=18, column=1)

self.tab1GP15 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="30%")
self.tab1GP15.g rid(padx=2, pady=2, row=19, column=1)

self.tab1GP16 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="31%")
self.tab1GP16.g rid(padx=2, pady=2, row=20, column=1)

self.tab1GP17 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="33%")
self.tab1GP17.g rid(padx=2, pady=2, row=21, column=1)

self.tab1GP18 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="35%")
self.tab1GP18.g rid(padx=2, pady=2, row=22, column=1)

self.tab1GP19 = Label(self.fram e1, width=4, relief=RIDGE, bg="white", text="40%")
self.tab1GP19.g rid(padx=2, pady=2, row=23, column=1)

self.tab1GP20 = Label(self.fram e1, width=4, relief=RIDGE, bg="light grey", text="45%")
self.tab1GP20.g rid(padx=2, pady=2, row=24, column=1)

self.tab1Markup 1 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 1.grid(padx=2, pady=2, row=5, column=2, sticky=E)

self.tab1Markup 2 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 2.grid(padx=2, pady=2, row=6, column=2, sticky=E)

self.tab1Markup 3 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 3.grid(padx=2, pady=2, row=7, column=2, sticky=E)

self.tab1Markup 4 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 4.grid(padx=2, pady=2, row=8, column=2, sticky=E)

self.tab1Markup 5 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 5.grid(padx=2, pady=2, row=9, column=2, sticky=E)

self.tab1Markup 6 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 6.grid(padx=2, pady=2, row=10, column=2, sticky=E)

self.tab1Markup 7 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 7.grid(padx=2, pady=2, row=11, column=2, sticky=E)

self.tab1Markup 8 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 8.grid(padx=2, pady=2, row=12, column=2, sticky=E)

self.tab1Markup 9 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 9.grid(padx=2, pady=2, row=13, column=2, sticky=E)

self.tab1Markup 10 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 10.grid(padx=2, pady=2, row=14, column=2, sticky=E)

self.tab1Markup 11 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 11.grid(padx=2, pady=2, row=15, column=2, sticky=E)

self.tab1Markup 12 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 12.grid(padx=2, pady=2, row=16, column=2, sticky=E)

self.tab1Markup 13 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 13.grid(padx=2, pady=2, row=17, column=2, sticky=E)

self.tab1Markup 14 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 14.grid(padx=2, pady=2, row=18, column=2, sticky=E)

self.tab1Markup 15 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 15.grid(padx=2, pady=2, row=19, column=2, sticky=E)

self.tab1Markup 16 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 16.grid(padx=2, pady=2, row=20, column=2, sticky=E)

self.tab1Markup 17 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 17.grid(padx=2, pady=2, row=21, column=2, sticky=E)

self.tab1Markup 18 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 18.grid(padx=2, pady=2, row=22, column=2, sticky=E)

self.tab1Markup 19 = Label(self.fram e1, width=12, relief=RIDGE, bg="white")
self.tab1Markup 19.grid(padx=2, pady=2, row=23, column=2, sticky=E)

self.tab1Markup 20 = Label(self.fram e1, width=12, relief=RIDGE, bg="light grey")
self.tab1Markup 20.grid(padx=2, pady=2, row=24, column=2, sticky=E)

def tab2Func(self, event):
self.tab1 = Button(self.fra me2, 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.fra me2, 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.fra me2, 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.fra me2, 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.fram e2, 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.fram e2, textvariable=se lf.COG2)
self.tab2Entry1 .select_range(0 , END)
self.tab2Entry1 .bind("<Return> ", self.singleMark up)
self.tab2Entry1 .focus_force()
self.tab2Entry1 .grid(padx=2, pady=2, row=2, column=2, columnspan=2, sticky=W)

self.tab2Entry2 = Entry(self.fram e2, textvariable=se lf.GP1)
self.tab2Entry2 .select_range(0 , END)
self.tab2Entry2 .bind("<Return> ", self.singleMark up)
self.tab2Entry2 .focus_force()
self.tab2Entry2 .grid(padx=2, pady=2, row=3, column=2, columnspan=2, sticky=W)

self.tab2Entry1 Title= Label(self.fram e2, text="Enter COG:")
self.tab2Entry1 Title.grid(padx =2, pady=2, row=2, column=1, sticky=E)

self.tab2Entry2 Title= Label(self.fram e2, text="Enter GP %:")
self.tab2Entry2 Title.grid(padx =2, pady=2, row=3, column=1, sticky=E)

self.tab2CalcBu tton = Button(self.fra me2, text="Calculate ")
self.tab2CalcBu tton.bind("<But ton-1>", self.singleMark up)
self.tab2CalcBu tton.bind("<Ret urn>", self.singleMark up)
self.tab2CalcBu tton.grid(padx= 2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)

self.tab2Header = Label(self.fram e2, 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.tab2Markup 1 = Label(self.fram e2, width=10, font="bold", relief=GROOVE, bg="white")
self.tab2Markup 1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)

def tab3Func(self, event):
self.tab1 = Button(self.fra me3, 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.fra me3, 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.fra me3, 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.fra me3, 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.fram e3, font="bold",rel ief=GROOVE, text="Product Increase Calculator")
self.tabTitle.g rid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)

self.tab3Entry1 = Entry(self.fram e3, textvariable=se lf.COG3)
self.tab3Entry1 .select_range(0 , END)
self.tab3Entry1 .bind("<Return> ", self.priceIncre ase)
self.tab3Entry1 .focus_force()
self.tab3Entry1 .grid(padx=2, pady=2, row=2, column=2, columnspan=2, sticky=W)

self.tab3Entry2 = Entry(self.fram e3, textvariable=se lf.PrInc)
self.tab3Entry2 .select_range(0 , END)
self.tab3Entry2 .bind("<Return> ", self.priceIncre ase)
self.tab3Entry2 .focus_force()
self.tab3Entry2 .grid(padx=2, pady=2, row=3, column=2, columnspan=2, sticky=W)

self.tab3Entry1 Title= Label(self.fram e3, text="Enter COG:")
self.tab3Entry1 Title.grid(padx =2, pady=2, row=2, column=1, sticky=E)

self.tab3Entry2 Title= Label(self.fram e3, text="Enter Increase %:")
self.tab3Entry2 Title.grid(padx =2, pady=2, row=3, column=1, sticky=E)

self.tab3CalcBu tton = Button(self.fra me3, text="Calculate ")
self.tab3CalcBu tton.bind("<But ton-1>", self.priceIncre ase)
self.tab3CalcBu tton.bind("<Ret urn>", self.priceIncre ase)
self.tab3CalcBu tton.grid(padx= 2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)

self.tab3Header = Label(self.fram e3, font="bold", relief=GROOVE)
self.tab3Header["text"] = self.PrInc.get( ), "%","Price","In crease"
self.tab3Header .grid(padx=2, pady=2, row=5, column=0, columnspan=4, sticky=W+E)

self.tab3Markup 1 = Label(self.fram e3, width=10, font="bold", relief=GROOVE, bg="white")
self.tab3Markup 1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)

def tab4Func(self, event):
self.tab1 = Button(self.fra me4, 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.fra me4, 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.fra me4, 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.fra me4, 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.fram e4, font="bold",rel ief=GROOVE, text="Calculate GP")
self.tabTitle.g rid(pady=1, row=1, column=0, columnspan=4, sticky=W+E)

self.tab4Entry1 = Entry(self.fram e4, textvariable=se lf.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.fram e4, textvariable=se lf.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.tab4Entry1 Title= Label(self.fram e4, text="Enter COG:")
self.tab4Entry1 Title.grid(padx =2, pady=2, row=2, column=1, sticky=E)

self.tab4Entry2 Title= Label(self.fram e4, text="Enter Markup $:")
self.tab4Entry2 Title.grid(padx =2, pady=2, row=3, column=1, sticky=E)

self.tab4CalcBu tton = Button(self.fra me4, text="Calculate ")
self.tab4CalcBu tton.bind("<But ton-1>", self.GpCalc)
self.tab4CalcBu tton.bind("<Ret urn>", self.GpCalc)
self.tab4CalcBu tton.grid(padx= 2, pady=2, row=4, column=1, columnspan=2, sticky=W+E)

self.tab4Header = Label(self.fram e4, 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.tab4Markup 1 = Label(self.fram e4, width=10, font="bold", relief=GROOVE, bg="white")
self.tab4Markup 1.grid(padx=2, pady=2, row=6, column=1, columnspan=2)

def switch1(self, event):
self.frame1.gri d(sticky=N+S+E+ W)
self.frame2.gri d_forget()
self.frame3.gri d_forget()
self.frame4.gri d_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.gri d_forget()
self.frame2.gri d(sticky=N+S+E+ W)
self.frame3.gri d_forget()
self.frame4.gri d_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.gri d_forget()
self.frame2.gri d_forget()
self.frame3.gri d(sticky=N+S+E+ W)
self.frame4.gri d_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.gri d_forget()
self.frame2.gri d_forget()
self.frame3.gri d_forget()
self.frame4.gri d(sticky=N+S+E+ W)
self.tab4Entry1 .focus_force()
self.tab4Entry1 .select_range(0 , END)

def multiMarkup(sel f, event):
try:
value = self.COG1.get()
except ValueError:
self.COG1 = DoubleVar()
self.tab1Entry1["textvariab le"] = self.COG1

self.tab1Entry1 .select_range(0 , END)

self.tab1Markup 1["text"] = "$", round(self.COG1 .get()/.95, 2)
self.tab1Markup 2["text"] = "$", round(self.COG1 .get()/.90, 2)
self.tab1Markup 3["text"] = "$", round(self.COG1 .get()/.85, 2)
self.tab1Markup 4["text"] = "$", round(self.COG1 .get()/.82, 2)
self.tab1Markup 5["text"] = "$", round(self.COG1 .get()/.80, 2)
self.tab1Markup 6["text"] = "$", round(self.COG1 .get()/.79, 2)
self.tab1Markup 7["text"] = "$", round(self.COG1 .get()/.78, 2)
self.tab1Markup 8["text"] = "$", round(self.COG1 .get()/.77, 2)
self.tab1Markup 9["text"] = "$", round(self.COG1 .get()/.76, 2)
self.tab1Markup 10["text"] = "$", round(self.COG1 .get()/.75, 2)
self.tab1Markup 11["text"] = "$", round(self.COG1 .get()/.74, 2)
self.tab1Markup 12["text"] = "$", round(self.COG1 .get()/.73, 2)
self.tab1Markup 13["text"] = "$", round(self.COG1 .get()/.72, 2)
self.tab1Markup 14["text"] = "$", round(self.COG1 .get()/.71, 2)
self.tab1Markup 15["text"] = "$", round(self.COG1 .get()/.70, 2)
self.tab1Markup 16["text"] = "$", round(self.COG1 .get()/.69, 2)
self.tab1Markup 17["text"] = "$", round(self.COG1 .get()/.67, 2)
self.tab1Markup 18["text"] = "$", round(self.COG1 .get()/.65, 2)
self.tab1Markup 19["text"] = "$", round(self.COG1 .get()/.60, 2)
self.tab1Markup 20["text"] = "$", round(self.COG1 .get()/.55, 2)

def singleMarkup(se lf, event):
try:
value = self.COG2.get()
except ValueError:
self.COG2 = DoubleVar()
self.tab2Entry1["textvariab le"] = self.COG2

try:
value = self.GP1.get()
except ValueError:
self.GP1 = DoubleVar()
self.tab2Entry2["textvariab le"] = self.GP1

self.tab2Entry1 .focus_force()
self.tab2Entry1 .select_range(0 , END)

GP = 1 - (round((self.GP 1.get()/100),2))

self.tab2Markup 1["text"] = "$",round(self. COG2.get()/GP, 2)
self.tab2Header["text"] = self.GP1.get(), "%","Markup "

def priceIncrease(s elf, event):
try:
value = self.COG3.get()
except ValueError:
self.COG3 = DoubleVar()
self.tab3Entry1["textvariab le"] = self.COG3

try:
value = self.PrInc.get( )
except ValueError:
self.PrInc = DoubleVar()
self.tab3Entry2["textvariab le"] = self.PrInc

self.tab3Entry1 .focus_force()
self.tab3Entry1 .select_range(0 , END)

increase = 1+(self.PrInc.g et()/100)

self.tab3Markup 1["text"] = "$",round((self .COG3.get()*inc rease),2)
self.tab3Header["text"] = self.PrInc.get( ), "%","Price","In crease"

def GpCalc(self, event):
try:
value = self.COG4.get()
except ValueError:
self.COG4 = DoubleVar()
self.tab4Entry1["textvariab le"] = self.COG4

try:
value = self.markupPric e.get()
except ValueError:
self.markupPric e = DoubleVar()
self.tab4Entry2["textvariab le"] = self.markupPric e

self.tab4Entry1 .focus_force()
self.tab4Entry1 .select_range(0 , END)

COG4 = self.COG4.get()
markup = self.markupPric e.get()

if COG4==0.0 or markup==0.0:
self.tab4Markup 1["text"] = ""
else:
GP = 100*(1-(self.COG4.get( )/self.markupPric e.get()))
self.tab4Markup 1["text"] = round(GP, 2),"%"
root = Tk()
myapp = MyApp(root)
root.mainloop()

--
http://mail.python.org/mailman/listinfo/python-list


--
-- Guilherme H. Polo Goncalves
Sep 4 '08 #1
0 1513

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1678
by: Sebastien Aubry | last post by:
Hello, I am trying to embed a Tkinter widget (TkZinc, http://www.tkzinc.org) inside a PyGtk HMI. A guru gave me this advice: "I think you can do some magic using the XID of the Tkinter widget's window to produce a GdkWindow" I wrote this little program, which gets the XID of the Tkinter window and uses it to create a gtk.gdk.Window.
3
2151
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I can't type! See example code below. Is this just me doing something really really silly, or is...
0
2360
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo widget, but for some reason the text is invisible on cygwin). After I close the Toplevel widget, all of the menus in my app behave as though they have no contents to them, i..e I can press on the File menu button, and see it depress, but the Exit...
3
2582
by: vedran_dekovic | last post by:
Hi, I need help about Tkinter listbox widget.I want,when somebody click on any item(file) in Listbox,then in new Label widget text must be selected item from server. my program (wrong example): import ftputil import Tkinter root=Tkinter.Tk()
4
5449
by: BartlebyScrivener | last post by:
Using Python on Debian Etch. What is the best way to paste a block of text in at the command prompt. I'm trying something like: Quote = raw_input("Paste quote here: ") Which works great for one line of text with a single newline. It gets
7
2319
by: =?iso-8859-1?q?Xavier_B=E9rard?= | last post by:
Hello everyone, I am wondering if there is a way to use custom drawing in Tkinter. I've been using it for few months, and all I know about custom drawing is to draw directly on a Canvas with such methods as "create_line", "create_rectangle", etc. Now, the problem, is that I have already plenty of widgets on my screen. I just want to draw over them, which is a bit difficult in my comprehension of things.
1
2364
by: vijayca | last post by:
my python installation is:Active python 2.5.1 i am using Red Hat Linux i have the Tkinter module installed but any simple script produces an error.... script: from Tkinter import Label widget = Label(None, text='Hello GUI world!') widget.pack() widget.mainloop()
1
3663
by: Kevin Walzer | last post by:
I'm trying to toggle the visibility of a Tkinter widget using pack_forget(), and I'm running into unexpected behavior. The widget "hides" correctly, but does not become visible again. My sample code is below: ---- from Tkinter import * root = Tk()
0
1144
by: Helmut Jarausch | last post by:
Hi, I'd like to bind the '<Return>' event to a function which does some calculations (like a database lookup) and then invoke tk_focusNext. I get an exception as many others have reported earlier, see http://bugs.python.org/issue799428 There has even a patch been suggested. Why hasn't it been fixed - I haven't seen a fix. The problem can be reproduced by the following tiny script
0
3990
by: nicstel | last post by:
Hello. My script run fine within python but not in my program(SDS/2 wich is a software like Autocad). The problem is I got an error when the time comes to read the line14 to 19. (Source code come from Tkinter.py) class Tk(Misc, Wm): """Toplevel widget of Tk which represents mostly the main window of an appliation. It has an associated Tcl interpreter.""" _w = '.' def __init__(self, screenName=None, baseName=None,...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.