From alexnbryan at gmail.com Wed Jul 2 07:25:51 2008 From: alexnbryan at gmail.com (Alexnb) Date: Tue, 1 Jul 2008 22:25:51 -0700 (PDT) Subject: [Tkinter-discuss] Clearing out a Frame Message-ID: <18230530.post@talk.nabble.com> I have an app that has a base frame, and some other frames inside of that base frame. My question is if there is some way to clear out the base frame. Meaning leaving an empty baseframe. See I have a function that pulls up frames inside that base frame. The problem comes when I hit a button(this button is the button that first shows the frames inside the base frame, basically you click it and the internal frames show up.) and then I hit it again, I get some weird stuff. Okay, this is getting really complicated. I really just want to know if I can clear out a frame, and still be able to fill it back up again. If you want ot uunderstand further I'll post the code at the bottom and just run it, then hit the "Word List" button, then hit it again, you'll see what I am talking about. Here's the code: from Tkinter import* class App: def __init__(self, parent): self.parent = parent self.parent.geometry("500x250") #----------------------------Contstants for Buttons------------ button_padx = "2m" button_pady = "1m" #--------------------------end constants----------------------- self.baseContainer = Frame(self.parent) self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) #the Top Frame with all the buttons self.topContainer = Frame(self.baseContainer) self.topContainer.pack(side=TOP, expand=YES, ipadx=5, ipady=5, fill = X, anchor=N) #the frame with the main things the user will use self.mainContainer = Frame(self.baseContainer) self.mainContainer.pack(side=TOP, ipadx = 5, ipady = 5, anchor=CENTER, expand=YES, fill=BOTH) #---------------------Top Buttons----------------------------- self.defineButton = Button(self.topContainer, padx=button_padx, pady=button_pady) self.defineButton.configure(text="Word List", command=self.define_Frame) self.defineButton.pack(side=LEFT) #-------------------------------------------------------------- def define_Frame(self): myMessage="Please type in all the words that you would like to define" Label(self.mainContainer, text=myMessage, justify=LEFT).pack(side=TOP, anchor=N) #The LEFT Frame that comes up when you hit define self.defineContainer1 = Frame(self.mainContainer) self.defineContainer1.pack(side=LEFT, ipadx = 5, ipady = 5, expand=YES, fill=BOTH) #The RIGHT Frame that comes up when you hit define self.defineContainer2 = Frame(self.mainContainer) self.defineContainer2.pack(side=LEFT, ipadx=5, ipady=5, expand=YES, fill=BOTH) #This frame is where the define button goes self.defineButtonF = Frame(self.baseContainer) self.defineButtonF.pack(side=TOP, anchor=S, ipady=5, ipadx=5, fill=BOTH, expand=NO) #----------------------------Contstants for Buttons------------ self.button_padx = "2m" self.button_pady = "1m" #--------------------------end constants----------------------- #----------------------STUFF FOR DEFINE FRAME------------------------- self.e1 = Entry(self.defineContainer1) self.e1.pack(fill=X) self.e2 = Entry(self.defineContainer1) self.e2.pack(fill=X) self.e3 = Entry(self.defineContainer1) self.e3.pack(fill=X) self.e4 = Entry(self.defineContainer1) self.e4.pack(fill=X) self.e5 = Entry(self.defineContainer1) self.e5.pack(fill=X) self.e6 = Entry(self.defineContainer1) self.e6.pack(fill=X) self.e7 = Entry(self.defineContainer1) self.e7.pack(fill=X) self.e8 = Entry(self.defineContainer2) self.e8.pack(fill=X) self.e9 = Entry(self.defineContainer2) self.e9.pack(fill=X) self.e10 = Entry(self.defineContainer2) self.e10.pack(fill=X) self.e11 = Entry(self.defineContainer2) self.e11.pack(fill=X) self.e12 = Entry(self.defineContainer2) self.e12.pack(fill=X) self.e13 = Entry(self.defineContainer2) self.e13.pack(fill=X) self.e14 = Entry(self.defineContainer2,) self.e14.pack(fill=X) #-------------------------Define Button Stuff------------------------- #Define it button self.defineIt= Button(self.defineButtonF, command=self.DefineClick) self.defineIt.configure(text="Define!") self.defineIt.bind("", self.DefineClickE) self.defineIt.pack(side=TOP, anchor=N, padx=self.button_padx, pady=self.button_pady,) def DefineClickE(self, event): print "Define was hit with Enter" self.DefineClick() def DefineClick(self): print "Define was activated." #----------------------------end define Button Stuff---------------------- root = Tk() app = App(root) root.mainloop() -- View this message in context: http://www.nabble.com/Clearing-out-a-Frame-tp18230530p18230530.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jmcmonagle at velseis.com.au Wed Jul 2 08:03:27 2008 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Wed, 02 Jul 2008 16:03:27 +1000 Subject: [Tkinter-discuss] Clearing out a Frame In-Reply-To: <18230530.post@talk.nabble.com> References: <18230530.post@talk.nabble.com> Message-ID: <486B1A2F.8040607@velseis.com.au> Alexnb wrote: > I have an app that has a base frame, and some other frames inside of that > base frame. My question is if there is some way to clear out the base frame. > Meaning leaving an empty baseframe. See I have a function that pulls up > frames inside that base frame. The problem comes when I hit a button(this > button is the button that first shows the frames inside the base frame, > basically you click it and the internal frames show up.) and then I hit it > again, I get some weird stuff. Okay, this is getting really complicated. I > really just want to know if I can clear out a frame, and still be able to > fill it back up again. If you want ot uunderstand further I'll post the code > at the bottom and just run it, then hit the "Word List" button, then hit it > again, you'll see what I am talking about. > Make a list of the widgets when they are created and destroy the widgets in this list whenever you have to re-define them. Regards, John Your code with mods: from Tkinter import * class App: def __init__(self, parent): self.parent = parent self.parent.geometry("500x250") self.list_of_widgets = [] #----------------------------Contstants for Buttons------------ button_padx = "2m" button_pady = "1m" #--------------------------end constants----------------------- self.baseContainer = Frame(self.parent) self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) #the Top Frame with all the buttons self.topContainer = Frame(self.baseContainer) self.topContainer.pack(side=TOP, expand=YES, ipadx=5, ipady=5, fill = X, anchor=N) #the frame with the main things the user will use self.mainContainer = Frame(self.baseContainer) self.mainContainer.pack(side=TOP, ipadx = 5, ipady = 5, anchor=CENTER, expand=YES, fill=BOTH) #---------------------Top Buttons----------------------------- self.defineButton = Button(self.topContainer, padx=button_padx, pady=button_pady) self.defineButton.configure(text="Word List", command=self.define_Frame) self.defineButton.pack(side=LEFT) #-------------------------------------------------------------- def define_Frame(self): # destroy all the child widgets of the Frame for widget in self.list_of_widgets: widget.destroy() self.list_of_widgets = [] myMessage="Please type in all the words that you would like to define" xxx = Label(self.mainContainer, text=myMessage, justify=LEFT) xxx.pack(side=TOP, anchor=N) self.list_of_widgets.append(xxx) #The LEFT Frame that comes up when you hit define self.defineContainer1 = Frame(self.mainContainer) self.defineContainer1.pack(side=LEFT, ipadx = 5, ipady = 5, expand=YES, fill=BOTH) self.list_of_widgets.append(self.defineContainer1) #The RIGHT Frame that comes up when you hit define self.defineContainer2 = Frame(self.mainContainer) self.defineContainer2.pack(side=LEFT, ipadx=5, ipady=5, expand=YES, fill=BOTH) self.list_of_widgets.append(self.defineContainer2) #This frame is where the define button goes self.defineButtonF = Frame(self.baseContainer) self.defineButtonF.pack(side=TOP, anchor=S, ipady=5, ipadx=5, fill=BOTH, expand=NO) self.list_of_widgets.append(self.defineButtonF) #----------------------------Contstants for Buttons------------ self.button_padx = "2m" self.button_pady = "1m" #--------------------------end constants----------------------- #----------------------STUFF FOR DEFINE FRAME------------------------- self.e1 = Entry(self.defineContainer1) self.e1.pack(fill=X) self.e2 = Entry(self.defineContainer1) self.e2.pack(fill=X) self.e3 = Entry(self.defineContainer1) self.e3.pack(fill=X) self.e4 = Entry(self.defineContainer1) self.e4.pack(fill=X) self.e5 = Entry(self.defineContainer1) self.e5.pack(fill=X) self.e6 = Entry(self.defineContainer1) self.e6.pack(fill=X) self.e7 = Entry(self.defineContainer1) self.e7.pack(fill=X) self.e8 = Entry(self.defineContainer2) self.e8.pack(fill=X) self.e9 = Entry(self.defineContainer2) self.e9.pack(fill=X) self.e10 = Entry(self.defineContainer2) self.e10.pack(fill=X) self.e11 = Entry(self.defineContainer2) self.e11.pack(fill=X) self.e12 = Entry(self.defineContainer2) self.e12.pack(fill=X) self.e13 = Entry(self.defineContainer2) self.e13.pack(fill=X) self.e14 = Entry(self.defineContainer2,) self.e14.pack(fill=X) #-------------------------Define Button Stuff------------------------- #Define it button self.defineIt= Button(self.defineButtonF, command=self.DefineClick) self.defineIt.configure(text="Define!") self.defineIt.bind("", self.DefineClickE) self.defineIt.pack(side=TOP, anchor=N, padx=self.button_padx, pady=self.button_pady,) def DefineClickE(self, event): print "Define was hit with Enter" self.DefineClick() def DefineClick(self): print "Define was activated." #----------------------------end define Button Stuff---------------------- root = Tk() app = App(root) root.mainloop() From alexnbryan at gmail.com Wed Jul 2 08:12:36 2008 From: alexnbryan at gmail.com (Alexnb) Date: Tue, 1 Jul 2008 23:12:36 -0700 (PDT) Subject: [Tkinter-discuss] Clearing out a Frame In-Reply-To: <486B1A2F.8040607@velseis.com.au> References: <18230530.post@talk.nabble.com> <486B1A2F.8040607@velseis.com.au> Message-ID: <18230910.post@talk.nabble.com> Haha!, Brilliant, worked perfectly! Thank you for the help! John McMonagle-3 wrote: > > Alexnb wrote: >> I have an app that has a base frame, and some other frames inside of that >> base frame. My question is if there is some way to clear out the base >> frame. >> Meaning leaving an empty baseframe. See I have a function that pulls up >> frames inside that base frame. The problem comes when I hit a button(this >> button is the button that first shows the frames inside the base frame, >> basically you click it and the internal frames show up.) and then I hit >> it >> again, I get some weird stuff. Okay, this is getting really complicated. >> I >> really just want to know if I can clear out a frame, and still be able to >> fill it back up again. If you want ot uunderstand further I'll post the >> code >> at the bottom and just run it, then hit the "Word List" button, then hit >> it >> again, you'll see what I am talking about. >> > Make a list of the widgets when they are created and destroy the widgets > in this list whenever you have to re-define them. > > Regards, > > John > > > Your code with mods: > > from Tkinter import * > > class App: > def __init__(self, parent): > self.parent = parent > self.parent.geometry("500x250") > > self.list_of_widgets = [] > > #----------------------------Contstants for Buttons------------ > > button_padx = "2m" > button_pady = "1m" > > #--------------------------end constants----------------------- > > self.baseContainer = Frame(self.parent) > self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) > > #the Top Frame with all the buttons > self.topContainer = Frame(self.baseContainer) > self.topContainer.pack(side=TOP, expand=YES, ipadx=5, > ipady=5, fill = X, anchor=N) > > > > #the frame with the main things the user will use > self.mainContainer = Frame(self.baseContainer) > self.mainContainer.pack(side=TOP, > ipadx = 5, > ipady = 5, > anchor=CENTER, > expand=YES, > fill=BOTH) > > #---------------------Top Buttons----------------------------- > > self.defineButton = Button(self.topContainer, padx=button_padx, > pady=button_pady) > self.defineButton.configure(text="Word List", > command=self.define_Frame) > self.defineButton.pack(side=LEFT) > > #-------------------------------------------------------------- > def define_Frame(self): > # destroy all the child widgets of the Frame > for widget in self.list_of_widgets: > widget.destroy() > self.list_of_widgets = [] > > myMessage="Please type in all the words that you would like to > define" > xxx = Label(self.mainContainer, text=myMessage, > justify=LEFT) > xxx.pack(side=TOP, anchor=N) > self.list_of_widgets.append(xxx) > > #The LEFT Frame that comes up when you hit define > self.defineContainer1 = Frame(self.mainContainer) > self.defineContainer1.pack(side=LEFT, ipadx = 5, > ipady = 5, expand=YES, fill=BOTH) > self.list_of_widgets.append(self.defineContainer1) > > #The RIGHT Frame that comes up when you hit define > self.defineContainer2 = Frame(self.mainContainer) > self.defineContainer2.pack(side=LEFT, ipadx=5, > ipady=5, expand=YES, fill=BOTH) > self.list_of_widgets.append(self.defineContainer2) > > #This frame is where the define button goes > self.defineButtonF = Frame(self.baseContainer) > self.defineButtonF.pack(side=TOP, > anchor=S, > ipady=5, > ipadx=5, > fill=BOTH, > expand=NO) > self.list_of_widgets.append(self.defineButtonF) > > #----------------------------Contstants for Buttons------------ > > self.button_padx = "2m" > self.button_pady = "1m" > > #--------------------------end constants----------------------- > > > > > #----------------------STUFF FOR DEFINE > FRAME------------------------- > > self.e1 = Entry(self.defineContainer1) > self.e1.pack(fill=X) > > self.e2 = Entry(self.defineContainer1) > self.e2.pack(fill=X) > > self.e3 = Entry(self.defineContainer1) > self.e3.pack(fill=X) > > self.e4 = Entry(self.defineContainer1) > self.e4.pack(fill=X) > > self.e5 = Entry(self.defineContainer1) > self.e5.pack(fill=X) > > self.e6 = Entry(self.defineContainer1) > self.e6.pack(fill=X) > > self.e7 = Entry(self.defineContainer1) > self.e7.pack(fill=X) > > self.e8 = Entry(self.defineContainer2) > self.e8.pack(fill=X) > > self.e9 = Entry(self.defineContainer2) > self.e9.pack(fill=X) > > self.e10 = Entry(self.defineContainer2) > self.e10.pack(fill=X) > > self.e11 = Entry(self.defineContainer2) > self.e11.pack(fill=X) > > self.e12 = Entry(self.defineContainer2) > self.e12.pack(fill=X) > > self.e13 = Entry(self.defineContainer2) > self.e13.pack(fill=X) > > self.e14 = Entry(self.defineContainer2,) > self.e14.pack(fill=X) > > #-------------------------Define Button Stuff------------------------- > > #Define it button > self.defineIt= Button(self.defineButtonF, > command=self.DefineClick) > self.defineIt.configure(text="Define!") > self.defineIt.bind("", self.DefineClickE) > self.defineIt.pack(side=TOP, > anchor=N, > padx=self.button_padx, > pady=self.button_pady,) > def DefineClickE(self, event): > print "Define was hit with Enter" > self.DefineClick() > def DefineClick(self): > print "Define was activated." > > #----------------------------end define Button Stuff---------------------- > > > > root = Tk() > app = App(root) > root.mainloop() > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/Clearing-out-a-Frame-tp18230530p18230910.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Wed Jul 2 08:37:02 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 2 Jul 2008 08:37:02 +0200 Subject: [Tkinter-discuss] Clearing out a Frame In-Reply-To: <18230910.post@talk.nabble.com> References: <18230530.post@talk.nabble.com> <486B1A2F.8040607@velseis.com.au> <18230910.post@talk.nabble.com> Message-ID: <47e491110807012337y20a613a1r439defe1bbf3f8fc@mail.gmail.com> Hi Alex, John, No need to collect a list of widgets to delete. Use pack_slaves() to find the widgets packed in the the frame, and then kill each of these: for wgt in self.mainContainer.pack_slaves(): wgt.destroy() All widgets within these widgets will also be destroyed. Mick On Wed, Jul 2, 2008 at 8:12 AM, Alexnb wrote: > > Haha!, Brilliant, worked perfectly! Thank you for the help! > > > > John McMonagle-3 wrote: >> >> Alexnb wrote: >>> I have an app that has a base frame, and some other frames inside of that >>> base frame. My question is if there is some way to clear out the base >>> frame. >>> Meaning leaving an empty baseframe. See I have a function that pulls up >>> frames inside that base frame. The problem comes when I hit a button(this >>> button is the button that first shows the frames inside the base frame, >>> basically you click it and the internal frames show up.) and then I hit >>> it >>> again, I get some weird stuff. Okay, this is getting really complicated. >>> I >>> really just want to know if I can clear out a frame, and still be able to >>> fill it back up again. If you want ot uunderstand further I'll post the >>> code >>> at the bottom and just run it, then hit the "Word List" button, then hit >>> it >>> again, you'll see what I am talking about. >>> >> Make a list of the widgets when they are created and destroy the widgets >> in this list whenever you have to re-define them. >> >> Regards, >> >> John >> >> >> Your code with mods: >> >> from Tkinter import * >> >> class App: >> def __init__(self, parent): >> self.parent = parent >> self.parent.geometry("500x250") >> >> self.list_of_widgets = [] >> >> #----------------------------Contstants for Buttons------------ >> >> button_padx = "2m" >> button_pady = "1m" >> >> #--------------------------end constants----------------------- >> >> self.baseContainer = Frame(self.parent) >> self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) >> >> #the Top Frame with all the buttons >> self.topContainer = Frame(self.baseContainer) >> self.topContainer.pack(side=TOP, expand=YES, ipadx=5, >> ipady=5, fill = X, anchor=N) >> >> >> >> #the frame with the main things the user will use >> self.mainContainer = Frame(self.baseContainer) >> self.mainContainer.pack(side=TOP, >> ipadx = 5, >> ipady = 5, >> anchor=CENTER, >> expand=YES, >> fill=BOTH) >> >> #---------------------Top Buttons----------------------------- >> >> self.defineButton = Button(self.topContainer, padx=button_padx, >> pady=button_pady) >> self.defineButton.configure(text="Word List", >> command=self.define_Frame) >> self.defineButton.pack(side=LEFT) >> >> #-------------------------------------------------------------- >> def define_Frame(self): >> # destroy all the child widgets of the Frame >> for widget in self.list_of_widgets: >> widget.destroy() >> self.list_of_widgets = [] >> >> myMessage="Please type in all the words that you would like to >> define" >> xxx = Label(self.mainContainer, text=myMessage, >> justify=LEFT) >> xxx.pack(side=TOP, anchor=N) >> self.list_of_widgets.append(xxx) >> >> #The LEFT Frame that comes up when you hit define >> self.defineContainer1 = Frame(self.mainContainer) >> self.defineContainer1.pack(side=LEFT, ipadx = 5, >> ipady = 5, expand=YES, fill=BOTH) >> self.list_of_widgets.append(self.defineContainer1) >> >> #The RIGHT Frame that comes up when you hit define >> self.defineContainer2 = Frame(self.mainContainer) >> self.defineContainer2.pack(side=LEFT, ipadx=5, >> ipady=5, expand=YES, fill=BOTH) >> self.list_of_widgets.append(self.defineContainer2) >> >> #This frame is where the define button goes >> self.defineButtonF = Frame(self.baseContainer) >> self.defineButtonF.pack(side=TOP, >> anchor=S, >> ipady=5, >> ipadx=5, >> fill=BOTH, >> expand=NO) >> self.list_of_widgets.append(self.defineButtonF) >> >> #----------------------------Contstants for Buttons------------ >> >> self.button_padx = "2m" >> self.button_pady = "1m" >> >> #--------------------------end constants----------------------- >> >> >> >> >> #----------------------STUFF FOR DEFINE >> FRAME------------------------- >> >> self.e1 = Entry(self.defineContainer1) >> self.e1.pack(fill=X) >> >> self.e2 = Entry(self.defineContainer1) >> self.e2.pack(fill=X) >> >> self.e3 = Entry(self.defineContainer1) >> self.e3.pack(fill=X) >> >> self.e4 = Entry(self.defineContainer1) >> self.e4.pack(fill=X) >> >> self.e5 = Entry(self.defineContainer1) >> self.e5.pack(fill=X) >> >> self.e6 = Entry(self.defineContainer1) >> self.e6.pack(fill=X) >> >> self.e7 = Entry(self.defineContainer1) >> self.e7.pack(fill=X) >> >> self.e8 = Entry(self.defineContainer2) >> self.e8.pack(fill=X) >> >> self.e9 = Entry(self.defineContainer2) >> self.e9.pack(fill=X) >> >> self.e10 = Entry(self.defineContainer2) >> self.e10.pack(fill=X) >> >> self.e11 = Entry(self.defineContainer2) >> self.e11.pack(fill=X) >> >> self.e12 = Entry(self.defineContainer2) >> self.e12.pack(fill=X) >> >> self.e13 = Entry(self.defineContainer2) >> self.e13.pack(fill=X) >> >> self.e14 = Entry(self.defineContainer2,) >> self.e14.pack(fill=X) >> >> #-------------------------Define Button Stuff------------------------- >> >> #Define it button >> self.defineIt= Button(self.defineButtonF, >> command=self.DefineClick) >> self.defineIt.configure(text="Define!") >> self.defineIt.bind("", self.DefineClickE) >> self.defineIt.pack(side=TOP, >> anchor=N, >> padx=self.button_padx, >> pady=self.button_pady,) >> def DefineClickE(self, event): >> print "Define was hit with Enter" >> self.DefineClick() >> def DefineClick(self): >> print "Define was activated." >> >> #----------------------------end define Button Stuff---------------------- >> >> >> >> root = Tk() >> app = App(root) >> root.mainloop() >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > -- > View this message in context: http://www.nabble.com/Clearing-out-a-Frame-tp18230530p18230910.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From alexnbryan at gmail.com Thu Jul 3 07:33:49 2008 From: alexnbryan at gmail.com (Alexnb) Date: Wed, 2 Jul 2008 22:33:49 -0700 (PDT) Subject: [Tkinter-discuss] Issue with the layout of a frame Message-ID: <18252118.post@talk.nabble.com> I am in the middle of writing my first big app. I am having trouble with the layout of the frames and buttons. In particular, just one frame. I'll post the code and you can compile it and see what I am talking about. But, when you do there is a red frame with the button "Define" in it. I want this frame to be below the yellow and green frame. It has to be a child frame of a certain parent frame. I can make it work if it is not in that certain parent frame, but can't seem to when it is. Here's the code, and Ill give some additional info at the bottom. from Tkinter import* #Now for the class that gets the definitions from get_defs import* class App: def __init__(self, parent): self.parent = parent self.parent.geometry("500x250") #----------------------------Contstants for Buttons------------ button_padx = "2m" button_pady = "1m" #--------------------------end constants----------------------- self.baseContainer = Frame(self.parent) self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) #the Top Frame with all the buttons self.topContainer = Frame(self.baseContainer, bg="purple") self.topContainer.pack(side=TOP, expand=YES, ipadx=5, ipady=5, fill = X, anchor=N) #the frame with the main things the user will use self.mainContainer = Frame(self.baseContainer, bg="blue") self.mainContainer.pack(side=TOP, ipadx = 5, ipady = 5, anchor=CENTER, expand=YES, fill=BOTH) #---------------------Top Buttons----------------------------- #WORD LIST BUTTON------------------ self.wordListButton = Button(self.topContainer, padx=button_padx, pady=button_pady) self.wordListButton.configure(text="Word List", command=self.define_Frame) self.wordListButton.pack(side=LEFT) #END WORD LIST BUTTON--------------- #DEFINITIONS BUTTON----------------- self.definitionsButton = Button(self.topContainer, padx=button_padx, pady=button_pady, command = self.defs_Frame) self.definitionsButton.configure(text="Definitions") self.definitionsButton.pack(side=LEFT) #END DEFINITIONS BUTTON-------------- def destroyMainChildren(self): #This will make sure taht when a button is pushed for a new set of frames #that everything will go smoothly. for widget in self.mainContainer.pack_slaves(): widget.destroy() def destroyDefButFrame(self): #The define it button is under a different frame than main frame #so this is another way of killing it. for widget in self.defineButtonF.pack_slaves(): widget.destroy() self.defineButtonF.destroy() def defs_Frame(self): #Destroy main's children self.destroyMainChildren() self.destroyDefButFrame() optionsFrame = Frame(self.mainContainer, bg="red") optionsFrame.pack(side=TOP, expand=YES, ipadx=5, ipady=5, fill = X, anchor=N) #---------------------DEFINE FRAME------------------------ #This frame is the frame that has all the entry widgets, it is called #the define frame. when you hit the "wordListButton" this should come up def define_Frame(self): #Destroy all child widgets self.destroyMainChildren() myMessage="Please type in all the words that you would like to define" Label(self.mainContainer, text=myMessage, justify=LEFT).pack(side=TOP, anchor=N) #The LEFT Frame that comes up when you hit define self.defineContainer1 = Frame(self.mainContainer, bg="green") self.defineContainer1.pack(side=LEFT, ipadx = 5, ipady = 5, expand=YES, fill=BOTH) #The RIGHT Frame that comes up when you hit define self.defineContainer2 = Frame(self.mainContainer, bg="yellow") self.defineContainer2.pack(side=LEFT, ipadx=5, ipady=5, expand=YES, fill=BOTH) #This frame is where the define button goes self.defineButtonF = Frame(self.mainContainer, bg="red") self.defineButtonF.pack(side=BOTTOM, anchor=S, ipady=5, ipadx=5, fill=BOTH, expand=YES) #----------------------------Contstants for Buttons------------ self.button_padx = "2m" self.button_pady = "1m" #--------------------------end constants----------------------- #----------------------STUFF FOR DEFINE FRAME------------------------- self.e1 = Entry(self.defineContainer1) self.e1.pack(fill=X) self.e2 = Entry(self.defineContainer1) self.e2.pack(fill=X) self.e3 = Entry(self.defineContainer1) self.e3.pack(fill=X) self.e4 = Entry(self.defineContainer1) self.e4.pack(fill=X) self.e5 = Entry(self.defineContainer1) self.e5.pack(fill=X) self.e6 = Entry(self.defineContainer1) self.e6.pack(fill=X) self.e7 = Entry(self.defineContainer1) self.e7.pack(fill=X) self.e8 = Entry(self.defineContainer2) self.e8.pack(fill=X) self.e9 = Entry(self.defineContainer2) self.e9.pack(fill=X) self.e10 = Entry(self.defineContainer2) self.e10.pack(fill=X) self.e11 = Entry(self.defineContainer2) self.e11.pack(fill=X) self.e12 = Entry(self.defineContainer2) self.e12.pack(fill=X) self.e13 = Entry(self.defineContainer2) self.e13.pack(fill=X) self.e14 = Entry(self.defineContainer2,) self.e14.pack(fill=X) self.listBuffer=[self.e1, self.e2, self.e3, self.e4, self.e5, self.e6, self.e7, self.e8, self.e9, self.e10, self.e11, self.e12, self.e13, self.e14] self.wordList=['None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None', 'None'] self.finalWords=[] self.definition1=[] self.definition2=[] self.definition3=[] self.definition4=[] self.definition5=[] self.definition6=[] self.definition7=[] self.definition8=[] self.definition9=[] self.definition10=[] self.definition11=[] self.definition12=[] self.definition13=[] self.definition14=[] self.definitionsList=[self.definition1, self.definition2, self.definition3, self.definition4, self.definition5, self.definition6, self.definition7, self.definition8, self.definition9, self.definition10, self.definition11, self.definition12, self.definition13, self.definition14] self.bufferList = [] #-------------------------Define Button Stuff------------------------- #Define it button self.defineIt= Button(self.defineButtonF, command=self.DefineClick) self.defineIt.configure(text="Define!") self.defineIt.bind("", self.DefineClickE) self.defineIt.pack(side=TOP, anchor=N, padx=self.button_padx, pady=self.button_pady,) def DefineClickE(self, event): print "Define was hit with Enter" self.DefineClick() def DefineClick(self): print "Define was activated." self.getWords() def getWords(self): self.n=0 for entry in self.listBuffer: self.wordList[self.n] = entry.get() self.n=self.n + 1 for item in self.wordList: if item != '': self.finalWords.append(item) #wordList is the list of all the words, entered or not #print self.wordList #finalWords is the list of words refined, with just the ones the user typed #print self.finalWords #----------------------------END DEFINE BUTTON STUFF---------------------- #------------------------------------------------------------------------- #-----------END OF EVERYTHING FOR THE DEFINE FRAMES----------- #------------------------------------------------------------------------- root = Tk() app = App(root) root.mainloop() there is a button towards the bottom called the defineIt button. this is the button in the red frame. If you look right above the big comment called constants for buttons, that frame called definebuttonF is the red frame. I need the parent to be the mainContainer frame. However, if you make it the baseContainer frame. that is what I want it to look like. See if you can make it work. I haven't been able to yet. I know this may seem like it would take a while; but I really would like it if someone helped. -- View this message in context: http://www.nabble.com/Issue-with-the-layout-of-a-frame-tp18252118p18252118.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Thu Jul 3 14:10:35 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 3 Jul 2008 09:10:35 -0300 Subject: [Tkinter-discuss] Issue with the layout of a frame In-Reply-To: <18252118.post@talk.nabble.com> References: <18252118.post@talk.nabble.com> Message-ID: On Thu, Jul 3, 2008 at 2:33 AM, Alexnb wrote: > > I am in the middle of writing my first big app. I am having trouble with the > layout of the frames and buttons. In particular, just one frame. I'll post > the code and you can compile it and see what I am talking about. But, when > you do there is a red frame with the button "Define" in it. I want this > frame to be below the yellow and green frame. It has to be a child frame of > a certain parent frame. I can make it work if it is not in that certain > parent frame, but can't seem to when it is. Here's the code, and Ill give > some additional info at the bottom. I'm sure you can manage to post a much smaller code that shows your problem. This may also help you understanding the problem, and your chances of getting help will increase at the same time. > > from Tkinter import* > #Now for the class that gets the definitions > from get_defs import* > > class App: > def __init__(self, parent): > self.parent = parent > self.parent.geometry("500x250") > > #----------------------------Contstants for Buttons------------ > > button_padx = "2m" > button_pady = "1m" > > #--------------------------end constants----------------------- > > self.baseContainer = Frame(self.parent) > self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO) > > #the Top Frame with all the buttons > self.topContainer = Frame(self.baseContainer, bg="purple") > self.topContainer.pack(side=TOP, expand=YES, ipadx=5, > ipady=5, fill = X, anchor=N) > > > > #the frame with the main things the user will use > self.mainContainer = Frame(self.baseContainer, bg="blue") > self.mainContainer.pack(side=TOP, > ipadx = 5, > ipady = 5, > anchor=CENTER, > expand=YES, > fill=BOTH) > > #---------------------Top Buttons----------------------------- > #WORD LIST BUTTON------------------ > self.wordListButton = Button(self.topContainer, padx=button_padx, > pady=button_pady) > self.wordListButton.configure(text="Word List", > command=self.define_Frame) > self.wordListButton.pack(side=LEFT) > #END WORD LIST BUTTON--------------- > > #DEFINITIONS BUTTON----------------- > self.definitionsButton = Button(self.topContainer, > padx=button_padx, > pady=button_pady, > command = self.defs_Frame) > self.definitionsButton.configure(text="Definitions") > self.definitionsButton.pack(side=LEFT) > #END DEFINITIONS BUTTON-------------- > def destroyMainChildren(self): > #This will make sure taht when a button is pushed for a new set of > frames > #that everything will go smoothly. > for widget in self.mainContainer.pack_slaves(): > widget.destroy() > def destroyDefButFrame(self): > #The define it button is under a different frame than main frame > #so this is another way of killing it. > for widget in self.defineButtonF.pack_slaves(): > widget.destroy() > self.defineButtonF.destroy() > > > > > def defs_Frame(self): > #Destroy main's children > self.destroyMainChildren() > self.destroyDefButFrame() > > optionsFrame = Frame(self.mainContainer, bg="red") > optionsFrame.pack(side=TOP, expand=YES, ipadx=5, > ipady=5, fill = X, anchor=N) > > > > > > > #---------------------DEFINE FRAME------------------------ > #This frame is the frame that has all the entry widgets, it is > called > #the define frame. when you hit the "wordListButton" this should > come up > def define_Frame(self): > > #Destroy all child widgets > self.destroyMainChildren() > > > myMessage="Please type in all the words that you would like to > define" > Label(self.mainContainer, text=myMessage, > justify=LEFT).pack(side=TOP, anchor=N) > > #The LEFT Frame that comes up when you hit define > self.defineContainer1 = Frame(self.mainContainer, bg="green") > self.defineContainer1.pack(side=LEFT, ipadx = 5, > ipady = 5, expand=YES, fill=BOTH) > > #The RIGHT Frame that comes up when you hit define > self.defineContainer2 = Frame(self.mainContainer, bg="yellow") > self.defineContainer2.pack(side=LEFT, ipadx=5, > ipady=5, expand=YES, fill=BOTH) > > #This frame is where the define button goes > self.defineButtonF = Frame(self.mainContainer, bg="red") > self.defineButtonF.pack(side=BOTTOM, > anchor=S, > ipady=5, > ipadx=5, > fill=BOTH, > expand=YES) > > > #----------------------------Contstants for Buttons------------ > > self.button_padx = "2m" > self.button_pady = "1m" > > #--------------------------end constants----------------------- > > > > > #----------------------STUFF FOR DEFINE > FRAME------------------------- > > > self.e1 = Entry(self.defineContainer1) > self.e1.pack(fill=X) > > self.e2 = Entry(self.defineContainer1) > self.e2.pack(fill=X) > > self.e3 = Entry(self.defineContainer1) > self.e3.pack(fill=X) > > self.e4 = Entry(self.defineContainer1) > self.e4.pack(fill=X) > > self.e5 = Entry(self.defineContainer1) > self.e5.pack(fill=X) > > self.e6 = Entry(self.defineContainer1) > self.e6.pack(fill=X) > > self.e7 = Entry(self.defineContainer1) > self.e7.pack(fill=X) > > self.e8 = Entry(self.defineContainer2) > self.e8.pack(fill=X) > > self.e9 = Entry(self.defineContainer2) > self.e9.pack(fill=X) > > self.e10 = Entry(self.defineContainer2) > self.e10.pack(fill=X) > > self.e11 = Entry(self.defineContainer2) > self.e11.pack(fill=X) > > self.e12 = Entry(self.defineContainer2) > self.e12.pack(fill=X) > > self.e13 = Entry(self.defineContainer2) > self.e13.pack(fill=X) > > self.e14 = Entry(self.defineContainer2,) > self.e14.pack(fill=X) > > self.listBuffer=[self.e1, self.e2, self.e3, self.e4, > self.e5, self.e6, self.e7, self.e8, > self.e9, self.e10, self.e11, > self.e12, self.e13, self.e14] > self.wordList=['None', 'None', 'None', 'None', 'None', 'None', > 'None', 'None', 'None', 'None', 'None', 'None', > 'None', 'None'] > self.finalWords=[] > > self.definition1=[] > self.definition2=[] > self.definition3=[] > self.definition4=[] > self.definition5=[] > self.definition6=[] > self.definition7=[] > self.definition8=[] > self.definition9=[] > self.definition10=[] > self.definition11=[] > self.definition12=[] > self.definition13=[] > self.definition14=[] > > self.definitionsList=[self.definition1, self.definition2, > self.definition3, > self.definition4, self.definition5, > self.definition6, > self.definition7, self.definition8, > self.definition9, > self.definition10, self.definition11, > self.definition12, > self.definition13, self.definition14] > self.bufferList = [] > > > #-------------------------Define Button Stuff------------------------- > > #Define it button > self.defineIt= Button(self.defineButtonF, command=self.DefineClick) > self.defineIt.configure(text="Define!") > self.defineIt.bind("", self.DefineClickE) > self.defineIt.pack(side=TOP, > anchor=N, > padx=self.button_padx, > pady=self.button_pady,) > def DefineClickE(self, event): > print "Define was hit with Enter" > self.DefineClick() > def DefineClick(self): > print "Define was activated." > self.getWords() > > def getWords(self): > self.n=0 > for entry in self.listBuffer: > self.wordList[self.n] = entry.get() > self.n=self.n + 1 > for item in self.wordList: > if item != '': > self.finalWords.append(item) > #wordList is the list of all the words, entered or not > #print self.wordList > #finalWords is the list of words refined, with just the ones the > user typed > #print self.finalWords > > > #----------------------------END DEFINE BUTTON STUFF---------------------- > #------------------------------------------------------------------------- > #-----------END OF EVERYTHING FOR THE DEFINE FRAMES----------- > #------------------------------------------------------------------------- > > > > root = Tk() > app = App(root) > root.mainloop() > > there is a button towards the bottom called the defineIt button. this is the > button in the red frame. If you look right above the big comment called > constants for buttons, that frame called definebuttonF is the red frame. I > need the parent to be the mainContainer frame. However, if you make it the > baseContainer frame. that is what I want it to look like. See if you can > make it work. I haven't been able to yet. I know this may seem like it would > take a while; but I really would like it if someone helped. > > -- > View this message in context: http://www.nabble.com/Issue-with-the-layout-of-a-frame-tp18252118p18252118.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From jmcmonagle at velseis.com.au Fri Jul 4 00:30:07 2008 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Fri, 04 Jul 2008 08:30:07 +1000 Subject: [Tkinter-discuss] Issue with the layout of a frame In-Reply-To: <18252118.post@talk.nabble.com> References: <18252118.post@talk.nabble.com> Message-ID: <486D52EF.6020201@velseis.com.au> Alexnb wrote: > > there is a button towards the bottom called the defineIt button. this is the > button in the red frame. If you look right above the big comment called > constants for buttons, that frame called definebuttonF is the red frame. I > need the parent to be the mainContainer frame. However, if you make it the > baseContainer frame. that is what I want it to look like. See if you can > make it work. I haven't been able to yet. I know this may seem like it would > take a while; but I really would like it if someone helped. > Make another frame, which is a child of self.mainContainer and pack the LEFT and RIGHT frames in it. Now your frame with the red background is packed underneath and is a child of mainContainer. eg: def define_Frame(self): #Destroy all child widgets self.destroyMainChildren() myMessage="Please type in all the words that you would like to define" Label(self.mainContainer, text=myMessage, justify=LEFT).pack(side=TOP, anchor=N) f = Frame(self.mainContainer) f.pack(side=TOP, expand=YES, fill=BOTH) #The LEFT Frame that comes up when you hit define self.defineContainer1 = Frame(f, bg="green") self.defineContainer1.pack(side=LEFT, ipadx = 5, ipady = 5, expand=YES, fill=BOTH) #The RIGHT Frame that comes up when you hit define self.defineContainer2 = Frame(f, bg="yellow") self.defineContainer2.pack(side=LEFT, ipadx=5, ipady=5, expand=YES, fill=BOTH) #This frame is where the define button goes self.defineButtonF = Frame(self.mainContainer, bg="red") self.defineButtonF.pack(side=BOTTOM, anchor=S, ipady=5, ipadx=5, fill=BOTH, expand=YES) Regards, John From alexnbryan at gmail.com Fri Jul 4 01:16:23 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 3 Jul 2008 16:16:23 -0700 (PDT) Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file Message-ID: <18269937.post@talk.nabble.com> I don't really know if this is possible, but it seems like there should be an easy way. If I have a text widget: text = Text(parent) and I want to take what is in there and save it has a text file. How would I go about doing this. Also, if it matters, I would like to keep it in the same format as the textbox. -- View this message in context: http://www.nabble.com/Taking-a-Text%28%29-widget-and-saving-it-to-a-.txt-file-tp18269937p18269937.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From bob at greschke.com Fri Jul 4 02:32:29 2008 From: bob at greschke.com (Bob Greschke) Date: Thu, 3 Jul 2008 18:32:29 -0600 Subject: [Tkinter-discuss] Text() scrolling, but Canvas() not on OSX In-Reply-To: <18269937.post@talk.nabble.com> References: <18269937.post@talk.nabble.com> Message-ID: <2EC6F10E-F10E-45CF-8048-6B4D7BE18ABA@greschke.com> My Text() widgets with scrollbars (all Tkinter, not PMW widgets) scroll using the two-finger scroll method on my MacBook trackpad, but my Canvas()'s with scrollbars don't. Is there some bind I should be doing, or is this just another OSX X11 "feature"? Typical Text(): Sub = Frame(LFrm) LTxt = Txt["HELP"] = Text(Sub, width = HELPWidth, height = HELPHeight, \ wrap = WORD, font = HELPFont, relief = SUNKEN) LTxt.pack(side = LEFT, fill = BOTH, expand = YES) Sb = Scrollbar(Sub, orient = VERTICAL, command = LTxt.yview) Sb.pack(side = RIGHT, fill = Y) LTxt.configure(yscrollcommand = Sb.set) Sub.pack(side = TOP, fill = BOTH, expand = YES) Typical Canvas(): SSSub = Frame(SSub) LCan = Can["PTRD"] = Canvas(SSSub, bg = Clr["B"], bd = 0, width = 700, \ height = 500, scrollregion = (0, 0, 700, 500)) LCan.pack(side = LEFT, fill = BOTH, expand = YES) PTRDScroll = Sb = Scrollbar(SSSub, orient = VERTICAL, command = LCan.yview) Sb.pack(side = RIGHT, fill = Y, expand = NO) LCan.configure(yscrollcommand = Sb.set) SSSub.pack(side = TOP, fill = BOTH, expand = YES) Thanks! From Cameron at phaseit.net Fri Jul 4 02:57:14 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Fri, 4 Jul 2008 00:57:14 +0000 Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <18269937.post@talk.nabble.com> References: <18269937.post@talk.nabble.com> Message-ID: <20080704005713.GA5967@lairds.us> On Thu, Jul 03, 2008 at 04:16:23PM -0700, Alexnb wrote: . . . > I don't really know if this is possible, but it seems like there should be an > easy way. If I have a text widget: > > text = Text(parent) > > and I want to take what is in there and save it has a text file. How would I > go about doing this. Also, if it matters, I would like to keep it in the > same format as the textbox. . . . You'll want to start by reading , and especially about get(): text.get("1.0", "end") From bob at greschke.com Fri Jul 4 03:42:17 2008 From: bob at greschke.com (Bob Greschke) Date: Thu, 3 Jul 2008 19:42:17 -0600 Subject: [Tkinter-discuss] Is this introspective? In-Reply-To: <20080704005713.GA5967@lairds.us> References: <18269937.post@talk.nabble.com> <20080704005713.GA5967@lairds.us> Message-ID: <9851F797-F4B3-46EA-AE52-3372EB15F0CA@greschke.com> #! /usr/bin/env python def doSomething(): return def doSomethingElse(): return def canWeDoSomethingPopup(): if 'doSomething() exists': Add-doSomething-call-to-the-popup() if 'doSomethingElse() exists': Add-doSomethingElse()-call-to-the-popup() return mainloop() What's the right way to find out if the function doSomething() is in this program? I want to make up popup context menus (and menubar menus too, I guess) based on what functions are available in a given program. doSomething() may be in one program, but not in another, and I'd like the list of menu items to handle that automatically. Should I use getargspec() from the inspect module and look for the NameError exception, or just use something like "if doSomething:", or ? Thanks! From Cameron at phaseit.net Fri Jul 4 03:54:40 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Fri, 4 Jul 2008 01:54:40 +0000 Subject: [Tkinter-discuss] Is this introspective? In-Reply-To: <9851F797-F4B3-46EA-AE52-3372EB15F0CA@greschke.com> References: <18269937.post@talk.nabble.com> <20080704005713.GA5967@lairds.us> <9851F797-F4B3-46EA-AE52-3372EB15F0CA@greschke.com> Message-ID: <20080704015440.GA13871@lairds.us> On Thu, Jul 03, 2008 at 07:42:17PM -0600, Bob Greschke wrote: . . . > #! /usr/bin/env python > > def doSomething(): > return > > def doSomethingElse(): > return > > def canWeDoSomethingPopup(): > if 'doSomething() exists': > Add-doSomething-call-to-the-popup() > if 'doSomethingElse() exists': > Add-doSomethingElse()-call-to-the-popup() > return > > mainloop() > > > What's the right way to find out if the function doSomething() is in > this program? I want to make up popup context menus (and menubar > menus too, I guess) based on what functions are available in a given > program. doSomething() may be in one program, but not in another, and > I'd like the list of menu items to handle that automatically. > > Should I use getargspec() from the inspect module and look for the > NameError exception, or just use something like "if doSomething:", or ? . . . This is more a question about Python than Tkinter. While we might do well to move further discussion to comp.lang.tcl (or its mailing-list equivalent), I can provide the highlights here: if "doSomething" in globals(): ... or import types if "doSomething" in globals() and type(doSomething) == types.FunctionType: ... or import types if "doSomething" in globals() and \ type(globals()["doSomething"]) == types.FunctionType: ... or ... From bob at greschke.com Fri Jul 4 04:18:01 2008 From: bob at greschke.com (Bob Greschke) Date: Thu, 3 Jul 2008 20:18:01 -0600 Subject: [Tkinter-discuss] Is this introspective? In-Reply-To: <20080704015440.GA13871@lairds.us> References: <18269937.post@talk.nabble.com> <20080704005713.GA5967@lairds.us> <9851F797-F4B3-46EA-AE52-3372EB15F0CA@greschke.com> <20080704015440.GA13871@lairds.us> Message-ID: On 2008-07-03, at 19:54, Cameron Laird wrote: > > On Thu, Jul 03, 2008 at 07:42:17PM -0600, Bob Greschke wrote: > . > . > . >> #! /usr/bin/env python >> >> def doSomething(): >> return >> >> def doSomethingElse(): >> return >> >> def canWeDoSomethingPopup(): >> if 'doSomething() exists': >> Add-doSomething-call-to-the-popup() >> if 'doSomethingElse() exists': >> Add-doSomethingElse()-call-to-the-popup() >> return >> >> mainloop() >> >> >> What's the right way to find out if the function doSomething() is in >> this program? I want to make up popup context menus (and menubar >> menus too, I guess) based on what functions are available in a given >> program. doSomething() may be in one program, but not in another, >> and >> I'd like the list of menu items to handle that automatically. >> >> Should I use getargspec() from the inspect module and look for the >> NameError exception, or just use something like "if doSomething:", >> or ? > . > . > . > This is more a question about Python than Tkinter. > While we might do well to move further discussion > to comp.lang.tcl (or its mailing-list equivalent), > I can provide the highlights here: > > if "doSomething" in globals(): > ... > or > import types > if "doSomething" in globals() and type(doSomething) == > types.FunctionType: > ... > or > import types > if "doSomething" in globals() and \ > type(globals()["doSomething"]) == types.FunctionType: > ... > or ... > > Oh yeah, you're right. Oops. I just wasn't thinking. I'm trying to make menus that call functions that bring up toplevel frames. Does that count? ;) globals()! I forgot all about that. Thanks! Bob From jmcmonagle at velseis.com.au Fri Jul 4 04:42:51 2008 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Fri, 04 Jul 2008 12:42:51 +1000 Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <18269937.post@talk.nabble.com> References: <18269937.post@talk.nabble.com> Message-ID: <486D8E2B.10407@velseis.com.au> Alexnb wrote: > I don't really know if this is possible, but it seems like there should be an > easy way. If I have a text widget: > > text = Text(parent) > > and I want to take what is in there and save it has a text file. How would I > go about doing this. Also, if it matters, I would like to keep it in the > same format as the textbox. As Cameron Laird has pointed out, the get method of the Text widget returns a range of characters selected by line and character position to a string. You then need to open a file for writing, write the string to the file, and close the file. As for keeping it in the same format as the textbox, that does not make any sense. Plain text files don't really have formatting, apart from spaces, tabs or carriage returns. These will be preserved by the get method. However other formatting such as font type, font height, colour, etc will not. Regards, John From Cameron at phaseit.net Fri Jul 4 07:14:59 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Fri, 4 Jul 2008 05:14:59 +0000 Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <486D8E2B.10407@velseis.com.au> References: <18269937.post@talk.nabble.com> <486D8E2B.10407@velseis.com.au> Message-ID: <20080704051459.GA16260@lairds.us> On Fri, Jul 04, 2008 at 12:42:51PM +1000, John McMonagle wrote: . . . > As for keeping it in the same format as the textbox, that does not make > any sense. Plain text files don't really have formatting, apart from > spaces, tabs or carriage returns. These will be preserved by the get > method. However other formatting such as font type, font height, > colour, etc will not. . . . I wonder if Alexnb has in mind display-level word-wrap as part of the formatting he has in mind to preserve. Alex? From kodavali.lakshmi at gmail.com Fri Jul 4 08:44:58 2008 From: kodavali.lakshmi at gmail.com (Lakshmi Narayana) Date: Thu, 3 Jul 2008 23:44:58 -0700 (PDT) Subject: [Tkinter-discuss] re garding labels alignment in PyTkinter GUI Message-ID: <18273808.post@talk.nabble.com> Hari Om, Here iam facing one problem is i created more than one labels which have different lengths. All labels text are displaying(aligned) in center based on longest label length. (I am not require any textwrapping) So how can i aligne all labels text from left side means left justify. Example code is: ------------------------------------------------- from Tkinter import * master = Tk() w = Label(master, text="AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB", anchor=W, justify=LEFT) w.pack() w1 = Label(master, text="AAAAAAAAAAAAA ", anchor=W, justify=LEFT) w1.pack() mainloop() ---------------------------------- Output producing is : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB AAAAAAAAAAAAA But i require like this : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB AAAAAAAAAAAAA Kindly help me to solve this problem: Iam very thankful if i got output like this. By urs friend Lakshminarayana. -- View this message in context: http://www.nabble.com/regarding-labels-alignment-in-PyTkinter-GUI-tp18273808p18273808.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Fri Jul 4 18:53:02 2008 From: alexnbryan at gmail.com (Alexnb) Date: Fri, 4 Jul 2008 09:53:02 -0700 (PDT) Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <20080704051459.GA16260@lairds.us> References: <18269937.post@talk.nabble.com> <486D8E2B.10407@velseis.com.au> <20080704051459.GA16260@lairds.us> Message-ID: <18282989.post@talk.nabble.com> Cameron Laird-2 wrote: > > On Fri, Jul 04, 2008 at 12:42:51PM +1000, John McMonagle wrote: > . > . > . >> As for keeping it in the same format as the textbox, that does not make >> any sense. Plain text files don't really have formatting, apart from >> spaces, tabs or carriage returns. These will be preserved by the get >> method. However other formatting such as font type, font height, >> colour, etc will not. > . > . > . > I wonder if Alexnb has in mind display-level word-wrap > as part of the formatting he has in mind to preserve. > Alex? > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Sorry guys that it has taken me a while. Okay, well what I meant by formatting is that I have a word and a series of definitions. The word is indented, and the definitions are further indented. However, not really indented, it is just spaces. But you guys said that will stay. But I have gotten another question after running the program. Some of the definitions wrap. They don't actually wrap, I need to set that, they like just go to the very end of the line and then go to the next line. If that makes sense. But My next question is can you set a margin in a textbox? -- View this message in context: http://www.nabble.com/Taking-a-Text%28%29-widget-and-saving-it-to-a-.txt-file-tp18269937p18282989.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From jmcmonagle at velseis.com.au Sat Jul 5 10:59:19 2008 From: jmcmonagle at velseis.com.au (John McMoangle) Date: Sat, 5 Jul 2008 18:59:19 +1000 Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <18282989.post@talk.nabble.com> References: <18269937.post@talk.nabble.com> <486D8E2B.10407@velseis.com.au> <20080704051459.GA16260@lairds.us> <18282989.post@talk.nabble.com> Message-ID: <20080705085741.M14435@velseis.com.au> > Cameron Laird-2 wrote: > > > > On Fri, Jul 04, 2008 at 12:42:51PM +1000, John McMonagle wrote: > > . > > . > > . > >> As for keeping it in the same format as the textbox, that does not make > >> any sense. Plain text files don't really have formatting, apart from > >> spaces, tabs or carriage returns. These will be preserved by the get > >> method. However other formatting such as font type, font height, > >> colour, etc will not. > > . > > . > > . > > I wonder if Alexnb has in mind display-level word-wrap > > as part of the formatting he has in mind to preserve. > > Alex? > > _______________________________________________ > > Tkinter-discuss mailing list > > Tkinter-discuss at python.org > > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > > > Sorry guys that it has taken me a while. Okay, well what I meant by > formatting is that I have a word and a series of definitions. The > word is indented, and the definitions are further indented. However, > not really indented, it is just spaces. But you guys said that will > stay. But I have gotten another question after running the program. > Some of the definitions wrap. They don't actually wrap, I need to > set that, they like just go to the very end of the line and then go > to the next line. If that makes sense. But My next question is can > you set a margin in a textbox? > I don't really understand what you want. Check out the options to the Text widget at: http://www.pythonware.com/library/tkinter/introduction/x8896-options.htm You might want to look at wrap, width, setgrid. Regards, John From jmcmonagle at velseis.com.au Sat Jul 5 11:48:12 2008 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Sat, 5 Jul 2008 19:48:12 +1000 Subject: [Tkinter-discuss] re garding labels alignment in PyTkinter GUI In-Reply-To: <18273808.post@talk.nabble.com> References: <18273808.post@talk.nabble.com> Message-ID: <20080705094649.M75323@velseis.com.au> > Hari Om, > > Here iam facing one problem is i created more than one labels > which have different lengths. > > All labels text are displaying(aligned) in center based > on longest label length. (I am not require any textwrapping) > > So how can i aligne all labels text from left side means > left justify. > > Example code is: > ------------------------------------------------- > from Tkinter import * > master = Tk() > w = Label(master, text="AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB", anchor=W, > justify=LEFT) > w.pack() > w1 = Label(master, text="AAAAAAAAAAAAA ", anchor=W, justify=LEFT) > w1.pack() > mainloop() > ---------------------------------- > Output producing is : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB > AAAAAAAAAAAAA > > But i require like this : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB > AAAAAAAAAAAAA > > Kindly help me to solve this problem: > Iam very thankful if i got output like this. > > By urs friend > > Lakshminarayana. You must also anchor the packing. Try the following: from Tkinter import * master = Tk() w = Label(master, text="AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB", anchor=W, justify=LEFT) w.pack(anchor=W) w1 = Label(master, text="AAAAAAAAAAAAA ", anchor=W, justify=LEFT) w1.pack(anchor=W) master.mainloop() Regards, John From Cameron at phaseit.net Sat Jul 5 15:05:32 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sat, 5 Jul 2008 13:05:32 +0000 Subject: [Tkinter-discuss] Taking a Text() widget and saving it to a .txt file In-Reply-To: <18282989.post@talk.nabble.com> References: <18269937.post@talk.nabble.com> <486D8E2B.10407@velseis.com.au> <20080704051459.GA16260@lairds.us> <18282989.post@talk.nabble.com> Message-ID: <20080705130532.GA1699@lairds.us> On Fri, Jul 04, 2008 at 09:53:02AM -0700, Alexnb wrote: . . . > very end of the line and then go to the next line. If that makes sense. But > My next question is can you set a margin in a textbox? . . . You'll want to read up on borderwidth, lmargin1, lmargin2, ... in . From alexnbryan at gmail.com Sat Jul 5 15:40:04 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 5 Jul 2008 06:40:04 -0700 (PDT) Subject: [Tkinter-discuss] Re stating what I want In-Reply-To: <20080705085741.M14435@velseis.com.au> References: <18269937.post@talk.nabble.com> <486D8E2B.10407@velseis.com.au> <20080704051459.GA16260@lairds.us> <18282989.post@talk.nabble.com> <20080705085741.M14435@velseis.com.au> Message-ID: <18292423.post@talk.nabble.com> Okay, right now I have a textbox formatted by spaces. Not good. I need to learn to use the margins but that is a whole other issue I am having. But I am wondering now, can I save the textbox to a file as it looks in the textbox, meaning with the margins set and all. And while on that topic, is it possible to print with those margins? -- View this message in context: http://www.nabble.com/Taking-a-Text%28%29-widget-and-saving-it-to-a-.txt-file-tp18269937p18292423.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 10:19:17 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 01:19:17 -0700 (PDT) Subject: [Tkinter-discuss] Toplevel - failure to understand it Message-ID: <18312052.post@talk.nabble.com> I have a Tkinter app that works for me until I use Toplevel to add a title. My efforts to use Toplevel have confused me, bringing an additional unwelcome blank window that I don't understand how to manage. The question is simply "how do I confer Toplevel methods to a top level PanedWindow and still have the application run in a single window?" Thank you for any direct help or pointers to code that works that I could understand. Regards, Geoff ---------------------------------------------------------- """ Example modified from Fredrik Lundh's 3-paned window on http://effbot.org/tkinterbook/panedwindow.htm """ from Tkinter import * class TkApp(): def __init__(self, parent=None, idtext=''): self.idtext = idtext self.mainpane = PanedWindow(parent) self.mainpane.pack(fill=BOTH, expand=1) self.createWidgets() def createWidgets(self): # left self.left = Label(self.mainpane, text=self.idtext+"left pane") self.mainpane.add(self.left) # right self.right = PanedWindow(self.mainpane, orient=VERTICAL) self.mainpane.add(self.right) # top of the right pane self.top = Label(self.right, text=self.idtext+"top pane") self.right.add(self.top) # botton of the right pane self.bottom = Label(self.right, text=self.idtext+"bottom pane") self.right.add(self.bottom) if __name__ == '__main__': # A window that works but you can't add a title tk1 = TkApp(idtext="App1 ") # comment next line out when using IDLE #mainloop() ---------------------------------------------------------- Alternative main ... if __name__ == '__main__': # A window that works but comes with an additional blank window tk2 = Toplevel() tk2.title("Title2") tk3 = TkApp(tk2, "App2 ") # comment next line out when using IDLE #mainloop() -- View this message in context: http://www.nabble.com/Toplevel---failure-to-understand-it-tp18312052p18312052.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 13:21:15 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 04:21:15 -0700 (PDT) Subject: [Tkinter-discuss] Toplevel - failure to understand it In-Reply-To: <18312052.post@talk.nabble.com> References: <18312052.post@talk.nabble.com> Message-ID: <18314544.post@talk.nabble.com> gegard wrote: > > I have a Tkinter app that works for me until I use Toplevel to add a > title. ... Well, I've found root.wm_title("A title") for the title, so that will do for my immediate needs. Regards, Geoff -- View this message in context: http://www.nabble.com/Toplevel---failure-to-understand-it-tp18312052p18314544.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Mon Jul 7 13:36:17 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 7 Jul 2008 11:36:17 +0000 Subject: [Tkinter-discuss] Toplevel - failure to understand it In-Reply-To: <18312052.post@talk.nabble.com> References: <18312052.post@talk.nabble.com> Message-ID: <20080707113617.GA1469@lairds.us> On Mon, Jul 07, 2008 at 01:19:17AM -0700, gegard wrote: . . . > I have a Tkinter app that works for me until I use Toplevel to add a title. > My efforts to use Toplevel have confused me, bringing an additional > unwelcome blank window that I don't understand how to manage. > > The question is simply "how do I confer Toplevel methods to a top level > PanedWindow and still have the application run in a single window?" > > Thank you for any direct help or pointers to code that works that I could > understand. . . . There are several confusions in what you've written. If I understand correctly, an example of what you'd like is to decorate a PanedWindow with a title. I suspect that the following will interest you: import Tkinter m = Tkinter.PanedWindow(orient = Tkinter.VERTICAL) m.pack(fill = Tkinter.BOTH, expand = 1) top = Tkinter.Label(m, text = "Do you see how wide the top pane is?") m.add(top) bottom = Tkinter.Label(m, text = "bottom pane") m.add(bottom) m.winfo_toplevel().title("look at me") Tkinter.mainloop() From ggardiner at iee.org Mon Jul 7 13:47:47 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 04:47:47 -0700 (PDT) Subject: [Tkinter-discuss] Toplevel - failure to understand it In-Reply-To: <20080707113617.GA1469@lairds.us> References: <18312052.post@talk.nabble.com> <20080707113617.GA1469@lairds.us> Message-ID: <18314933.post@talk.nabble.com> Cameron Laird-2 wrote: > > There are several confusions in what you've written. If > I understand correctly, an example of what you'd like is > to decorate a PanedWindow with a title. Thank you, yes. You've confirmed that I don't actually need Toplevel, which is what I was beginning to realize. I'm sure I do have other confusions but such are their nature and my level that I haven't worked out what they are yet. Regards, Geoff -- View this message in context: http://www.nabble.com/Toplevel---failure-to-understand-it-tp18312052p18314933.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 17:02:14 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 08:02:14 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? Message-ID: <18318831.post@talk.nabble.com> I'm now trying to respond to listbox changes and have two problems illustrated in the example below. The example's an extension of the one that Cameron Laird supplied in a response earlier today. 1) How do I make things happen in the main loop when they do in an instance of SListbox? SListbox.click() runs fine, but I just can't see how to call methods in main. I'd thought that self.master might hold the keys (maybe even literally), but I can't work that out. 2) Why can I not bind to arrow keys (Up in this example)? Arrow keys do not change the list box and, presumably as a consequence, I can't get the SListbox.uparrow() method to run. As ever, thank you for direction. Regards, Geoff -------------------------------------------------------- import Tkinter class SListbox(Tkinter.Frame): # Listbox in a frame, will be linked with other widgets def __init__(self, parent): Tkinter.Frame.__init__(self, parent) self.pack() self.list = Tkinter.Listbox(self) self.list.pack() self.list.bind('', self.click) self.list.bind('', self.uparrow) def append(self, entry): self.list.insert(Tkinter.END, entry) def click(self, args=None) : # This method works, but I don't know how # to make it affect the main loop so that I can act on it print 'Clicked Selection', str(self.list.curselection()) # self.master.... what now? I want to populate the text box. def uparrow(self, args=None) : # This method is never reached print 'Uparrow' m = Tkinter.PanedWindow(orient = Tkinter.VERTICAL) m.pack(fill = Tkinter.BOTH, expand = 1) top = Tkinter.Label(m, text = "Do you see how wide the top pane is?") m.add(top) # New listbox in a frame list = SListbox(m) m.add(list) text = Tkinter.Text(m) m.add(text, height=20, width=10) bottom = Tkinter.Label(m, text = "bottom pane") m.add(bottom) m.winfo_toplevel().title("look at me") for entry in range(20): list.append("entry "+str(entry)) #Tkinter.mainloop() -------------------------------------------------------- -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18318831.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 19:22:40 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 10:22:40 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18318831.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> Message-ID: <18321930.post@talk.nabble.com> gegard wrote: > ...2) Why can I not bind to arrow keys (Up in this example)? Arrow keys do > not change the list box... Aha, the listbox doesn't get the focus, so the arrow keys and any other keyboard events affect some other widget - the last-visited-except-for-the-listbox as far as I can tell. So how can the listbox be made to accept and retain the focus? Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18321930.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 19:34:06 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 10:34:06 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18321930.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <18321930.post@talk.nabble.com> Message-ID: <18322192.post@talk.nabble.com> gegard wrote: > .. So how can the listbox be made to accept and retain the focus?... Getting there: self.list.focus_force() in the click method does it. Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18322192.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Mon Jul 7 19:34:41 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 7 Jul 2008 17:34:41 +0000 Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18321930.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <18321930.post@talk.nabble.com> Message-ID: <20080707173441.GA12031@lairds.us> On Mon, Jul 07, 2008 at 10:22:40AM -0700, gegard wrote: . . . > > ...2) Why can I not bind to arrow keys (Up in this example)? Arrow keys do > > not change the list box... > Aha, the listbox doesn't get the focus, so the arrow keys and any other > keyboard events affect some other widget - the > last-visited-except-for-the-listbox as far as I can tell. So how can the > listbox be made to accept and retain the focus? . . . Also, in terms of the code you posted earlier, you'll want to experiment with self.list.focus_set() From ggardiner at iee.org Mon Jul 7 21:04:50 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 12:04:50 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <20080707173441.GA12031@lairds.us> References: <18318831.post@talk.nabble.com> <18321930.post@talk.nabble.com> <20080707173441.GA12031@lairds.us> Message-ID: <18324219.post@talk.nabble.com> Cameron Laird-2 wrote: > ...you'll want to > experiment with > > self.list.focus_set()... Thank you. Indeed better than focus_force(). Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18324219.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 21:08:57 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 12:08:57 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18318831.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> Message-ID: <18324316.post@talk.nabble.com> So the problem is now reduced to this: gegard wrote: > ...1) How do I make things happen in the main loop when they do in an > instance of SListbox? ... I just can't see how to call methods in main.... I can get the parent from self.master, but there seems to be no visibility of any variables there. Perhaps there's a way of doing that or a way of catching the event at a higher level, but I haven't worked out either possibility yet. Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18324316.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Mon Jul 7 21:13:49 2008 From: ggardiner at iee.org (gegard) Date: Mon, 7 Jul 2008 12:13:49 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18324219.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <18321930.post@talk.nabble.com> <20080707173441.GA12031@lairds.us> <18324219.post@talk.nabble.com> Message-ID: <18324400.post@talk.nabble.com> gegard wrote: > ... better than focus_force().... But I see that I get the index number of the selection _before_ I've moved to a new selected item if I'm using the arrow keys. Another problem to resolve. I guess there's code to learn from somewhere! Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18324400.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Tue Jul 8 02:39:01 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 8 Jul 2008 00:39:01 +0000 Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18324400.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <18321930.post@talk.nabble.com> <20080707173441.GA12031@lairds.us> <18324219.post@talk.nabble.com> <18324400.post@talk.nabble.com> Message-ID: <20080708003901.GA31819@lairds.us> On Mon, Jul 07, 2008 at 12:13:49PM -0700, gegard wrote: . . . > But I see that I get the index number of the selection _before_ I've moved > to a new selected item if I'm using the arrow keys. Another problem to > resolve. I guess there's code to learn from somewhere! . . . Yes. This is a well-known issue, that's been present for at least a decade, and apparently no one has ever put the answer in a readily accessible place. And I am unlikely to do so in the next day. Briefly, you need to use bindtags to insert your custom bindings AFTER the standard bindings. For reasons that must seem obscure for the moment, your command is sequenced before the listbox does its own work of updating the selection; bindtag gives you the control to reverse that order. From alexnbryan at gmail.com Tue Jul 8 08:59:47 2008 From: alexnbryan at gmail.com (Alexnb) Date: Mon, 7 Jul 2008 23:59:47 -0700 (PDT) Subject: [Tkinter-discuss] Creating a tag, and setting a margin Message-ID: <18333029.post@talk.nabble.com> Okay, this may sound noobish, but I just cannot figure this out. I am trying to set a tag in a Text widget of mine, but I don't know how and I am also trying to set a margin for the tag, but I have no clue how to do either! Please help this poor noob! -- View this message in context: http://www.nabble.com/Creating-a-tag%2C-and-setting-a-margin-tp18333029p18333029.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Tue Jul 8 10:08:29 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 8 Jul 2008 10:08:29 +0200 Subject: [Tkinter-discuss] Creating a tag, and setting a margin In-Reply-To: <18333029.post@talk.nabble.com> References: <18333029.post@talk.nabble.com> Message-ID: <47e491110807080108l2bfa2877q640f2108d887471e@mail.gmail.com> On Tue, Jul 8, 2008 at 8:59 AM, Alexnb wrote: > > Okay, this may sound noobish, but I just cannot figure this out. I am trying > to set a tag in a Text widget of mine, but I don't know how and I am also > trying to set a margin for the tag, but I have no clue how to do either! from Tkinter import* root = Tk() twgt=Text(root) twgt.pack(expand=True, fill=BOTH) twgt.insert(END, "This text has no margin.\n\n") twgt.insert(END, "This text has a margin.\n\n", ("marg")) twgt.insert(END, "This text has no margin.\n\n") twgt.tag_config("marg", lmargin1=15, lmargin2=15) root.mainloop() From Vasilis.Vlachoudis at cern.ch Tue Jul 8 10:51:39 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 8 Jul 2008 10:51:39 +0200 Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18318831.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> Message-ID: <48732A9B.1080401@cern.ch> The best solution I found on the web to overcome the binding problem is to use the <> event, which is called after a change in the selection of the list self.list.bind("<>", self.listChanged) def listChanged(self, event): print "selection=",self.list.curselection() gegard wrote: > I'm now trying to respond to listbox changes and have two problems > illustrated in the example below. The example's an extension of the one that > Cameron Laird supplied in a response earlier today. > > 1) How do I make things happen in the main loop when they do in an instance > of SListbox? SListbox.click() runs fine, but I just can't see how to call > methods in main. I'd thought that self.master might hold the keys (maybe > even literally), but I can't work that out. > > 2) Why can I not bind to arrow keys (Up in this example)? Arrow keys do not > change the list box and, presumably as a consequence, I can't get the > SListbox.uparrow() method to run. > > As ever, thank you for direction. > > Regards, Geoff > > -------------------------------------------------------- > import Tkinter > > class SListbox(Tkinter.Frame): > # Listbox in a frame, will be linked with other widgets > def __init__(self, parent): > Tkinter.Frame.__init__(self, parent) > self.pack() > self.list = Tkinter.Listbox(self) > self.list.pack() > self.list.bind('', self.click) > self.list.bind('', self.uparrow) > > def append(self, entry): > self.list.insert(Tkinter.END, entry) > > def click(self, args=None) : > # This method works, but I don't know how > # to make it affect the main loop so that I can act on it > print 'Clicked Selection', str(self.list.curselection()) > # self.master.... what now? I want to populate the text box. > > > > def uparrow(self, args=None) : > # This method is never reached > print 'Uparrow' > > m = Tkinter.PanedWindow(orient = Tkinter.VERTICAL) > m.pack(fill = Tkinter.BOTH, expand = 1) > top = Tkinter.Label(m, text = "Do you see how wide the top pane is?") > m.add(top) > # New listbox in a frame > list = SListbox(m) > m.add(list) > text = Tkinter.Text(m) > m.add(text, height=20, width=10) > bottom = Tkinter.Label(m, text = "bottom pane") > m.add(bottom) > > m.winfo_toplevel().title("look at me") > for entry in range(20): > list.append("entry "+str(entry)) > #Tkinter.mainloop() > > -------------------------------------------------------- > -------------- next part -------------- A non-text attachment was scrubbed... Name: Vasilis_Vlachoudis.vcf Type: text/x-vcard Size: 312 bytes Desc: not available URL: From ggardiner at iee.org Tue Jul 8 11:14:40 2008 From: ggardiner at iee.org (gegard) Date: Tue, 8 Jul 2008 02:14:40 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18324316.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <18324316.post@talk.nabble.com> Message-ID: <18335037.post@talk.nabble.com> gegard wrote: > ... or a way of catching the event at a higher level ... I'm taking this approach, because I've sorted out how it works (and have not yet worked out [if I can|how to] make the parent object methods visible). So the binding and the click() are now at the top level. Regards, Geoff ------------------------------------------------------- .... list.bind('', click) def click(args=None) : print 'Clicked Selection', str(list.curselection()) .... ------------------------------------------------------- -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18335037.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggardiner at iee.org Tue Jul 8 11:48:09 2008 From: ggardiner at iee.org (gegard) Date: Tue, 8 Jul 2008 02:48:09 -0700 (PDT) Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <48732A9B.1080401@cern.ch> References: <18318831.post@talk.nabble.com> <48732A9B.1080401@cern.ch> Message-ID: <18335536.post@talk.nabble.com> Vasilis Vlachoudis wrote: > ... use the <> event... That works perfectly, thank you. I'm very grateful. That's in none of the main resources I was using (effbot.org, NMT, an early copy of Mark Lutz, and the tk-lib files in the python installation), except for a comment contributed by 'Chris' at the bottom of http://effbot.org/tkinterbook/listbox.htm. Regards, Geoff -- View this message in context: http://www.nabble.com/Method-calling-upwards--Listbox-arrow-events---tp18318831p18335536.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Tue Jul 8 15:04:03 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 8 Jul 2008 13:04:03 +0000 Subject: [Tkinter-discuss] Method calling upwards; Listbox arrow events ? In-Reply-To: <18335536.post@talk.nabble.com> References: <18318831.post@talk.nabble.com> <48732A9B.1080401@cern.ch> <18335536.post@talk.nabble.com> Message-ID: <20080708130403.GA11803@lairds.us> On Tue, Jul 08, 2008 at 02:48:09AM -0700, gegard wrote: . . . > > ... use the <> event... > That works perfectly, thank you. I'm very grateful. > > That's in none of the main resources I was using (effbot.org, NMT, an early > copy of Mark Lutz, and the tk-lib files in the python installation), except > for a comment contributed by 'Chris' at the bottom of > http://effbot.org/tkinterbook/listbox.htm. . . . Right: we *really* need to write this up for our Wiki . In particular, we need to document the appearance of , which only became available with version ... well, that'll be one of the points to research. So, gegard, my sympathies for the difficulties you've faced. While there's a lot of good documentation available--and a know you've been studying quite a bit of it--there are also significant gaps which constitute considerable annoyances. I hope Tkinter rewards you enough to persevere in spite of them. From comp.ogz at gmail.com Tue Jul 8 18:54:53 2008 From: comp.ogz at gmail.com (Oguz Yarimtepe) Date: Tue, 8 Jul 2008 19:54:53 +0300 Subject: [Tkinter-discuss] binding and overrideredirect problem Message-ID: <20831c740807080954h2e837ab6l17c3d9bef38630e6@mail.gmail.com> Hi, I have a problem about using overrideredirect(1) and binding events to the keys. At my application i am creating root and binding an action to a ke press as: self.root = Tk() #self.root.overrideredirect(1) self.root.focus() #self.frame.pack() self.root.bind('', self.action) self.root.title("Status") The action method is as: def action(self,event): #print event.keycode if event.keycode == self.actionkey: self.showImage() So when i press a key i want to a different image on the screen: def showImage(self): im = Image.open(imageName) xlocation = 440 ylocation = 640 width = im.size[0]+20 height = im.size[1]+20 newgeometry = str(width)+"x"+str(height)+"+"+str(xlocation)+"+"+str(ylocation) self.root.geometry(newgeometry) self.root.protocol('WM_DELETE_WINDOW', self.doExit) # add 20 to account for border defined in create_image self.canvas = Canvas(self.root, height=im.size[1]+20, width=im.size[0]+20) self.canvas.pack(side=LEFT,fill=BOTH,expand=1) photo = ImageTk.PhotoImage(im) item = self.canvas.create_image(10,10,anchor=NW, image=photo) self.canvas.update() self.root.mainloop() if i comment out the self.root.overrideredirect(1) part, i can see the winowless gui but i am not able to catch the keypress events this time. The application is working nice without the self.root.overrideredirect(1) part. But i want ti have windowless application, how can i fix it? I didn't put the whole code above, just the related part. As you can guess, i have a class definition. -- O?uz Yar?mtepe From alexnbryan at gmail.com Thu Jul 10 10:05:05 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 01:05:05 -0700 (PDT) Subject: [Tkinter-discuss] Best way to create a loading type bar or dot.... Message-ID: <18377620.post@talk.nabble.com> This may be hard to explain using text, but you have all seen one. What I need to do is to create an object like a loading bar ( a bar like the little bar that comes up when you boot into xp or the circle that comes up when you boot into mac or on the tabs in firefox) or I would like a dot, that starts grey or red and goes to green once the action is completed. The action is getting something from the internet. But I am wondering what is the best way to go about doing this in Tkinter, I am thinking maybe a canvas thing? I have never used the canvas aspect but I am just wondering what is the best way to do such a thing? Oh and I forgot, but on the loading bar I don't care if it is timed right, I just want it to like go from empty to full, over and over again and stay full when the information is received. So I would love your input! -- View this message in context: http://www.nabble.com/Best-way-to-create-a-loading-type-bar-or-dot....-tp18377620p18377620.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From mfranklin1 at gatwick.westerngeco.slb.com Thu Jul 10 10:52:48 2008 From: mfranklin1 at gatwick.westerngeco.slb.com (Martin Franklin) Date: Thu, 10 Jul 2008 09:52:48 +0100 Subject: [Tkinter-discuss] Best way to create a loading type bar or dot.... In-Reply-To: <0K3S00F026INS8@eurmta01.london.eur.slb.com> References: <0K3S00F026INS8@eurmta01.london.eur.slb.com> Message-ID: <4875CDE0.9010104@gatwick.westerngeco.slb.com> Alexnb wrote: > This may be hard to explain using text, but you have all seen one. What I > need to do is to create an object like a loading bar ( a bar like the little > bar that comes up when you boot into xp or the circle that comes up when you > boot into mac or on the tabs in firefox) or I would like a dot, that starts > grey or red and goes to green once the action is completed. The action is > getting something from the internet. But I am wondering what is the best way > to go about doing this in Tkinter, I am thinking maybe a canvas thing? I > have never used the canvas aspect but I am just wondering what is the best > way to do such a thing? Oh and I forgot, but on the loading bar I don't care > if it is timed right, I just want it to like go from empty to full, over and > over again and stay full when the information is received. So I would love > your input! Google for busy bar, or progress bar indeterminate or something like that you'll find lots of examples one here :- http://tkinter.unpythonic.net/wiki/BusyBar Is one that I've used. Cheers Martin -- signature file not found, must be something I ate From michael.odonnell at uam.es Thu Jul 10 19:07:08 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 10 Jul 2008 19:07:08 +0200 Subject: [Tkinter-discuss] Tkinter with Tk8.5 ? Message-ID: <47e491110807101007o3252e374le51997d15ad7fd16@mail.gmail.com> Hi All, Does anyone know when Tkinter will be released using Tk8.5? (My Tkinter application does not display unicode text on MacOSX and I understand this is fixed in tk8.5). Barring that,has anyone successfully linked the TK8.5 libraries to python 2.5 under MacOSX? Mick From kw at codebykevin.com Thu Jul 10 19:20:56 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 10 Jul 2008 13:20:56 -0400 Subject: [Tkinter-discuss] Tkinter with Tk8.5 ? In-Reply-To: <47e491110807101007o3252e374le51997d15ad7fd16@mail.gmail.com> References: <47e491110807101007o3252e374le51997d15ad7fd16@mail.gmail.com> Message-ID: <487644F8.9030203@codebykevin.com> Michael O'Donnell wrote: > Does anyone know when Tkinter will be released using Tk8.5? > (My Tkinter application does not display unicode text on MacOSX > and I understand this is fixed in tk8.5). > > Barring that,has anyone successfully linked the TK8.5 libraries > to python 2.5 under MacOSX? > To do this, you'll have to build Python yourself from source and link it against a framework build of Tk 8.5. Here's how I do it: 1. Install or build Tk 8.5 in /Library/Frameworks. 2. Download the Python source code. 3. In setup.py, comment out "/System/Library/Frameworks" as a place to look for Tk--this will keep Python from linking about the Tk installed by default on OS X (8.4.7). 4. Build as usual. It will link to Tk 8.5. There is currently no special support in Tkinter for some of the new goodies in Tk 8.5, such as the native theming stuff, but that's in the works: http://gpolo.ath.cx:81/projects/ttk_to_tkinter/ Hope this helps, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Thu Jul 10 22:57:51 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 13:57:51 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it Message-ID: <18391735.post@talk.nabble.com> Okay, so I have a for loop with a sleep command. I want the loop to continue until it is told to stop. I want to tell it to stop when a list goes from empty to having something. The problem is that when that loop starts, the program pretty much stops with it. To make things harder, I really want that to be it's own class, so I have to pass it the list that triggers the stopping, but I can only pass it the list once. So I don't think it is possible. But if this made sense to anyone, and you have a suggestion I would love it. Heres the full code: (but at the bottom, the Open function is really the only thing that matters) from Tkinter import * import time class BusyBar(Frame): def __init__(self, master=None, **options): # make sure we have sane defaults self.master=master self.options=options self.width=options.setdefault('width', 300) self.height=options.setdefault('height', 20) self.background=options.setdefault('background', 'white') self.relief=options.setdefault('relief', 'sunken') self.bd=options.setdefault('bd', 2) #extract options not applicable to frames self._extractOptions(options) # init the base class Frame.__init__(self, master, options) self.incr=self.width*self.increment self.busy=0 self.dir='right' # create the canvas which is the container for the bar self.canvas=Canvas(self, height=self.height, width=self.width, bd=0, highlightthickness=0, background=self.background) # catch canvas resizes self.canvas.bind('', self.onSize) # this is the bar that moves back and forth on the canvas self.scale=self.canvas.create_rectangle(0, 0, self.width*self.barWidth, self.height, fill=self.fill, width = 0) # label that is in the center of the widget self.label=self.canvas.create_text(self.canvas.winfo_reqwidth() / 2, self.height / 2, text=self.text, anchor="c", fill=self.foreground, font=self.font) self.update() self.canvas.pack(side=TOP, fill=X, expand=NO) def _extractOptions(self, options): # these are the options not applicable to a frame self.foreground=pop(options, 'foreground', 'white') self.fill=pop(options, 'fill', 'black') self.interval=pop(options, 'interval', 30) self.font=pop(options, 'font','arial 12') self.text=pop(options, 'text', '') self.barWidth=pop(options, 'barWidth', 0.2) self.increment=pop(options, 'increment', 0.05) # todo - need to implement config, cget, __setitem__, __getitem__ so it's more like a reg widget # as it is now, you get a chance to set stuff at the constructor but not after def onSize(self, e=None): self.width = e.width self.height = e.height # make sure the label is centered self.canvas.delete(self.label) self.label=self.canvas.create_text(self.width / 2, self.height / 2, text=self.text, anchor="c", fill=self.foreground, font=self.font) def on(self): self.busy = 1 self.canvas.after(self.interval, self.update) def of(self): self.busy = 0 def update(self): # do the move x1,y1,x2,y2 = self.canvas.coords(self.scale) if x2>=self.width: self.dir='left' if x1<=0: self.dir='right' if self.dir=='right': self.canvas.move(self.scale, self.incr, 0) else: self.canvas.move(self.scale, -1*self.incr, 0) if self.busy: self.canvas.after(self.interval, self.update) self.canvas.update_idletasks() def pop(dict, key, default): value = dict.get(key, default) if dict.has_key(key): del dict[key] return value #if __name__=='__main__': #-----------------------------IMPORTANT STUFF------------------------------------------------- def Open(root): bb = BusyBar(root, text='Grabbing Definitions') bb.pack(side=LEFT, expand=NO) bb.on() root.update_idletasks() for i in range(0, 100): time.sleep(0.1) root.update() bb.of() and the Open fucntion is with I would be calling from another program. -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18391735.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Thu Jul 10 23:22:45 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 10 Jul 2008 18:22:45 -0300 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18391735.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> Message-ID: On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: > > Okay, so I have a for loop with a sleep command. I want the loop to continue > until it is told to stop. I want to tell it to stop when a list goes from > empty to having something. The problem is that when that loop starts, the > program pretty much stops with it. You need to remove the use of sleep and use "after" instead. You keep scheduling your task till the condition is not met anymore, then you stop scheduling it with "after". > To make things harder, I really want that > to be it's own class, so I have to pass it the list that triggers the > stopping, but I can only pass it the list once. So I don't think it is > possible. It is, just pass some other object along which can call the method "after". > But if this made sense to anyone, and you have a suggestion I > would love it. Heres the full code: (but at the bottom, the Open function is > really the only thing that matters) > If you want help based on code, you have to post a short-enough code that demonstrates the problem. > from Tkinter import * > import time > > class BusyBar(Frame): > def __init__(self, master=None, **options): > # make sure we have sane defaults > self.master=master > self.options=options > self.width=options.setdefault('width', 300) > self.height=options.setdefault('height', 20) > self.background=options.setdefault('background', 'white') > self.relief=options.setdefault('relief', 'sunken') > self.bd=options.setdefault('bd', 2) > > #extract options not applicable to frames > self._extractOptions(options) > > # init the base class > Frame.__init__(self, master, options) > > self.incr=self.width*self.increment > self.busy=0 > self.dir='right' > > # create the canvas which is the container for the bar > self.canvas=Canvas(self, height=self.height, width=self.width, bd=0, > highlightthickness=0, background=self.background) > # catch canvas resizes > self.canvas.bind('', self.onSize) > > # this is the bar that moves back and forth on the canvas > self.scale=self.canvas.create_rectangle(0, 0, > self.width*self.barWidth, self.height, fill=self.fill, width = 0) > > # label that is in the center of the widget > self.label=self.canvas.create_text(self.canvas.winfo_reqwidth() / 2, > self.height / 2, text=self.text, > anchor="c", fill=self.foreground, > font=self.font) > self.update() > self.canvas.pack(side=TOP, fill=X, expand=NO) > > def _extractOptions(self, options): > # these are the options not applicable to a frame > self.foreground=pop(options, 'foreground', 'white') > self.fill=pop(options, 'fill', 'black') > self.interval=pop(options, 'interval', 30) > self.font=pop(options, 'font','arial 12') > self.text=pop(options, 'text', '') > self.barWidth=pop(options, 'barWidth', 0.2) > self.increment=pop(options, 'increment', 0.05) > > # todo - need to implement config, cget, __setitem__, __getitem__ so > it's more like a reg widget > # as it is now, you get a chance to set stuff at the constructor but not > after > > def onSize(self, e=None): > self.width = e.width > self.height = e.height > # make sure the label is centered > self.canvas.delete(self.label) > self.label=self.canvas.create_text(self.width / 2, self.height / 2, > text=self.text, > anchor="c", fill=self.foreground, > font=self.font) > > def on(self): > self.busy = 1 > self.canvas.after(self.interval, self.update) > > def of(self): > self.busy = 0 > > def update(self): > # do the move > x1,y1,x2,y2 = self.canvas.coords(self.scale) > if x2>=self.width: > self.dir='left' > if x1<=0: > self.dir='right' > if self.dir=='right': > self.canvas.move(self.scale, self.incr, 0) > else: > self.canvas.move(self.scale, -1*self.incr, 0) > > if self.busy: > self.canvas.after(self.interval, self.update) > self.canvas.update_idletasks() > > def pop(dict, key, default): > value = dict.get(key, default) > if dict.has_key(key): > del dict[key] > return value > > > #if __name__=='__main__': > > #-----------------------------IMPORTANT > STUFF------------------------------------------------- > def Open(root): > > bb = BusyBar(root, text='Grabbing Definitions') > bb.pack(side=LEFT, expand=NO) > > bb.on() > root.update_idletasks() > for i in range(0, 100): > time.sleep(0.1) > root.update() > bb.of() > > and the Open fucntion is with I would be calling from another program. > -- > View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18391735.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Fri Jul 11 00:31:24 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 15:31:24 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: References: <18391735.post@talk.nabble.com> Message-ID: <18393290.post@talk.nabble.com> Guilherme Polo wrote: > > On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >> >> Okay, so I have a for loop with a sleep command. I want the loop to >> continue >> until it is told to stop. I want to tell it to stop when a list goes from >> empty to having something. The problem is that when that loop starts, the >> program pretty much stops with it. > > You need to remove the use of sleep and use "after" instead. You keep > scheduling your task till the condition is not met anymore, then you > stop scheduling it with "after". > >> To make things harder, I really want that >> to be it's own class, so I have to pass it the list that triggers the >> stopping, but I can only pass it the list once. So I don't think it is >> possible. > > It is, just pass some other object along which can call the method > "after". > >> But if this made sense to anyone, and you have a suggestion I >> would love it. Heres the full code: (but at the bottom, the Open function >> is >> really the only thing that matters) >> > > If you want help based on code, you have to post a short-enough code > that demonstrates the problem. > >> from Tkinter import * >> import time >> >> class BusyBar(Frame): >> def __init__(self, master=None, **options): >> # make sure we have sane defaults >> self.master=master >> self.options=options >> self.width=options.setdefault('width', 300) >> self.height=options.setdefault('height', 20) >> self.background=options.setdefault('background', 'white') >> self.relief=options.setdefault('relief', 'sunken') >> self.bd=options.setdefault('bd', 2) >> >> #extract options not applicable to frames >> self._extractOptions(options) >> >> # init the base class >> Frame.__init__(self, master, options) >> >> self.incr=self.width*self.increment >> self.busy=0 >> self.dir='right' >> >> # create the canvas which is the container for the bar >> self.canvas=Canvas(self, height=self.height, width=self.width, >> bd=0, >> highlightthickness=0, >> background=self.background) >> # catch canvas resizes >> self.canvas.bind('', self.onSize) >> >> # this is the bar that moves back and forth on the canvas >> self.scale=self.canvas.create_rectangle(0, 0, >> self.width*self.barWidth, self.height, fill=self.fill, width = 0) >> >> # label that is in the center of the widget >> self.label=self.canvas.create_text(self.canvas.winfo_reqwidth() / >> 2, >> self.height / 2, >> text=self.text, >> anchor="c", >> fill=self.foreground, >> font=self.font) >> self.update() >> self.canvas.pack(side=TOP, fill=X, expand=NO) >> >> def _extractOptions(self, options): >> # these are the options not applicable to a frame >> self.foreground=pop(options, 'foreground', 'white') >> self.fill=pop(options, 'fill', 'black') >> self.interval=pop(options, 'interval', 30) >> self.font=pop(options, 'font','arial 12') >> self.text=pop(options, 'text', '') >> self.barWidth=pop(options, 'barWidth', 0.2) >> self.increment=pop(options, 'increment', 0.05) >> >> # todo - need to implement config, cget, __setitem__, __getitem__ so >> it's more like a reg widget >> # as it is now, you get a chance to set stuff at the constructor but >> not >> after >> >> def onSize(self, e=None): >> self.width = e.width >> self.height = e.height >> # make sure the label is centered >> self.canvas.delete(self.label) >> self.label=self.canvas.create_text(self.width / 2, self.height / >> 2, >> text=self.text, >> anchor="c", >> fill=self.foreground, >> font=self.font) >> >> def on(self): >> self.busy = 1 >> self.canvas.after(self.interval, self.update) >> >> def of(self): >> self.busy = 0 >> >> def update(self): >> # do the move >> x1,y1,x2,y2 = self.canvas.coords(self.scale) >> if x2>=self.width: >> self.dir='left' >> if x1<=0: >> self.dir='right' >> if self.dir=='right': >> self.canvas.move(self.scale, self.incr, 0) >> else: >> self.canvas.move(self.scale, -1*self.incr, 0) >> >> if self.busy: >> self.canvas.after(self.interval, self.update) >> self.canvas.update_idletasks() >> >> def pop(dict, key, default): >> value = dict.get(key, default) >> if dict.has_key(key): >> del dict[key] >> return value >> >> >> #if __name__=='__main__': >> >> #-----------------------------IMPORTANT >> STUFF------------------------------------------------- >> def Open(root): >> >> bb = BusyBar(root, text='Grabbing Definitions') >> bb.pack(side=LEFT, expand=NO) >> >> bb.on() >> root.update_idletasks() >> for i in range(0, 100): >> time.sleep(0.1) >> root.update() >> bb.of() >> >> and the Open fucntion is with I would be calling from another program. >> -- >> View this message in context: >> http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18391735.html >> Sent from the Python - tkinter-discuss mailing list archive at >> Nabble.com. >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Okay, so I modified the bottom code to this: def Open(root): bb = BusyBar(root, text='Grabbing Definitions') bb.pack(side=LEFT, expand=NO) def sleeper(): root.update root.after(1, sleeper) bb.on() root.update_idletasks() sleeper() #for i in range(0, 100): #time.sleep(0.1) #root.update() bb.of() but it doesn't repeat. What am I missing? -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18393290.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Fri Jul 11 00:52:50 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 10 Jul 2008 19:52:50 -0300 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18393290.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> Message-ID: On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: > > > > Guilherme Polo wrote: >> >> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >>> >>> Okay, so I have a for loop with a sleep command. I want the loop to >>> continue >>> until it is told to stop. I want to tell it to stop when a list goes from >>> empty to having something. The problem is that when that loop starts, the >>> program pretty much stops with it. >> >> You need to remove the use of sleep and use "after" instead. You keep >> scheduling your task till the condition is not met anymore, then you >> stop scheduling it with "after". >> >>> To make things harder, I really want that >>> to be it's own class, so I have to pass it the list that triggers the >>> stopping, but I can only pass it the list once. So I don't think it is >>> possible. >> >> It is, just pass some other object along which can call the method >> "after". >> >>> But if this made sense to anyone, and you have a suggestion I >>> would love it. Heres the full code: (but at the bottom, the Open function >>> is >>> really the only thing that matters) >>> >> >> If you want help based on code, you have to post a short-enough code >> that demonstrates the problem. >> >>> from Tkinter import * >>> import time >>> >>> class BusyBar(Frame): >>> ... >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > Okay, so I modified the bottom code to this: > > def Open(root): > > bb = BusyBar(root, text='Grabbing Definitions') > bb.pack(side=LEFT, expand=NO) > > > def sleeper(): > root.update What if you change this to root.update() ? > root.after(1, sleeper) after works with milliseconds, not seconds, be aware. > bb.on() > root.update_idletasks() > > sleeper() > > #for i in range(0, 100): > #time.sleep(0.1) > #root.update() > bb.of() > > but it doesn't repeat. What am I missing? > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Fri Jul 11 01:24:47 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 16:24:47 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> Message-ID: <18394006.post@talk.nabble.com> Guilherme Polo wrote: > > On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: >> >> >> >> Guilherme Polo wrote: >>> >>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >>>> >>>> Okay, so I have a for loop with a sleep command. I want the loop to >>>> continue >>>> until it is told to stop. I want to tell it to stop when a list goes >>>> from >>>> empty to having something. The problem is that when that loop starts, >>>> the >>>> program pretty much stops with it. >>> >>> You need to remove the use of sleep and use "after" instead. You keep >>> scheduling your task till the condition is not met anymore, then you >>> stop scheduling it with "after". >>> >>>> To make things harder, I really want that >>>> to be it's own class, so I have to pass it the list that triggers the >>>> stopping, but I can only pass it the list once. So I don't think it is >>>> possible. >>> >>> It is, just pass some other object along which can call the method >>> "after". >>> >>>> But if this made sense to anyone, and you have a suggestion I >>>> would love it. Heres the full code: (but at the bottom, the Open >>>> function >>>> is >>>> really the only thing that matters) >>>> >>> >>> If you want help based on code, you have to post a short-enough code >>> that demonstrates the problem. >>> >>>> from Tkinter import * >>>> import time >>>> >>>> class BusyBar(Frame): >>>> ... >>> >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> _______________________________________________ >>> Tkinter-discuss mailing list >>> Tkinter-discuss at python.org >>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>> >>> >> >> Okay, so I modified the bottom code to this: >> >> def Open(root): >> >> bb = BusyBar(root, text='Grabbing Definitions') >> bb.pack(side=LEFT, expand=NO) >> >> >> def sleeper(): >> root.update > > What if you change this to root.update() ? > >> root.after(1, sleeper) > > after works with milliseconds, not seconds, be aware. > >> bb.on() >> root.update_idletasks() >> >> sleeper() >> >> #for i in range(0, 100): >> #time.sleep(0.1) >> #root.update() >> bb.of() >> >> but it doesn't repeat. What am I missing? >> > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Well, what was happening before is that the bar would just be at a standstill. After making it update() it moved a little, but was just a standstill at a different place, if that makes sense. Any more ideas? heres the code: def Open(root): bb = BusyBar(root, text='Grabbing Definitions') bb.pack(side=LEFT, expand=NO) bb.on() root.update_idletasks() def sleeper(): root.update() root.after(1, sleeper) sleeper() #for i in range(0, 100): #time.sleep(0.1) #root.update() bb.of() -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18394006.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Fri Jul 11 01:45:48 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 10 Jul 2008 20:45:48 -0300 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18394006.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> Message-ID: On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: > > > > Guilherme Polo wrote: >> >> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: >>> >>> >>> >>> Guilherme Polo wrote: >>>> >>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >>>>> >>>>> Okay, so I have a for loop with a sleep command. I want the loop to >>>>> continue >>>>> until it is told to stop. I want to tell it to stop when a list goes >>>>> from >>>>> empty to having something. The problem is that when that loop starts, >>>>> the >>>>> program pretty much stops with it. >>>> >>>> You need to remove the use of sleep and use "after" instead. You keep >>>> scheduling your task till the condition is not met anymore, then you >>>> stop scheduling it with "after". >>>> >>>>> To make things harder, I really want that >>>>> to be it's own class, so I have to pass it the list that triggers the >>>>> stopping, but I can only pass it the list once. So I don't think it is >>>>> possible. >>>> >>>> It is, just pass some other object along which can call the method >>>> "after". >>>> >>>>> But if this made sense to anyone, and you have a suggestion I >>>>> would love it. Heres the full code: (but at the bottom, the Open >>>>> function >>>>> is >>>>> really the only thing that matters) >>>>> >>>> >>>> If you want help based on code, you have to post a short-enough code >>>> that demonstrates the problem. >>>> >>>>> from Tkinter import * >>>>> import time >>>>> >>>>> class BusyBar(Frame): >>>>> ... >>>> >>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>>> _______________________________________________ >>>> Tkinter-discuss mailing list >>>> Tkinter-discuss at python.org >>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>> >>>> >>> >>> Okay, so I modified the bottom code to this: >>> >>> def Open(root): >>> >>> bb = BusyBar(root, text='Grabbing Definitions') >>> bb.pack(side=LEFT, expand=NO) >>> >>> >>> def sleeper(): >>> root.update >> >> What if you change this to root.update() ? >> >>> root.after(1, sleeper) >> >> after works with milliseconds, not seconds, be aware. >> >>> bb.on() >>> root.update_idletasks() >>> >>> sleeper() >>> >>> #for i in range(0, 100): >>> #time.sleep(0.1) >>> #root.update() >>> bb.of() >>> >>> but it doesn't repeat. What am I missing? >>> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > Well, what was happening before is that the bar would just be at a > standstill. After making it update() it moved a little, but was just a > standstill at a different place, if that makes sense. Any more ideas? heres > the code: > > def Open(root): > > bb = BusyBar(root, text='Grabbing Definitions') > bb.pack(side=LEFT, expand=NO) > > bb.on() > root.update_idletasks() > > def sleeper(): > root.update() > root.after(1, sleeper) Did you ignore my last email where I said after takes milliseconds, not seconds ? And this will forever, not what you want apparently. > > sleeper() > > #for i in range(0, 100): > #time.sleep(0.1) > #root.update() > bb.of() The code you have pasted in the last two emails don't show the problem you are having. I guess someone else will have to look at your entire code to give more help. > > -- > View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18394006.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Fri Jul 11 01:47:03 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Thu, 10 Jul 2008 20:47:03 -0300 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> Message-ID: On Thu, Jul 10, 2008 at 8:45 PM, Guilherme Polo wrote: > On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: >> >> >> >> Guilherme Polo wrote: >>> >>> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: >>>> >>>> >>>> >>>> Guilherme Polo wrote: >>>>> >>>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >>>>>> >>>>>> Okay, so I have a for loop with a sleep command. I want the loop to >>>>>> continue >>>>>> until it is told to stop. I want to tell it to stop when a list goes >>>>>> from >>>>>> empty to having something. The problem is that when that loop starts, >>>>>> the >>>>>> program pretty much stops with it. >>>>> >>>>> You need to remove the use of sleep and use "after" instead. You keep >>>>> scheduling your task till the condition is not met anymore, then you >>>>> stop scheduling it with "after". >>>>> >>>>>> To make things harder, I really want that >>>>>> to be it's own class, so I have to pass it the list that triggers the >>>>>> stopping, but I can only pass it the list once. So I don't think it is >>>>>> possible. >>>>> >>>>> It is, just pass some other object along which can call the method >>>>> "after". >>>>> >>>>>> But if this made sense to anyone, and you have a suggestion I >>>>>> would love it. Heres the full code: (but at the bottom, the Open >>>>>> function >>>>>> is >>>>>> really the only thing that matters) >>>>>> >>>>> >>>>> If you want help based on code, you have to post a short-enough code >>>>> that demonstrates the problem. >>>>> >>>>>> from Tkinter import * >>>>>> import time >>>>>> >>>>>> class BusyBar(Frame): >>>>>> ... >>>>> >>>>> >>>>> >>>>> -- >>>>> -- Guilherme H. Polo Goncalves >>>>> _______________________________________________ >>>>> Tkinter-discuss mailing list >>>>> Tkinter-discuss at python.org >>>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>> >>>>> >>>> >>>> Okay, so I modified the bottom code to this: >>>> >>>> def Open(root): >>>> >>>> bb = BusyBar(root, text='Grabbing Definitions') >>>> bb.pack(side=LEFT, expand=NO) >>>> >>>> >>>> def sleeper(): >>>> root.update >>> >>> What if you change this to root.update() ? >>> >>>> root.after(1, sleeper) >>> >>> after works with milliseconds, not seconds, be aware. >>> >>>> bb.on() >>>> root.update_idletasks() >>>> >>>> sleeper() >>>> >>>> #for i in range(0, 100): >>>> #time.sleep(0.1) >>>> #root.update() >>>> bb.of() >>>> >>>> but it doesn't repeat. What am I missing? >>>> >>> >>> >>> -- >>> -- Guilherme H. Polo Goncalves >>> _______________________________________________ >>> Tkinter-discuss mailing list >>> Tkinter-discuss at python.org >>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>> >>> >> >> Well, what was happening before is that the bar would just be at a >> standstill. After making it update() it moved a little, but was just a >> standstill at a different place, if that makes sense. Any more ideas? heres >> the code: >> >> def Open(root): >> >> bb = BusyBar(root, text='Grabbing Definitions') >> bb.pack(side=LEFT, expand=NO) >> >> bb.on() >> root.update_idletasks() >> >> def sleeper(): >> root.update() >> root.after(1, sleeper) > > Did you ignore my last email where I said after takes milliseconds, > not seconds ? And this will forever, not what you want apparently. > I forgot a word there, "... And this will run forever ...", sorry >> >> sleeper() >> >> #for i in range(0, 100): >> #time.sleep(0.1) >> #root.update() >> bb.of() > > The code you have pasted in the last two emails don't show the problem > you are having. I guess someone else will have to look at your entire > code to give more help. > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Fri Jul 11 07:30:53 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 22:30:53 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> Message-ID: <18397021.post@talk.nabble.com> yes I know it runs in milliseconds. So what do you suggest? 1 millisecond is about what I want. it was .1 seconds for the sleep() time. I didn't write this code I found it online so I don't really understand it, but I know that is where the problem is, the for loop. Guilherme Polo wrote: > > On Thu, Jul 10, 2008 at 8:45 PM, Guilherme Polo wrote: >> On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: >>> >>> >>> >>> Guilherme Polo wrote: >>>> >>>> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: >>>>> >>>>> >>>>> >>>>> Guilherme Polo wrote: >>>>>> >>>>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: >>>>>>> >>>>>>> Okay, so I have a for loop with a sleep command. I want the loop to >>>>>>> continue >>>>>>> until it is told to stop. I want to tell it to stop when a list goes >>>>>>> from >>>>>>> empty to having something. The problem is that when that loop >>>>>>> starts, >>>>>>> the >>>>>>> program pretty much stops with it. >>>>>> >>>>>> You need to remove the use of sleep and use "after" instead. You keep >>>>>> scheduling your task till the condition is not met anymore, then you >>>>>> stop scheduling it with "after". >>>>>> >>>>>>> To make things harder, I really want that >>>>>>> to be it's own class, so I have to pass it the list that triggers >>>>>>> the >>>>>>> stopping, but I can only pass it the list once. So I don't think it >>>>>>> is >>>>>>> possible. >>>>>> >>>>>> It is, just pass some other object along which can call the method >>>>>> "after". >>>>>> >>>>>>> But if this made sense to anyone, and you have a suggestion I >>>>>>> would love it. Heres the full code: (but at the bottom, the Open >>>>>>> function >>>>>>> is >>>>>>> really the only thing that matters) >>>>>>> >>>>>> >>>>>> If you want help based on code, you have to post a short-enough code >>>>>> that demonstrates the problem. >>>>>> >>>>>>> from Tkinter import * >>>>>>> import time >>>>>>> >>>>>>> class BusyBar(Frame): >>>>>>> ... >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> -- Guilherme H. Polo Goncalves >>>>>> _______________________________________________ >>>>>> Tkinter-discuss mailing list >>>>>> Tkinter-discuss at python.org >>>>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>> >>>>>> >>>>> >>>>> Okay, so I modified the bottom code to this: >>>>> >>>>> def Open(root): >>>>> >>>>> bb = BusyBar(root, text='Grabbing Definitions') >>>>> bb.pack(side=LEFT, expand=NO) >>>>> >>>>> >>>>> def sleeper(): >>>>> root.update >>>> >>>> What if you change this to root.update() ? >>>> >>>>> root.after(1, sleeper) >>>> >>>> after works with milliseconds, not seconds, be aware. >>>> >>>>> bb.on() >>>>> root.update_idletasks() >>>>> >>>>> sleeper() >>>>> >>>>> #for i in range(0, 100): >>>>> #time.sleep(0.1) >>>>> #root.update() >>>>> bb.of() >>>>> >>>>> but it doesn't repeat. What am I missing? >>>>> >>>> >>>> >>>> -- >>>> -- Guilherme H. Polo Goncalves >>>> _______________________________________________ >>>> Tkinter-discuss mailing list >>>> Tkinter-discuss at python.org >>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>> >>>> >>> >>> Well, what was happening before is that the bar would just be at a >>> standstill. After making it update() it moved a little, but was just a >>> standstill at a different place, if that makes sense. Any more ideas? >>> heres >>> the code: >>> >>> def Open(root): >>> >>> bb = BusyBar(root, text='Grabbing Definitions') >>> bb.pack(side=LEFT, expand=NO) >>> >>> bb.on() >>> root.update_idletasks() >>> >>> def sleeper(): >>> root.update() >>> root.after(1, sleeper) >> >> Did you ignore my last email where I said after takes milliseconds, >> not seconds ? And this will forever, not what you want apparently. >> > > I forgot a word there, "... And this will run forever ...", sorry > >>> >>> sleeper() >>> >>> #for i in range(0, 100): >>> #time.sleep(0.1) >>> #root.update() >>> bb.of() >> >> The code you have pasted in the last two emails don't show the problem >> you are having. I guess someone else will have to look at your entire >> code to give more help. >> > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18397021.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Fri Jul 11 07:35:03 2008 From: alexnbryan at gmail.com (Alexnb) Date: Thu, 10 Jul 2008 22:35:03 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18397021.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> Message-ID: <18397060.post@talk.nabble.com> Alexnb wrote: > > yes I know it runs in milliseconds. So what do you suggest? 1 millisecond > is about what I want. it was .1 seconds for the sleep() time. > I didn't write this code I found it online so I don't really understand > it, but I know that is where the problem is, the for loop. > > Guilherme Polo wrote: >> >> On Thu, Jul 10, 2008 at 8:45 PM, Guilherme Polo wrote: >>> On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: >>>> >>>> >>>> >>>> Guilherme Polo wrote: >>>>> >>>>> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: >>>>>> >>>>>> >>>>>> >>>>>> Guilherme Polo wrote: >>>>>>> >>>>>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb >>>>>>> wrote: >>>>>>>> >>>>>>>> Okay, so I have a for loop with a sleep command. I want the loop to >>>>>>>> continue >>>>>>>> until it is told to stop. I want to tell it to stop when a list >>>>>>>> goes >>>>>>>> from >>>>>>>> empty to having something. The problem is that when that loop >>>>>>>> starts, >>>>>>>> the >>>>>>>> program pretty much stops with it. >>>>>>> >>>>>>> You need to remove the use of sleep and use "after" instead. You >>>>>>> keep >>>>>>> scheduling your task till the condition is not met anymore, then you >>>>>>> stop scheduling it with "after". >>>>>>> >>>>>>>> To make things harder, I really want that >>>>>>>> to be it's own class, so I have to pass it the list that triggers >>>>>>>> the >>>>>>>> stopping, but I can only pass it the list once. So I don't think it >>>>>>>> is >>>>>>>> possible. >>>>>>> >>>>>>> It is, just pass some other object along which can call the method >>>>>>> "after". >>>>>>> >>>>>>>> But if this made sense to anyone, and you have a suggestion I >>>>>>>> would love it. Heres the full code: (but at the bottom, the Open >>>>>>>> function >>>>>>>> is >>>>>>>> really the only thing that matters) >>>>>>>> >>>>>>> >>>>>>> If you want help based on code, you have to post a short-enough code >>>>>>> that demonstrates the problem. >>>>>>> >>>>>>>> from Tkinter import * >>>>>>>> import time >>>>>>>> >>>>>>>> class BusyBar(Frame): >>>>>>>> ... >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> -- Guilherme H. Polo Goncalves >>>>>>> _______________________________________________ >>>>>>> Tkinter-discuss mailing list >>>>>>> Tkinter-discuss at python.org >>>>>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>>>> >>>>>>> >>>>>> >>>>>> Okay, so I modified the bottom code to this: >>>>>> >>>>>> def Open(root): >>>>>> >>>>>> bb = BusyBar(root, text='Grabbing Definitions') >>>>>> bb.pack(side=LEFT, expand=NO) >>>>>> >>>>>> >>>>>> def sleeper(): >>>>>> root.update >>>>> >>>>> What if you change this to root.update() ? >>>>> >>>>>> root.after(1, sleeper) >>>>> >>>>> after works with milliseconds, not seconds, be aware. >>>>> >>>>>> bb.on() >>>>>> root.update_idletasks() >>>>>> >>>>>> sleeper() >>>>>> >>>>>> #for i in range(0, 100): >>>>>> #time.sleep(0.1) >>>>>> #root.update() >>>>>> bb.of() >>>>>> >>>>>> but it doesn't repeat. What am I missing? >>>>>> >>>>> >>>>> >>>>> -- >>>>> -- Guilherme H. Polo Goncalves >>>>> _______________________________________________ >>>>> Tkinter-discuss mailing list >>>>> Tkinter-discuss at python.org >>>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>>> >>>>> >>>> >>>> Well, what was happening before is that the bar would just be at a >>>> standstill. After making it update() it moved a little, but was just a >>>> standstill at a different place, if that makes sense. Any more ideas? >>>> heres >>>> the code: >>>> >>>> def Open(root): >>>> >>>> bb = BusyBar(root, text='Grabbing Definitions') >>>> bb.pack(side=LEFT, expand=NO) >>>> >>>> bb.on() >>>> root.update_idletasks() >>>> >>>> def sleeper(): >>>> root.update() >>>> root.after(1, sleeper) >>> >>> Did you ignore my last email where I said after takes milliseconds, >>> not seconds ? And this will forever, not what you want apparently. >>> >> >> I forgot a word there, "... And this will run forever ...", sorry >> >>>> >>>> sleeper() >>>> >>>> #for i in range(0, 100): >>>> #time.sleep(0.1) >>>> #root.update() >>>> bb.of() >>> >>> The code you have pasted in the last two emails don't show the problem >>> you are having. I guess someone else will have to look at your entire >>> code to give more help. >>> >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > I am not that familiar with teh after call, but when I change it to this: def Open(root): bb = BusyBar(root, text='Grabbing Definitions') bb.pack(side=LEFT, expand=NO) bb.on() root.update_idletasks() def sleeper(): root.update() root.after(100000000, sleeper()) sleeper() (notice the () after sleeper in after). It gives me this error. regardless of the number in after. Anyways, I get this error root.update() RuntimeError: maximum recursion depth exceeded -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18397060.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Fri Jul 11 09:43:41 2008 From: alexnbryan at gmail.com (Alexnb) Date: Fri, 11 Jul 2008 00:43:41 -0700 (PDT) Subject: [Tkinter-discuss] Icon on title bar in macOSX Message-ID: <18398460.post@talk.nabble.com> I know that in a normal windows python Tkinter app you would use: root.wm_iconbitmap("/Icons for App/Windows.ico") to make an icon in the title bar. However, when you do that in mac OSX you can't see it. I am not sure if it is because the x - and+ are on the left side, or because it just doesn't support MacOSX. Looking at other programs none of them have it either. I am just wondering is it possible to put an icon in the top title bar. -- View this message in context: http://www.nabble.com/Icon-on-title-bar-in-macOSX-tp18398460p18398460.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Fri Jul 11 15:52:26 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 11 Jul 2008 09:52:26 -0400 Subject: [Tkinter-discuss] Icon on title bar in macOSX In-Reply-To: <18398460.post@talk.nabble.com> References: <18398460.post@talk.nabble.com> Message-ID: <4877659A.5040703@codebykevin.com> Alexnb wrote: > I know that in a normal windows python Tkinter app you would use: > > root.wm_iconbitmap("/Icons for App/Windows.ico") > > to make an icon in the title bar. However, when you do that in mac OSX you > can't see it. I am not sure if it is because the x - and+ are on the left > side, or because it just doesn't support MacOSX. Looking at other programs > none of them have it either. I am just wondering is it possible to put an > icon in the top title bar. > No, OS X doesn't support this, as far as I know. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sun Jul 13 01:06:01 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 12 Jul 2008 16:06:01 -0700 (PDT) Subject: [Tkinter-discuss] Getting rid of the title bar Message-ID: <18424531.post@talk.nabble.com> For part of the app I am writing I want to be able to temporarily make the title bar go away, and then bring it back. I vaguely remember reading about a Tkinter method that could do this, but don't remember. Does anyone know how I should do this? -- View this message in context: http://www.nabble.com/Getting-rid-of-the-title-bar-tp18424531p18424531.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Sun Jul 13 21:19:17 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 13 Jul 2008 19:19:17 +0000 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18397060.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> <18397060.post@talk.nabble.com> Message-ID: <20080713191917.GA30500@lairds.us> On Thu, Jul 10, 2008 at 10:35:03PM -0700, Alexnb wrote: . [hundreds of lines] . . > I am not that familiar with teh after call, but when I change it to this: > > def Open(root): > > bb = BusyBar(root, text='Grabbing Definitions') > bb.pack(side=LEFT, expand=NO) > > bb.on() > root.update_idletasks() > > def sleeper(): > root.update() > root.after(100000000, sleeper()) > > sleeper() > > (notice the () after sleeper in after). It gives me this error. regardless > of the number in after. Anyways, I get this error > > root.update() > RuntimeError: maximum recursion depth exceeded . . . Alex, I'm lost as to what your current status is--what you see as solved, and what questions still remain. Do you see why the fragment above is unlikely to make you happy? after()'s second argument names a function;, it doesn't expect the coder to invoke it. Does the self-scheduling in make sense? How did it not serve you better to write root.after(100000000, sleeper) than what you have above? From Cameron at phaseit.net Sun Jul 13 21:23:13 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 13 Jul 2008 19:23:13 +0000 Subject: [Tkinter-discuss] Getting rid of the title bar In-Reply-To: <18424531.post@talk.nabble.com> References: <18424531.post@talk.nabble.com> Message-ID: <20080713192313.GB30500@lairds.us> On Sat, Jul 12, 2008 at 04:06:01PM -0700, Alexnb wrote: . . . > For part of the app I am writing I want to be able to temporarily make the > title bar go away, and then bring it back. I vaguely remember reading about > a Tkinter method that could do this, but don't remember. Does anyone know > how I should do this? . . . Are you after the overrideredirect() in and elsewhere? From alexnbryan at gmail.com Sun Jul 13 21:23:29 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 13 Jul 2008 12:23:29 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <20080713191917.GA30500@lairds.us> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> <18397060.post@talk.nabble.com> <20080713191917.GA30500@lairds.us> Message-ID: <18432795.post@talk.nabble.com> Cameron Laird-2 wrote: > > On Thu, Jul 10, 2008 at 10:35:03PM -0700, Alexnb wrote: > . > [hundreds of lines] > . > . >> I am not that familiar with teh after call, but when I change it to this: >> >> def Open(root): >> >> bb = BusyBar(root, text='Grabbing Definitions') >> bb.pack(side=LEFT, expand=NO) >> >> bb.on() >> root.update_idletasks() >> >> def sleeper(): >> root.update() >> root.after(100000000, sleeper()) >> >> sleeper() >> >> (notice the () after sleeper in after). It gives me this error. >> regardless >> of the number in after. Anyways, I get this error >> >> root.update() >> RuntimeError: maximum recursion depth exceeded > . > . > . > Alex, I'm lost as to what your current status is--what > you see as solved, and what questions still remain. > Do you see why the fragment above is unlikely to make > you happy? after()'s second argument names a function;, > it doesn't expect the coder to invoke it. Does the > self-scheduling in http://tkinter.unpythonic.net/wiki/after > make sense? > How did it not serve you better to write > > root.after(100000000, sleeper) > > than what you have above? > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Well Thats what I said, only, it didn't help. It was for a busy bar and the bar would stop unless I was using the for loop with the time.sleep() in it. However, it would always stop at the same spot with after(), but when I used after(100, sleeper()) vs after(100, sleeper) the sleeper() would still stop, but it would go a little further down the bar track. If that makes sense. But I have given up on the idea for now, but thanks for your attempt to help! -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18432795.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Sun Jul 13 21:27:55 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 13 Jul 2008 19:27:55 +0000 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18397021.post@talk.nabble.com> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> Message-ID: <20080713192755.GA3666@lairds.us> On Thu, Jul 10, 2008 at 10:30:53PM -0700, Alexnb wrote: . . . > yes I know it runs in milliseconds. So what do you suggest? 1 millisecond is > about what I want. it was .1 seconds for the sleep() time. > I didn't write this code I found it online so I don't really understand it, > but I know that is where the problem is, the for loop. > > Guilherme Polo wrote: > > > > On Thu, Jul 10, 2008 at 8:45 PM, Guilherme Polo wrote: > >> On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: > >>> > >>> > >>> > >>> Guilherme Polo wrote: > >>>> > >>>> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb wrote: > >>>>> > >>>>> > >>>>> > >>>>> Guilherme Polo wrote: > >>>>>> > >>>>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb wrote: . . . > >>>>> def sleeper(): > >>>>> root.update > >>>> > >>>> What if you change this to root.update() ? > >>>> > >>>>> root.after(1, sleeper) . . . Again, I'm fuzzy on what questions remain open. The code above is almost certainly wrong, though; far more likely to be useful would be something like def sleeper(): root.after(100, sleeper) # update() is almost certain to introduce problems. check_global_variables_and_so_on() From Cameron at phaseit.net Sun Jul 13 21:30:03 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 13 Jul 2008 19:30:03 +0000 Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <18432795.post@talk.nabble.com> References: <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> <18397060.post@talk.nabble.com> <20080713191917.GA30500@lairds.us> <18432795.post@talk.nabble.com> Message-ID: <20080713193003.GB3666@lairds.us> On Sun, Jul 13, 2008 at 12:23:29PM -0700, Alexnb wrote: > > . > > . > > . > > Alex, I'm lost as to what your current status is--what > > you see as solved, and what questions still remain. > > Do you see why the fragment above is unlikely to make > > you happy? after()'s second argument names a function;, > > it doesn't expect the coder to invoke it. Does the > > self-scheduling in > http://tkinter.unpythonic.net/wiki/after > make sense? > > How did it not serve you better to write > > > > root.after(100000000, sleeper) . . . > Well Thats what I said, only, it didn't help. It was for a busy bar and the > bar would stop unless I was using the for loop with the time.sleep() in it. > However, it would always stop at the same spot with after(), but when I used > after(100, sleeper()) vs after(100, sleeper) the sleeper() would still stop, > but it would go a little further down the bar track. If that makes sense. > But I have given up on the idea for now, but thanks for your attempt to > help! . . . When you write that you "have given up ...", does that mean that a working busybar would not be a value to you now? From alexnbryan at gmail.com Sun Jul 13 21:30:46 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 13 Jul 2008 12:30:46 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <20080713192755.GA3666@lairds.us> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> <20080713192755.GA3666@lairds.us> Message-ID: <18432900.post@talk.nabble.com> Cameron Laird-2 wrote: > > On Thu, Jul 10, 2008 at 10:30:53PM -0700, Alexnb wrote: > . > . > . >> yes I know it runs in milliseconds. So what do you suggest? 1 millisecond >> is >> about what I want. it was .1 seconds for the sleep() time. >> I didn't write this code I found it online so I don't really understand >> it, >> but I know that is where the problem is, the for loop. >> >> Guilherme Polo wrote: >> > >> > On Thu, Jul 10, 2008 at 8:45 PM, Guilherme Polo >> wrote: >> >> On Thu, Jul 10, 2008 at 8:24 PM, Alexnb wrote: >> >>> >> >>> >> >>> >> >>> Guilherme Polo wrote: >> >>>> >> >>>> On Thu, Jul 10, 2008 at 7:31 PM, Alexnb >> wrote: >> >>>>> >> >>>>> >> >>>>> >> >>>>> Guilherme Polo wrote: >> >>>>>> >> >>>>>> On Thu, Jul 10, 2008 at 5:57 PM, Alexnb >> wrote: > . > . > . >> >>>>> def sleeper(): >> >>>>> root.update >> >>>> >> >>>> What if you change this to root.update() ? >> >>>> >> >>>>> root.after(1, sleeper) > . > . > . > Again, I'm fuzzy on what questions remain open. The code > above is almost certainly wrong, though; far more likely > to be useful would be something like > > def sleeper(): > root.after(100, sleeper) > # update() is almost certain to introduce problems. > check_global_variables_and_so_on() > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > No questions remain. I have given up on the idea. I didn't write the bar, I found it online. So it was hard for me to know exactly what was going wrong. It is a lot of code that no one really wants to go though. So no worries, but thanks for helping! -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18432900.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Sun Jul 13 21:34:03 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 13 Jul 2008 12:34:03 -0700 (PDT) Subject: [Tkinter-discuss] Stopping a for loop with a sleep() funciton in it In-Reply-To: <20080713193003.GB3666@lairds.us> References: <18391735.post@talk.nabble.com> <18393290.post@talk.nabble.com> <18394006.post@talk.nabble.com> <18397021.post@talk.nabble.com> <18397060.post@talk.nabble.com> <20080713191917.GA30500@lairds.us> <18432795.post@talk.nabble.com> <20080713193003.GB3666@lairds.us> Message-ID: <18432929.post@talk.nabble.com> Cameron Laird-2 wrote: > > On Sun, Jul 13, 2008 at 12:23:29PM -0700, Alexnb wrote: >> > . >> > . >> > . >> > Alex, I'm lost as to what your current status is--what >> > you see as solved, and what questions still remain. >> > Do you see why the fragment above is unlikely to make >> > you happy? after()'s second argument names a function;, >> > it doesn't expect the coder to invoke it. Does the >> > self-scheduling in > > http://tkinter.unpythonic.net/wiki/after > make sense? >> > How did it not serve you better to write >> > >> > root.after(100000000, sleeper) > . > . > . >> Well Thats what I said, only, it didn't help. It was for a busy bar and >> the >> bar would stop unless I was using the for loop with the time.sleep() in >> it. >> However, it would always stop at the same spot with after(), but when I >> used >> after(100, sleeper()) vs after(100, sleeper) the sleeper() would still >> stop, >> but it would go a little further down the bar track. If that makes sense. >> But I have given up on the idea for now, but thanks for your attempt to >> help! > . > . > . > When you write that you "have given up ...", does that > mean that a working busybar would not be a value to you > now? > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > NoNo, a working bar would be of value, but not this one. This one probably wasn't written that well, so I am going to try and write one myself. But a working one would serve me well. Just not this one. If you know of a good way to write one, or an easy way, or one that works, I'd love to know. -- View this message in context: http://www.nabble.com/Stopping-a-for-loop-with-a-sleep%28%29-funciton-in-it-tp18391735p18432929.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From igor.e.novikov at gmail.com Sun Jul 13 21:39:30 2008 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Sun, 13 Jul 2008 22:39:30 +0300 Subject: [Tkinter-discuss] [ANN] Ttk wrapper 0.0.9 Message-ID: <23f7fc190807131239r4e5cc969y963b4bba846952e6@mail.gmail.com> Hi, Recently I have found your message regarding ttk package which is a part of your GSoC 2008 project: http://mail.python.org/pipermail/tkinter-discuss/2008-June/001439.html It is curiously enough, but our sK1 project has used similar package since 2006 year (it was Tile wrapper initially). I think our code base could be useful for your GSoC project, because it contains a lot of fixes and workarounds. Sincerely, Igor Novikov sK1 Project http://sk1project.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From ggpolo at gmail.com Sun Jul 13 22:06:51 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 13 Jul 2008 17:06:51 -0300 Subject: [Tkinter-discuss] [ANN] Ttk wrapper 0.0.9 In-Reply-To: <23f7fc190807131239r4e5cc969y963b4bba846952e6@mail.gmail.com> References: <23f7fc190807131239r4e5cc969y963b4bba846952e6@mail.gmail.com> Message-ID: On Sun, Jul 13, 2008 at 4:39 PM, Igor Novikov wrote: > Hi, > > Recently I have found your message regarding ttk package which is a part of > your GSoC 2008 project: > > http://mail.python.org/pipermail/tkinter-discuss/2008-June/001439.html > > It is curiously enough, but our sK1 project has used similar package since > 2006 year (it was Tile wrapper initially). I think our code base could be > useful for your GSoC project, because it contains a lot of fixes and > workarounds. I'm taking a look at it, Igor, I guess you are referring to Ttk.py at sK1/src/app/UI, correct ? Initially I see it is missing Notebook, Treeview and all the theming management, I guess you just wrapped the bits useful for your project. I'm curios why you prefixed most classes with a "T", except the Labelframe one. Other thing I noticed is that the class TButton has way more methods than those supported by a ttk Button. Also, did you happen to give a try to my wrapper and found some different behavior than yours ? > > Sincerely, > I appreciate your interest, > Igor Novikov > sK1 Project > http://sk1project.org > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Sun Jul 13 22:26:18 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 13 Jul 2008 13:26:18 -0700 (PDT) Subject: [Tkinter-discuss] Having an icon as a button, or a clickable icon Message-ID: <18433498.post@talk.nabble.com> This is just something I've always wanted to do, and am just wondering how to do it. If the subject isn't clear, what I mean is like a button that isn't just text, like on a browser, the refresh button isn't "refresh" it is typically the two little arrows. I am wondering how to make buttons like that. If there is a way what is it? and what format should the image be in? should it be an icon, or a gif or whatever? -- View this message in context: http://www.nabble.com/Having-an-icon-as-a-button%2C-or-a-clickable-icon-tp18433498p18433498.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Sun Jul 13 22:45:58 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 13 Jul 2008 20:45:58 +0000 Subject: [Tkinter-discuss] Having an icon as a button, or a clickable icon In-Reply-To: <18433498.post@talk.nabble.com> References: <18433498.post@talk.nabble.com> Message-ID: <20080713204558.GA15514@lairds.us> On Sun, Jul 13, 2008 at 01:26:18PM -0700, Alexnb wrote: . . . > This is just something I've always wanted to do, and am just wondering how to > do it. If the subject isn't clear, what I mean is like a button that isn't > just text, like on a browser, the refresh button isn't "refresh" it is > typically the two little arrows. I am wondering how to make buttons like > that. If there is a way what is it? and what format should the image be in? > should it be an icon, or a gif or whatever? . . . Look for "image" in . Does that leave any questions? From igor.e.novikov at gmail.com Sun Jul 13 23:05:09 2008 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Mon, 14 Jul 2008 00:05:09 +0300 Subject: [Tkinter-discuss] Fwd: [ANN] Ttk wrapper 0.0.9 In-Reply-To: <23f7fc190807131404h717d46c1r7327ce6ea989edbb@mail.gmail.com> References: <23f7fc190807131239r4e5cc969y963b4bba846952e6@mail.gmail.com> <23f7fc190807131404h717d46c1r7327ce6ea989edbb@mail.gmail.com> Message-ID: <23f7fc190807131405k4c367a08q9b402484479fbb7a@mail.gmail.com> On Sun, Jul 13, 2008 at 11:06 PM, Guilherme Polo wrote: > On Sun, Jul 13, 2008 at 4:39 PM, Igor Novikov > wrote: > > Hi, > > > > Recently I have found your message regarding ttk package which is a part > of > > your GSoC 2008 project: > > > > http://mail.python.org/pipermail/tkinter-discuss/2008-June/001439.html > > > > It is curiously enough, but our sK1 project has used similar package > since > > 2006 year (it was Tile wrapper initially). I think our code base could be > > useful for your GSoC project, because it contains a lot of fixes and > > workarounds. > > I'm taking a look at it, Igor, I guess you are referring to Ttk.py at > sK1/src/app/UI, correct ? on this moment the package is refactored to sK1/src/app/UI/lib-ttk to be generic for all packages like Tkinter. > Initially I see it is missing Notebook, Treeview and all the theming > management, I guess you just wrapped the bits useful for your project. Yes, you are right. Our goal is providing custom Ttk package for our project but not for conventional usage. So our code could be useful as tips, no more. > > I'm curios why you prefixed most classes with a "T", except the > Labelframe one. Other thing I noticed is that the class TButton has > way more methods than those supported by a ttk Button. We don't use ttk::labelframe due to some ttk implementation bugs (may be they have been fixed). In Ttk.py you have found regular tk::labelframe. "T" prefix is used to avoid clashes with Tkinter classes. If you migrate from Tkinter to Ttk and your project is bigger than regular 'hello world' such clashes could be a serious issue. Also, did you happen to give a try to my wrapper and found some > different behavior than yours ? Sorry, I cannot using your package because it isn't compatible with sK1 code base. Regarding behavior we are overloading some ttk-related tcl scripts on runtime resolving some ttk and tk issues (sK1/src/app/tcl). Our sK1 UI uses pixmap-based themes only because existing Tile/ttk themes are not useful for complex interface. For example, as for Ubuntulooks theme: http://ru.wikipedia.org/wiki/SK1 sorry it is a Russian Wikipedia page, English variant is under construction. > > > > > > Sincerely, > > > > I appreciate your interest, > > > > > -- > -- Guilherme H. Polo Goncalves > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexnbryan at gmail.com Mon Jul 14 00:18:57 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 13 Jul 2008 15:18:57 -0700 (PDT) Subject: [Tkinter-discuss] Having an icon as a button, or a clickable icon In-Reply-To: <20080713204558.GA15514@lairds.us> References: <18433498.post@talk.nabble.com> <20080713204558.GA15514@lairds.us> Message-ID: <18434587.post@talk.nabble.com> Cameron Laird-2 wrote: > > On Sun, Jul 13, 2008 at 01:26:18PM -0700, Alexnb wrote: > . > . > . >> This is just something I've always wanted to do, and am just wondering >> how to >> do it. If the subject isn't clear, what I mean is like a button that >> isn't >> just text, like on a browser, the refresh button isn't "refresh" it is >> typically the two little arrows. I am wondering how to make buttons like >> that. If there is a way what is it? and what format should the image be >> in? >> should it be an icon, or a gif or whatever? > . > . > . > Look for "image" in . > Does that leave any questions? > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Okay Thanks that was exactly what I wanted! But I have a new question about it. So you know how you can make a stringvar() and like when you change it everything changes. For example, what I am doing it I have a button and hte text of the button is a string variable so when the action for the button is done, it changes the text of the button to 'Done'. So I am wondering, is there a way to like have the button image be one thing, and then when something happens, it changes to another icon. Will just changing the variable that the image is in then doing an update() work? like image= PhotoImage(file="first image') Button(master, image=image) *Button is clicked* image=PhotoImage(file="second image") root.update() Will something like that work? Or is there a better way? -- View this message in context: http://www.nabble.com/Having-an-icon-as-a-button%2C-or-a-clickable-icon-tp18433498p18434587.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Mon Jul 14 00:40:34 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sun, 13 Jul 2008 19:40:34 -0300 Subject: [Tkinter-discuss] [ANN] Ttk wrapper 0.0.9 In-Reply-To: <23f7fc190807131510g41b28411i8b3b335b2ab0e38e@mail.gmail.com> References: <23f7fc190807131239r4e5cc969y963b4bba846952e6@mail.gmail.com> <23f7fc190807131404h717d46c1r7327ce6ea989edbb@mail.gmail.com> <23f7fc190807131510g41b28411i8b3b335b2ab0e38e@mail.gmail.com> Message-ID: On Sun, Jul 13, 2008 at 7:10 PM, Igor Novikov wrote: > > > On Mon, Jul 14, 2008 at 12:16 AM, Guilherme Polo wrote: >> >> On Sun, Jul 13, 2008 at 6:04 PM, Igor Novikov >> wrote: >> > >> > >> > On Sun, Jul 13, 2008 at 11:06 PM, Guilherme Polo >> > wrote: >> >> >> >> On Sun, Jul 13, 2008 at 4:39 PM, Igor Novikov >> >> >> >> wrote: >> >> > Hi, >> >> > >> >> > Recently I have found your message regarding ttk package which is a >> >> > part >> >> > of >> >> > your GSoC 2008 project: >> >> > >> >> > >> >> > http://mail.python.org/pipermail/tkinter-discuss/2008-June/001439.html >> >> > >> >> > It is curiously enough, but our sK1 project has used similar package >> >> > since >> >> > 2006 year (it was Tile wrapper initially). I think our code base >> >> > could >> >> > be >> >> > useful for your GSoC project, because it contains a lot of fixes and >> >> > workarounds. >> >> >> >> I'm taking a look at it, Igor, I guess you are referring to Ttk.py at >> >> sK1/src/app/UI, correct ? >> > >> > on this moment the package is refactored to sK1/src/app/UI/lib-ttk to be >> > generic for all packages like Tkinter. >> > >> >> >> >> Initially I see it is missing Notebook, Treeview and all the theming >> >> management, I guess you just wrapped the bits useful for your project. >> > >> > Yes, you are right. Our goal is providing custom Ttk package for our >> > project >> > but not for conventional usage. So our code could be useful as tips, no >> > more. >> > >> >> >> >> I'm curios why you prefixed most classes with a "T", except the >> >> Labelframe one. Other thing I noticed is that the class TButton has >> >> way more methods than those supported by a ttk Button. >> > >> > We don't use ttk::labelframe due to some ttk implementation bugs (may >> > be >> > they have been fixed). In Ttk.py you have found regular tk::labelframe. >> >> Now I see it, but then why did you redo what is already done at Tkinter.py >> ? > > >> >> > "T" prefix is used to avoid clashes with Tkinter classes. If you migrate >> > from Tkinter to Ttk and your project is bigger than regular 'hello >> > world' >> > such clashes could be a serious issue. >> >> >> Only if you are doing from Tkinter import *, which is not really >> recommended. > > Not only in such cases. If tk widgets are instantiated with tk specific > options or some tk specific changes are applied to widgets, such code should > be refactored step-by-step. Yes, and how that does not relate to doing a star import ? If you don't do such imports, you won't have names being overrided. > Similar issue was for tcl scripts when Tile was > released. Attemps to substitute all widgets by changing namespaces have been > unsuccessful so all new widgets have ttk:: prefix and migration on ttk is > recommended to be accurate. I've changed IDLE to use ttk widgets when they are available, I'm aware of the differences between standard Tk widgets and Ttk widgets. This "ttk::" prefix just reinforces what I said about not using star imports, not sure why you are bringing it up. Ideally I would like to see "import Tkinter as tk" or something like that being used, instead of "from Tkinter import *", just like people do in every other toolkit. > >> >> Also, did you happen to give a try to my wrapper and found some >> >> different behavior than yours ? >> > >> > Sorry, I cannot using your package because it isn't compatible with sK1 >> > code >> > base. >> >> > >> >> In what sense ? > > There is no sence to refactor 0.5Mb of source code replacing existing > implementation by your classes. I never told you to use it in your project. I just asked if you tried it or not, because it seemed like you found a bug on it and your wrapper had some correction regarding the supposed problem. > More over in such case we should adding to > our SVN your ttk.py and regulary updating it. But such work doesn't improve > sK1 functionality because as our code and your implementetion are similar > wrappers surround the same tcl commands :) In that case you won't have to refactor 500kb of source code then. > Such migration will be reasonable > when Ttk will be officially included into Python distribution and API will > be freezed. > I haven't been changing its API at all for some weeks now, not in incompatible ways at least. And again, I didn't tell to you to just move your project to my wrapper and drop yours. > Regards, > > Igor Novikov > sK1 Project > http://sk1project.org > > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Tue Jul 15 03:52:27 2008 From: alexnbryan at gmail.com (Alexnb) Date: Mon, 14 Jul 2008 18:52:27 -0700 (PDT) Subject: [Tkinter-discuss] setting a windows starting screen position Message-ID: <18456640.post@talk.nabble.com> I am wondering how to set the window's starting screen postion. I guess the default is the top left, or some coordinate in the top left. But i want my app to start in the center of the screen. How would I ot about doing that? -- View this message in context: http://www.nabble.com/setting-a-windows-starting-screen-position-tp18456640p18456640.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Tue Jul 15 04:11:37 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 14 Jul 2008 23:11:37 -0300 Subject: [Tkinter-discuss] setting a windows starting screen position In-Reply-To: <18456640.post@talk.nabble.com> References: <18456640.post@talk.nabble.com> Message-ID: On Mon, Jul 14, 2008 at 10:52 PM, Alexnb wrote: > > I am wondering how to set the window's starting screen postion. I guess the > default is the top left, or some coordinate in the top left. But i want my > app to start in the center of the screen. How would I ot about doing that? You would use wm_geometry, winfo_screenheight, winfo_screenwidth, width and height methods on your toplevel. Anything else I say will take out all the fun. Just a hint: you can set a position, without setting the widget size, using wm_geometry and calling it with something like ('+xpos+ypos'). > -- > View this message in context: http://www.nabble.com/setting-a-windows-starting-screen-position-tp18456640p18456640.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Tue Jul 15 04:46:39 2008 From: alexnbryan at gmail.com (Alexnb) Date: Mon, 14 Jul 2008 19:46:39 -0700 (PDT) Subject: [Tkinter-discuss] setting a windows starting screen position In-Reply-To: References: <18456640.post@talk.nabble.com> Message-ID: <18457114.post@talk.nabble.com> Guilherme Polo wrote: > > On Mon, Jul 14, 2008 at 10:52 PM, Alexnb wrote: >> >> I am wondering how to set the window's starting screen postion. I guess >> the >> default is the top left, or some coordinate in the top left. But i want >> my >> app to start in the center of the screen. How would I ot about doing >> that? > > You would use wm_geometry, winfo_screenheight, winfo_screenwidth, > width and height methods on your toplevel. Anything else I say will > take out all the fun. Just a hint: you can set a position, without > setting the widget size, using wm_geometry and calling it with > something like ('+xpos+ypos'). > >> -- >> View this message in context: >> http://www.nabble.com/setting-a-windows-starting-screen-position-tp18456640p18456640.html >> Sent from the Python - tkinter-discuss mailing list archive at >> Nabble.com. >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > haha I think I know what you meant about have fun with it. But I figured it out. Thanks for the help -- View this message in context: http://www.nabble.com/setting-a-windows-starting-screen-position-tp18456640p18457114.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From bob at passcal.nmt.edu Thu Jul 17 00:17:13 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 16 Jul 2008 16:17:13 -0600 Subject: [Tkinter-discuss] Lots of widgets in a Text widget Message-ID: I have a program that maintains a simple, on-the-fly database using a dictionary. The user can see what is going on with it by brining up a toplevel with a Text() widget. Checkbuttons and Entry fields are used to display the state of the items in the database (see picture). www.passcal.nmt.edu/~bob/unlinked/images/showdb.tiff The EN, AE, BR, etc. "flags" are the Checkbuttons and to the right of each TP, TO and ST label is an Entry field. Each line is one seismic recording instrument which this program talks to. From this 'form' the user can manually make changes to the state of each instrument by just clicking the flags or entering stuff in the fields. The problem is when there are hundreds of instruments it starts to take a long time to open the form and fill it all in, scroll the form, and close the form and destroy all of those widgets. Is there a faster way? Would putting all of this on a Canvas be faster? I'd try it, but it would take a bit of messing just to do the experiment -- only to find out it's not faster, plus I'm not looking forward to counting pixels to get everything to line up. This late-summer we will have an experiment with a few thousand instruments, so I'm lookin' for a solution. :) Thanks! Bob From ggpolo at gmail.com Thu Jul 17 02:19:06 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 16 Jul 2008 21:19:06 -0300 Subject: [Tkinter-discuss] Lots of widgets in a Text widget In-Reply-To: References: Message-ID: On Wed, Jul 16, 2008 at 7:17 PM, Bob Greschke wrote: > I have a program that maintains a simple, on-the-fly database using a > dictionary. The user can see what is going on with it by brining up a > toplevel with a Text() widget. Checkbuttons and Entry fields are used to > display the state of the items in the database (see picture). > > www.passcal.nmt.edu/~bob/unlinked/images/showdb.tiff > > The EN, AE, BR, etc. "flags" are the Checkbuttons and to the right of each > TP, TO and ST label is an Entry field. Each line is one seismic recording > instrument which this program talks to. From this 'form' the user can > manually make changes to the state of each instrument by just clicking the > flags or entering stuff in the fields. The problem is when there are > hundreds of instruments it starts to take a long time to open the form and > fill it all in, scroll the form, and close the form and destroy all of those > widgets. Is there a faster way? What if you limit the amount of instruments shown at a time ? Does it bring any advantage to show them all ? Also, you could try running that app under tk 8.5, it will require no changes and it is said to be 10% faster but I have never tested it so maybe you can test this. > Would putting all of this on a Canvas be > faster? I'd try it, but it would take a bit of messing just to do the > experiment -- only to find out it's not faster, plus I'm not looking forward > to counting pixels to get everything to line up. This late-summer we will > have an experiment with a few thousand instruments, so I'm lookin' for a > solution. :) > > Thanks! > > Bob > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From bob at greschke.com Thu Jul 17 02:32:57 2008 From: bob at greschke.com (Bob Greschke) Date: Wed, 16 Jul 2008 18:32:57 -0600 Subject: [Tkinter-discuss] Lots of widgets in a Text widget In-Reply-To: References: Message-ID: <2456D5BD-EF27-4F89-8E77-E7C27B8CD472@greschke.com> Personally, I don't think it does any good to see any of them. The users will just get in there and mess things up! Haha. I could have a different form where they enter the ID number of an instrument and just work with that unit. There's really no logical way to split them up other than like 100 at a time or something like that. Which one the user wants to change info for is usually just random so showing them all is best. Changing things manually is only really done if one stops working and you need to set the broken flag or fill in that last field with a designation for the deployed location. We should be updating to 8.5 next week so I'll try it out. Thanks! Bob -------- Sent from my iPod On Jul 16, 2008, at 18:19, "Guilherme Polo" wrote: > On Wed, Jul 16, 2008 at 7:17 PM, Bob Greschke > wrote: >> I have a program that maintains a simple, on-the-fly database using a >> dictionary. The user can see what is going on with it by brining >> up a >> toplevel with a Text() widget. Checkbuttons and Entry fields are >> used to >> display the state of the items in the database (see picture). >> >> www.passcal.nmt.edu/~bob/unlinked/images/showdb.tiff >> >> The EN, AE, BR, etc. "flags" are the Checkbuttons and to the right >> of each >> TP, TO and ST label is an Entry field. Each line is one seismic >> recording >> instrument which this program talks to. From this 'form' the user >> can >> manually make changes to the state of each instrument by just >> clicking the >> flags or entering stuff in the fields. The problem is when there are >> hundreds of instruments it starts to take a long time to open the >> form and >> fill it all in, scroll the form, and close the form and destroy all >> of those >> widgets. Is there a faster way? > > What if you limit the amount of instruments shown at a time ? Does it > bring any advantage to show them all ? > > Also, you could try running that app under tk 8.5, it will require no > changes and it is said to be 10% faster but I have never tested it so > maybe you can test this. > >> Would putting all of this on a Canvas be >> faster? I'd try it, but it would take a bit of messing just to do >> the >> experiment -- only to find out it's not faster, plus I'm not >> looking forward >> to counting pixels to get everything to line up. This late-summer >> we will >> have an experiment with a few thousand instruments, so I'm lookin' >> for a >> solution. :) >> >> Thanks! >> >> Bob >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > From callen at gemini.edu Thu Jul 17 03:09:10 2008 From: callen at gemini.edu (Craig Allen) Date: Wed, 16 Jul 2008 15:09:10 -1000 Subject: [Tkinter-discuss] multithreading Message-ID: <1216256950.18083.26.camel@phact.hi.gemini.edu> Anyone that's interested, I have a command line application which I want to run as such, with a flag that alternately puts up a pretty monitoring GUI that shows in more detail what's going on. So fine, I run the Tk mainloop in a background thread. I've read and learned myself you cannot make your Tk calls outside this thread. Fine. But as this is a bit of an extra feature I have not been particularly careful, and since the command line can execute more than one sequence of it's processing, it wants to open up a new pair of windows every time. As I"m just hacking this together (the pretty Tk interface is an addition, not really required to be build) to do this I call the master object which is a threading object... i.e. another thread is started, and this other thread has a mainloop call in it. It all works fine, but I'm sort of of the impression I'm not supposed to do this, that there should only be one thread running a mainloop call. Is that true, is this evil? Any comments appreciated. craig -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Thu Jul 17 09:17:05 2008 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Thu, 17 Jul 2008 09:17:05 +0200 Subject: [Tkinter-discuss] Lots of widgets in a Text widget In-Reply-To: <2456D5BD-EF27-4F89-8E77-E7C27B8CD472@greschke.com> References: <2456D5BD-EF27-4F89-8E77-E7C27B8CD472@greschke.com> Message-ID: <487EF1F1.8080900@cern.ch> I had a similar problem, with my application with Text and Canvas. After some testing I realized that enormous amount of time was used by Tk/Tcl from the tag_bind routine. In the end I've decided to use a global binding for the mouse and cache the bounding box of each element. It is a bit more messier to handle because for each modification you have to take care on the position of the bounding boxes, but in the end is much faster than using the tag_bind Cheers Vasilis Bob Greschke wrote: > Personally, I don't think it does any good to see any of them. The > users will just get in there and mess things up! Haha. > > I could have a different form where they enter the ID number of an > instrument and just work with that unit. There's really no logical way > to split them up other than like 100 at a time or something like that. > Which one the user wants to change info for is usually just random so > showing them all is best. Changing things manually is only really > done if one stops working and you need to set the broken flag or fill > in that last field with a designation for the deployed location. > > We should be updating to 8.5 next week so I'll try it out. > > Thanks! > > Bob > > -------- > Sent from my iPod > > On Jul 16, 2008, at 18:19, "Guilherme Polo" wrote: > >> On Wed, Jul 16, 2008 at 7:17 PM, Bob Greschke >> wrote: >>> I have a program that maintains a simple, on-the-fly database using a >>> dictionary. The user can see what is going on with it by brining up a >>> toplevel with a Text() widget. Checkbuttons and Entry fields are >>> used to >>> display the state of the items in the database (see picture). >>> >>> www.passcal.nmt.edu/~bob/unlinked/images/showdb.tiff >>> >>> The EN, AE, BR, etc. "flags" are the Checkbuttons and to the right >>> of each >>> TP, TO and ST label is an Entry field. Each line is one seismic >>> recording >>> instrument which this program talks to. From this 'form' the user can >>> manually make changes to the state of each instrument by just >>> clicking the >>> flags or entering stuff in the fields. The problem is when there are >>> hundreds of instruments it starts to take a long time to open the >>> form and >>> fill it all in, scroll the form, and close the form and destroy all >>> of those >>> widgets. Is there a faster way? >> >> What if you limit the amount of instruments shown at a time ? Does it >> bring any advantage to show them all ? >> >> Also, you could try running that app under tk 8.5, it will require no >> changes and it is said to be 10% faster but I have never tested it so >> maybe you can test this. >> >>> Would putting all of this on a Canvas be >>> faster? I'd try it, but it would take a bit of messing just to do the >>> experiment -- only to find out it's not faster, plus I'm not looking >>> forward >>> to counting pixels to get everything to line up. This late-summer >>> we will >>> have an experiment with a few thousand instruments, so I'm lookin' >>> for a >>> solution. :) >>> >>> Thanks! >>> >>> Bob >>> _______________________________________________ >>> Tkinter-discuss mailing list >>> Tkinter-discuss at python.org >>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>> >> >> >> >> -- >> -- Guilherme H. Polo Goncalves >> > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- A non-text attachment was scrubbed... Name: Vasilis_Vlachoudis.vcf Type: text/x-vcard Size: 312 bytes Desc: not available URL: From callen at gemini.edu Sat Jul 19 03:21:35 2008 From: callen at gemini.edu (C. Allen) Date: Fri, 18 Jul 2008 15:21:35 -1000 Subject: [Tkinter-discuss] multithreading In-Reply-To: <1216256950.18083.26.camel@phact.hi.gemini.edu> References: <1216256950.18083.26.camel@phact.hi.gemini.edu> Message-ID: <1216430495.1906.33.camel@phact.hi.gemini.edu> Ok, for anyone interested it felt bad to do to tkinter but even more importantly, it was not necessary to be so wasteful with threads, I really only need a single GUI thread (I may not feel that way the first time a problem in one window hangs them all), so I just redid things so all the windows are created and controlled by a single thread, and I use a list as a queue of commands from other threads (i.e. "open another set of windows associated to xyz data"). cheers. On Wed, 2008-07-16 at 15:09 -1000, Craig Allen wrote: > Anyone that's interested, > > I have a command line application which I want to run as such, with a > flag that alternately puts up a pretty monitoring GUI that shows in > more detail what's going on. So fine, I run the Tk mainloop in a > background thread. I've read and learned myself you cannot make your > Tk calls outside this thread. Fine. > > But as this is a bit of an extra feature I have not been particularly > careful, and since the command line can execute more than one sequence > of it's processing, it wants to open up a new pair of windows every > time. As I"m just hacking this together (the pretty Tk interface is > an addition, not really required to be build) to do this I call the > master object which is a threading object... i.e. another thread is > started, and this other thread has a mainloop call in it. It all > works fine, but I'm sort of of the impression I'm not supposed to do > this, that there should only be one thread running a mainloop call. > > Is that true, is this evil? > > Any comments appreciated. > > craig > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexnbryan at gmail.com Sat Jul 19 06:12:25 2008 From: alexnbryan at gmail.com (Alexnb) Date: Fri, 18 Jul 2008 21:12:25 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac Message-ID: <18541172.post@talk.nabble.com> Hello everyone! So, I have a texbox widget and I connected a scrollbar to it. On my PC everything works great. But on my mac, you can't scroll when you click the box and dragging the actual bar is very choppy. The only way it works like it should is the actual arrow on the end of the bar. I am wondering if this can be fixed? or is it just a weird bug you have to deal with? Here is the code: self.scrollbar = Scrollbar(self.textFrameBuffer) self.scrollbar.pack(side=RIGHT, fill=Y) self.text = Text(self.textFrameBuffer, yscrollcommand=self.scrollbar.set) self.text.pack(side=LEFT, fill=BOTH, expand=YES) -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18541172.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Sat Jul 19 07:40:27 2008 From: alexnbryan at gmail.com (Alexnb) Date: Fri, 18 Jul 2008 22:40:27 -0700 (PDT) Subject: [Tkinter-discuss] Buttons on a mac over-riding the Frame background Message-ID: <18541617.post@talk.nabble.com> Okay, so if my title didn't make that much sense, what I mean is this. Say I have a frame called "buttonsFrame" and I have two buttons in it. If the Frame's background is red, there is a little white square around the buttons. how can I get rid of that? Is there a way to change the default root background? -- View this message in context: http://www.nabble.com/Buttons-on-a-mac-over-riding-the-Frame-background-tp18541617p18541617.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Sat Jul 19 15:24:43 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 09:24:43 -0400 Subject: [Tkinter-discuss] Buttons on a mac over-riding the Frame background In-Reply-To: <18541617.post@talk.nabble.com> References: <18541617.post@talk.nabble.com> Message-ID: <4881EB1B.80600@codebykevin.com> Alexnb wrote: > Okay, so if my title didn't make that much sense, what I mean is this. Say I > have a frame called > "buttonsFrame" > and I have two buttons in it. If the Frame's background is red, there is a > little white square around the buttons. how can I get rid of that? Is there > a way to change the default root background? Set the highlightbackground of the button to the same color as the frame. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kw at codebykevin.com Sat Jul 19 15:56:32 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 09:56:32 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18541172.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> Message-ID: <4881F290.5090009@codebykevin.com> Alexnb wrote: > Hello everyone! > > So, I have a texbox widget and I connected a scrollbar to it. On my PC > everything works great. But on my mac, you can't scroll when you click the > box and dragging the actual bar is very choppy. The only way it works like > it should is the actual arrow on the end of the bar. I am wondering if this > can be fixed? or is it just a weird bug you have to deal with? > > Here is the code: > > self.scrollbar = Scrollbar(self.textFrameBuffer) > self.scrollbar.pack(side=RIGHT, fill=Y) > > self.text = Text(self.textFrameBuffer, > yscrollcommand=self.scrollbar.set) > self.text.pack(side=LEFT, fill=BOTH, expand=YES) > > This is just a guess, because there isn't enough code here to check, but did you set the command for the scrollbar widget? Something like self.scrollbar.configure(command=self.text.yview) ? I don't see that you've set this. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sat Jul 19 18:38:04 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 09:38:04 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <4881F290.5090009@codebykevin.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> Message-ID: <18546400.post@talk.nabble.com> Kevin Walzer-5 wrote: > > Alexnb wrote: >> Hello everyone! >> >> So, I have a texbox widget and I connected a scrollbar to it. On my PC >> everything works great. But on my mac, you can't scroll when you click >> the >> box and dragging the actual bar is very choppy. The only way it works >> like >> it should is the actual arrow on the end of the bar. I am wondering if >> this >> can be fixed? or is it just a weird bug you have to deal with? >> >> Here is the code: >> >> self.scrollbar = Scrollbar(self.textFrameBuffer) >> self.scrollbar.pack(side=RIGHT, fill=Y) >> >> self.text = Text(self.textFrameBuffer, >> yscrollcommand=self.scrollbar.set) >> self.text.pack(side=LEFT, fill=BOTH, expand=YES) >> >> > This is just a guess, because there isn't enough code here to check, but > did you set the command for the scrollbar widget? Something like > > self.scrollbar.configure(command=self.text.yview) > > ? > > I don't see that you've set this. > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Yes sorry. I do actually have that, I just forgot to put it in because it was below some comments. Everything works perfect on windows, but not on mac, which is the weird part. I think it is just maybe an issue in Tkinter with mac. -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18546400.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Sat Jul 19 18:47:26 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 12:47:26 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18546400.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> Message-ID: <48821A9E.6060107@codebykevin.com> Alexnb wrote: > Yes sorry. I do actually have that, I just forgot to put it in because it > was below some comments. Everything works perfect on windows, but not on > mac, which is the weird part. I think it is just maybe an issue in Tkinter > with mac. > It might be helpful to put together a small code sample that can help me to replicate the issue better. I don't see any problems with scrolling a Tkinter text widget on the Mac. IDLE, for instance, works fine: I can scroll with the mousewheel, by dragging the scrollbar, and by clicking the arrow in the scrollbar's trough. My setup is OS X 10.5.4, Python 2.5.2, Tk 8.5.3. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sat Jul 19 18:58:18 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 09:58:18 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <48821A9E.6060107@codebykevin.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> Message-ID: <18546591.post@talk.nabble.com> Kevin Walzer-5 wrote: > > Alexnb wrote: > >> Yes sorry. I do actually have that, I just forgot to put it in because it >> was below some comments. Everything works perfect on windows, but not on >> mac, which is the weird part. I think it is just maybe an issue in >> Tkinter >> with mac. >> > It might be helpful to put together a small code sample that can help me > to replicate the issue better. I don't see any problems with scrolling a > Tkinter text widget on the Mac. IDLE, for instance, works fine: I can > scroll with the mousewheel, by dragging the scrollbar, and by clicking > the arrow in the scrollbar's trough. > > My setup is OS X 10.5.4, Python 2.5.2, Tk 8.5.3. > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Okay, here we go. Try this out, let me know how it works. It has the same issue for me. from Tkinter import * class TestText: def __init__(self, parent): self.parent = parent self.baseFrame = Frame(self.parent) self.baseFrame.pack(fill=BOTH, expand=YES) self.scrollbar = Scrollbar(self.baseFrame) self.scrollbar.pack(side=RIGHT, fill=Y, pady=15) self.text = Text(self.baseFrame, yscrollcommand=self.scrollbar.set) self.text.pack(side=LEFT, fill=BOTH, expand=YES) self.scrollbar.config(command=self.text.yview) self.n = 0 for x in range(40): self.text.insert(END, str(self.n) + "\n") self.n = self.n+1 root = Tk() tt = TestText(root) root.mainloop() -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18546591.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Sat Jul 19 19:05:57 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 13:05:57 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18546591.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> Message-ID: <48821EF5.2010507@codebykevin.com> Alexnb wrote: > > Okay, here we go. Try this out, let me know how it works. It has the same > issue for me. > > Works fine for me. What does your setup look like? OS version, version of Python and Tk? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sat Jul 19 19:09:10 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 10:09:10 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <48821EF5.2010507@codebykevin.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> Message-ID: <18546701.post@talk.nabble.com> Kevin Walzer-5 wrote: > > Alexnb wrote: > >> >> Okay, here we go. Try this out, let me know how it works. It has the same >> issue for me. >> >> > > > Works fine for me. What does your setup look like? OS version, version > of Python and Tk? > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > As far as I know I've got the latest python, I code with 2.5, but I am not sure about Tk(). How can I check? My mac is updated as well. It's a macbook. But I don't see how that would make a difference. -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18546701.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Sat Jul 19 19:34:35 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 13:34:35 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18546701.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> <18546701.post@talk.nabble.com> Message-ID: <488225AB.8000602@codebykevin.com> Alexnb wrote: > > As far as I know I've got the latest python, I code with 2.5, but I am not > sure about Tk(). How can I check? My mac is updated as well. It's a macbook. > But I don't see how that would make a difference. > root.tk.call('info', 'patchlevel') will give you the version of Tk that you are running. If it's 8.4.7 (the Apple-installed version) I'm not sure what to suggest--I'm not aware of any bugs with scrolling in the text widget, but that version is three years old and is not going to get patched. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sat Jul 19 19:38:04 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 10:38:04 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <488225AB.8000602@codebykevin.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> <18546701.post@talk.nabble.com> <488225AB.8000602@codebykevin.com> Message-ID: <18546978.post@talk.nabble.com> Kevin Walzer-5 wrote: > > Alexnb wrote: >> > >> As far as I know I've got the latest python, I code with 2.5, but I am >> not >> sure about Tk(). How can I check? My mac is updated as well. It's a >> macbook. >> But I don't see how that would make a difference. >> > > root.tk.call('info', 'patchlevel') will give you the version of Tk that > you are running. > > If it's 8.4.7 (the Apple-installed version) I'm not sure what to > suggest--I'm not aware of any bugs with scrolling in the text widget, > but that version is three years old and is not going to get patched. > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Well, it is 8.4.7.... so how can I get 8.5 on a mac? -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18546978.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Sat Jul 19 19:43:43 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 13:43:43 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18546978.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> <18546701.post@talk.nabble.com> <488225AB.8000602@codebykevin.com> <18546978.post@talk.nabble.com> Message-ID: <488227CF.4070108@codebykevin.com> Alexnb wrote: > > > Well, it is 8.4.7.... so how can I get 8.5 on a mac? Install ActiveTcl from ActiveState, and build Python to link against Tk 8.5. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sat Jul 19 20:28:05 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 11:28:05 -0700 (PDT) Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18546978.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> <18546701.post@talk.nabble.com> <488225AB.8000602@codebykevin.com> <18546978.post@talk.nabble.com> Message-ID: <18547417.post@talk.nabble.com> Alexnb wrote: > > > > Kevin Walzer-5 wrote: >> >> Alexnb wrote: >>> >> >>> As far as I know I've got the latest python, I code with 2.5, but I am >>> not >>> sure about Tk(). How can I check? My mac is updated as well. It's a >>> macbook. >>> But I don't see how that would make a difference. >>> >> >> root.tk.call('info', 'patchlevel') will give you the version of Tk that >> you are running. >> >> If it's 8.4.7 (the Apple-installed version) I'm not sure what to >> suggest--I'm not aware of any bugs with scrolling in the text widget, >> but that version is three years old and is not going to get patched. >> >> -- >> Kevin Walzer >> Code by Kevin >> http://www.codebykevin.com >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > Well, it is 8.4.7.... so how can I get 8.5 on a mac? > Okay I installed the dmg but I still have the same version.. what am I missing? -- View this message in context: http://www.nabble.com/Issue-with-scrolling-in-a-Text%28%29-widget-on-a-mac-tp18541172p18547417.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From alexnbryan at gmail.com Sun Jul 20 00:43:44 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 15:43:44 -0700 (PDT) Subject: [Tkinter-discuss] Making an image the background of a Frame Message-ID: <18549545.post@talk.nabble.com> So, is there a way I can make the background of a frame an image and still have all the widgets (buttons in this case) remain where they are and how they work? -- View this message in context: http://www.nabble.com/Making-an-image-the-background-of-a-Frame-tp18549545p18549545.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Sun Jul 20 01:02:59 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 19 Jul 2008 20:02:59 -0300 Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: <18549545.post@talk.nabble.com> References: <18549545.post@talk.nabble.com> Message-ID: On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: > > So, is there a way I can make the background of a frame an image and still > have all the widgets (buttons in this case) remain where they are and how > they work? You could just use a Label with a image and use this Label as the parent for other widgets you want to place over it. You will probably also want to set the window geometry according to this background image dimensions. > -- > View this message in context: http://www.nabble.com/Making-an-image-the-background-of-a-Frame-tp18549545p18549545.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From alexnbryan at gmail.com Sun Jul 20 01:20:26 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 16:20:26 -0700 (PDT) Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: References: <18549545.post@talk.nabble.com> Message-ID: <18549826.post@talk.nabble.com> Guilherme Polo wrote: > > On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: >> >> So, is there a way I can make the background of a frame an image and >> still >> have all the widgets (buttons in this case) remain where they are and how >> they work? > > You could just use a Label with a image and use this Label as the > parent for other widgets you want to place over it. You will probably > also want to set the window geometry according to this background > image dimensions. > >> -- >> View this message in context: >> http://www.nabble.com/Making-an-image-the-background-of-a-Frame-tp18549545p18549545.html >> Sent from the Python - tkinter-discuss mailing list archive at >> Nabble.com. >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Okay, I tried that and the area just showed up white :(. What do you suggest? -- View this message in context: http://www.nabble.com/Making-an-image-the-background-of-a-Frame-tp18549545p18549826.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From timj at tolisgroup.com Sun Jul 20 01:30:31 2008 From: timj at tolisgroup.com (Tim Jones) Date: Sat, 19 Jul 2008 16:30:31 -0700 Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: <18549826.post@talk.nabble.com> References: <18549545.post@talk.nabble.com> <18549826.post@talk.nabble.com> Message-ID: On Jul 19, 2008, at 4:20 PM, Alexnb wrote: > Guilherme Polo wrote: >> >> On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: >>> >>> So, is there a way I can make the background of a frame an image >>> and still have all the widgets (buttons in this case) remain where >>> they are and how >>> they work? >> >> You could just use a Label with a image and use this Label as the >> parent for other widgets you want to place over it. You will >> probably also want to set the window geometry according to this >> background image dimensions. >> > Okay, I tried that and the area just showed up white :(. What do you > suggest? Unfortunately, this is one of the aspects of TK that isn't quite right on OS X. You could use a drawn image of a button on your backdrop image and then monitor for the mouseclick position to determine that the pseudo-button was pressed, but without proper ties to the Carbon Compositor, it's best to use pushbuttons only on default, blank backgrounds. Sorry the news isn't better. Tim From alexnbryan at gmail.com Sun Jul 20 01:40:11 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sat, 19 Jul 2008 16:40:11 -0700 (PDT) Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: References: <18549545.post@talk.nabble.com> <18549826.post@talk.nabble.com> Message-ID: <18549947.post@talk.nabble.com> Tim Jones-8 wrote: > > On Jul 19, 2008, at 4:20 PM, Alexnb wrote: > >> Guilherme Polo wrote: >>> >>> On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: >>>> >>>> So, is there a way I can make the background of a frame an image >>>> and still have all the widgets (buttons in this case) remain where >>>> they are and how >>>> they work? >>> >>> You could just use a Label with a image and use this Label as the >>> parent for other widgets you want to place over it. You will >>> probably also want to set the window geometry according to this >>> background image dimensions. >>> >> Okay, I tried that and the area just showed up white :(. What do you >> suggest? > > Unfortunately, this is one of the aspects of TK that isn't quite right > on OS X. You could use a drawn image of a button on your backdrop > image and then monitor for the mouseclick position to determine that > the pseudo-button was pressed, but without proper ties to the Carbon > Compositor, it's best to use pushbuttons only on default, blank > backgrounds. > > Sorry the news isn't better. > > Tim > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > Well, it's an answer. So thank you very much :) -- View this message in context: http://www.nabble.com/Making-an-image-the-background-of-a-Frame-tp18549545p18549947.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ggpolo at gmail.com Sun Jul 20 02:12:41 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 19 Jul 2008 21:12:41 -0300 Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: References: <18549545.post@talk.nabble.com> <18549826.post@talk.nabble.com> Message-ID: On Sat, Jul 19, 2008 at 8:30 PM, Tim Jones wrote: > On Jul 19, 2008, at 4:20 PM, Alexnb wrote: > >> Guilherme Polo wrote: >>> >>> On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: >>>> >>>> So, is there a way I can make the background of a frame an image and >>>> still have all the widgets (buttons in this case) remain where they are and >>>> how >>>> they work? >>> >>> You could just use a Label with a image and use this Label as the parent >>> for other widgets you want to place over it. You will probably also want to >>> set the window geometry according to this background image dimensions. >>> >> Okay, I tried that and the area just showed up white :(. What do you >> suggest? > > Unfortunately, this is one of the aspects of TK that isn't quite right on OS > X. You could use a drawn image of a button on your backdrop image and then > monitor for the mouseclick position to determine that the pseudo-button was > pressed, but without proper ties to the Carbon Compositor, it's best to use > pushbuttons only on default, blank backgrounds. > Does that happen when using a Canvas too ? Same in Tk 8.5 ? I'm curious, mainly because I don't have a mac to test. > Sorry the news isn't better. > > Tim > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -- -- Guilherme H. Polo Goncalves From timj at tolisgroup.com Sun Jul 20 03:27:32 2008 From: timj at tolisgroup.com (Tim Jones) Date: Sat, 19 Jul 2008 18:27:32 -0700 Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: References: <18549545.post@talk.nabble.com> <18549826.post@talk.nabble.com> Message-ID: On Jul 19, 2008, at 5:12 PM, Guilherme Polo wrote: >> Unfortunately, this is one of the aspects of TK that isn't quite >> right on OS >> X. You could use a drawn image of a button on your backdrop image >> and then >> monitor for the mouseclick position to determine that the pseudo- >> button was >> pressed, but without proper ties to the Carbon Compositor, it's >> best to use >> pushbuttons only on default, blank backgrounds. >> > > Does that happen when using a Canvas too ? Same in Tk 8.5 ? I'm > curious, mainly because I don't have a mac to test. Yes - for the button's background to be "transparent", OS X windows use a model known as Composite. Unfortunately, AFAIK, the TK implementation as it exists doesn't offer a Composite window parameter. Tim From michael.odonnell at uam.es Sun Jul 20 03:32:21 2008 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 20 Jul 2008 03:32:21 +0200 Subject: [Tkinter-discuss] Making an image the background of a Frame In-Reply-To: References: <18549545.post@talk.nabble.com> <18549826.post@talk.nabble.com> Message-ID: <47e491110807191832x7e4cce04g99563e8da60fbc78@mail.gmail.com> Hi, I ran the following on my Mac running python2.5.2 under Panther: from Tkinter import* root = Tk() cwgt=Canvas(root) cwgt.pack(expand=True, fill=BOTH) image1=PhotoImage(file="pict.gif") # keep a link to the image to stop the image being garbage collected cwgt.img=image1 cwgt.create_image(0, 0, anchor=NW, image=image1) b1=Button(cwgt, text="Hello", bd=0) cwgt.create_window(20,20, window=b1, anchor=NW) root.mainloop() (supply your own 'pict.gif') The canvas shows the image as background, and the button on top, functional. However, the button's normal border is there in white (see img below).Would be good to have a button with a transaprent background, but buttons in Mac Tkinter are the MacOS buttons, which are hard to change. Mick On Sun, Jul 20, 2008 at 2:12 AM, Guilherme Polo wrote: > On Sat, Jul 19, 2008 at 8:30 PM, Tim Jones wrote: >> On Jul 19, 2008, at 4:20 PM, Alexnb wrote: >> >>> Guilherme Polo wrote: >>>> >>>> On Sat, Jul 19, 2008 at 7:43 PM, Alexnb wrote: >>>>> >>>>> So, is there a way I can make the background of a frame an image and >>>>> still have all the widgets (buttons in this case) remain where they are and >>>>> how >>>>> they work? >>>> >>>> You could just use a Label with a image and use this Label as the parent >>>> for other widgets you want to place over it. You will probably also want to >>>> set the window geometry according to this background image dimensions. >>>> >>> Okay, I tried that and the area just showed up white :(. What do you >>> suggest? >> >> Unfortunately, this is one of the aspects of TK that isn't quite right on OS >> X. You could use a drawn image of a button on your backdrop image and then >> monitor for the mouseclick position to determine that the pseudo-button was >> pressed, but without proper ties to the Carbon Compositor, it's best to use >> pushbuttons only on default, blank backgrounds. >> > > Does that happen when using a Canvas too ? Same in Tk 8.5 ? I'm > curious, mainly because I don't have a mac to test. > >> Sorry the news isn't better. >> >> Tim >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > > > -- > -- Guilherme H. Polo Goncalves > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Sun Jul 20 04:44:42 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Jul 2008 22:44:42 -0400 Subject: [Tkinter-discuss] Issue with scrolling in a Text() widget on a mac In-Reply-To: <18547417.post@talk.nabble.com> References: <18541172.post@talk.nabble.com> <4881F290.5090009@codebykevin.com> <18546400.post@talk.nabble.com> <48821A9E.6060107@codebykevin.com> <18546591.post@talk.nabble.com> <48821EF5.2010507@codebykevin.com> <18546701.post@talk.nabble.com> <488225AB.8000602@codebykevin.com> <18546978.post@talk.nabble.com> <18547417.post@talk.nabble.com> Message-ID: <4882A69A.8010504@codebykevin.com> Alexnb wrote: > > Okay I installed the dmg but I still have the same version.. what am I > missing? > You forgot to rebuild Python from source. :-) Comment out the line in setup.py that lists /System/Library as a place to search for Tk, and it will search in /Library instead, and link against the new 8.5 version of Tk you've installed. Run ./configure --enable-framework --enable-universalsdk and you should be good to go. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From alexnbryan at gmail.com Sun Jul 27 21:23:52 2008 From: alexnbryan at gmail.com (Alexnb) Date: Sun, 27 Jul 2008 12:23:52 -0700 (PDT) Subject: [Tkinter-discuss] tkinter print file Dialog? Message-ID: <18679602.post@talk.nabble.com> So, I know there is a tk.openfiledialog() thing. But is there one for printing? like I am doubting it, but I want to prompt the user and let them be able to pick a printer. Is there one? or is there a good way to do this? -- View this message in context: http://www.nabble.com/tkinter-print-file-Dialog--tp18679602p18679602.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From kw at codebykevin.com Mon Jul 28 01:56:17 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 27 Jul 2008 19:56:17 -0400 Subject: [Tkinter-discuss] tkinter print file Dialog? In-Reply-To: <18679602.post@talk.nabble.com> References: <18679602.post@talk.nabble.com> Message-ID: <488D0B21.7030006@codebykevin.com> Alexnb wrote: > So, I know there is a tk.openfiledialog() thing. But is there one for > printing? like I am doubting it, but I want to prompt the user and let them > be able to pick a printer. Is there one? or is there a good way to do this? There is no general cross-platform printing method in Tkinter. There are separate solutions for Windows and Mac. Google can help here, as can the Tcl/Tk wiki at http://wiki.tcl.tk. Under *Nix, you will probably have to roll your own dialog and sent output to lpr. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From pbanfis at hotmail.it Mon Jul 28 11:14:05 2008 From: pbanfis at hotmail.it (Ambigioz) Date: Mon, 28 Jul 2008 02:14:05 -0700 (PDT) Subject: [Tkinter-discuss] [Tkinter]Right click popup Message-ID: <18686679.post@talk.nabble.com> Hello, I'm trying to do a notepad with tkinter in windows (well also for linux),and i'd like to create a popup with 'copy' , 'paste', 'cut', bla bla,on right click. My only problem it's to create that popup,because it's not neither toplevel nor alerts dialogs...can you help me?:p -- View this message in context: http://www.nabble.com/-Tkinter-Right-click-popup-tp18686679p18686679.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Mon Jul 28 22:07:44 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 28 Jul 2008 20:07:44 +0000 Subject: [Tkinter-discuss] [Tkinter]Right click popup In-Reply-To: <18686679.post@talk.nabble.com> References: <18686679.post@talk.nabble.com> Message-ID: <20080728200744.GA5442@lairds.us> On Mon, Jul 28, 2008 at 02:14:05AM -0700, Ambigioz wrote: . . . > I'm trying to do a notepad with tkinter in windows (well also for linux),and > i'd like to create a popup with 'copy' , 'paste', 'cut', bla bla,on right > click. > My only problem it's to create that popup,because it's not neither toplevel > nor alerts dialogs...can you help me?:p . . . Why is it not a toplevel? Is the sort of thing you're after? How about ? From pbanfis at hotmail.it Tue Jul 29 00:06:29 2008 From: pbanfis at hotmail.it (Ambigioz) Date: Mon, 28 Jul 2008 15:06:29 -0700 (PDT) Subject: [Tkinter-discuss] [Tkinter]Right click popup In-Reply-To: <18686679.post@talk.nabble.com> References: <18686679.post@talk.nabble.com> Message-ID: <18700817.post@talk.nabble.com> Because toplevel has got the windows manager buttons (close,expand,hide) and on right click i want only a rectangle with those commands.. -- View this message in context: http://www.nabble.com/-Tkinter-Right-click-popup-tp18686679p18700817.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From pbanfis at hotmail.it Tue Jul 29 00:08:36 2008 From: pbanfis at hotmail.it (Ambigioz) Date: Mon, 28 Jul 2008 15:08:36 -0700 (PDT) Subject: [Tkinter-discuss] [Tkinter]Right click popup Message-ID: <18700817.post@talk.nabble.com> Oh thanks!!!!!!Sorry for my ignorance ehehe :blush: -- View this message in context: http://www.nabble.com/-Tkinter-Right-click-popup-tp18686679p18700817.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From Cameron at phaseit.net Tue Jul 29 00:18:21 2008 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 28 Jul 2008 22:18:21 +0000 Subject: [Tkinter-discuss] [Tkinter]Right click popup In-Reply-To: <18700817.post@talk.nabble.com> References: <18686679.post@talk.nabble.com> <18700817.post@talk.nabble.com> Message-ID: <20080728221821.GA1529@lairds.us> On Mon, Jul 28, 2008 at 03:06:29PM -0700, Ambigioz wrote: . . . > Because toplevel has got the windows manager buttons (close,expand,hide) and > on right click i want only a rectangle with those commands.. . . . I believe Ambigioz has his current needs met, so might be indifferent to toplevel details now. For anyone else who comes across this thread, though, I want to be clear: Tkinter offers at least a couple of ways to configure the window-manager buttons. Don't think that all toplevels have to behave the same in this regard. From igor.e.novikov at gmail.com Tue Jul 29 02:25:57 2008 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Tue, 29 Jul 2008 03:25:57 +0300 Subject: [Tkinter-discuss] [Tkinter]Right click popup In-Reply-To: <18700817.post@talk.nabble.com> References: <18686679.post@talk.nabble.com> <18700817.post@talk.nabble.com> Message-ID: <23f7fc190807281725ia2a3bbegcc79bfba56f724b3@mail.gmail.com> Here is tooltips implementation for Tkinter/ttk based on Toplevel class: http://sk1.svn.sourceforge.net/viewvc/sk1/trunk/sK1/src/app/UI/lib-ttk/tooltips.py?view=markup On Tue, Jul 29, 2008 at 1:06 AM, Ambigioz wrote: > > > Because toplevel has got the windows manager buttons (close,expand,hide) > and > on right click i want only a rectangle with those commands.. > -- > View this message in context: > http://www.nabble.com/-Tkinter-Right-click-popup-tp18686679p18700817.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gnernest at yahoo.com Tue Jul 29 15:18:51 2008 From: gnernest at yahoo.com (Mezesh) Date: Tue, 29 Jul 2008 06:18:51 -0700 (PDT) Subject: [Tkinter-discuss] Displaying multiple image frames sequentially on the same window Message-ID: <18711958.post@talk.nabble.com> """ Hi all, I am relatively new to Tk and after following some examples from various sources, I have managed to write the (drastically simplified for posting purposes) code below. I'm sure that there are some glaring issues with the code and I'm not quite in touch with what I'm doing, but all I need to do is to get a prototype working. My problem is that I need to start a server which a client will connect to and send some image data over tcp. These images are sent at a rate of say 10 frames per second and I want to write the data to file and display it on a Tk window. I also want to show multiple frames as the data arrives without opening a new window each time. So, I have three classes: 1)ThreadedClient which launches the gui and starts a server thread 2)TCPServer which is the server whose handle() method is called when there's data to be processed and 3)Window which is the gui. The server thread works fine i.e it receives image data, writes the data to a file and puts a number on the queue to identify the image file. Note that the queue is global,I haven't yet figured out how to pass it to the server but it works fine for now, I think. Also, if I click on the main window using a mouse button, the event handler paint() is called fine and it loads the image every time I make a mouse click. Now I don't want the handler to be called only when the user clicks on the window, I would like it to be called periodically to check if there's something in the queue. That's what I intended to do with the periodicCall() method in the ThreadedClient class. The problem is, when I attempt to generate the mouse event, it blocks and so it is called only once. I'm not really sure how to get the mouse event generated periodically. I have run out of ideas about how to do this, so I would appreciate any help. Cheers, Mezesh --- """ import Tkinter,ImageTk,Image import threading,os,sys,Queue class Window: def __init__(self,master,queue): self.master = master self.master.bind("