From amit.finkler at gmail.com Tue Jan 1 11:04:11 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Tue, 01 Jan 2008 12:04:11 +0200 Subject: [Tkinter-discuss] Entry Widget - Setting a Default Text - continuted Message-ID: <477A101B.2000301@gmail.com> Hi, I tried setting up the following GUI: import Numeric, time from Tkinter import * import tkFileDialog def exec_2D(): """Main execution function. Takes input values from user, i.e. magnetic field and current values, filename, series resistance and runs a two-dimensional scan, line scans over the current for each magnetic field value.""" yoko_gpib = int(YokoAdr.get()) mag_gpib = int(MagAdr.get()) dmm_gpib = int(DMMAdr.get()) Rs = float(Rs_entr.get()) mag_coef = float(Mg_entr.get()) StartI = float(Ie_init.get())*Rs EndI = float(Ie_finl.get())*Rs StepI = float(Ie_step.get())*Rs StartH = float(He_init.get())/mag_coef EndH = float(He_finl.get())/mag_coef StepH = float(He_step.get())/mag_coef def RampYoko(): yoko_gpib = int(YokoAdr.get()) Rs = float(Rs_entr.get()) StartI = float(Ie_init.get())*Rs StepI = float(Ie_step.get())*Rs def RampMag(): mag_gpib = int(MagAdr.get()) mag_coef = float(Mg_entr.get()) StartH = float(He_init.get())/mag_coef StepH = float(He_step.get())/mag_coef def cooldown(): """Cooldown procedure. Call subprocedure of miniprograms to run a cooldown measurement""" lake_gpib = int(LakeAdr.get()) dmm_gpib = int(DMMAdr.get()) yoko_gpib = int(YokoAdr.get()) Rs = float(Rs_entr.get()) StartI = float(Ie_init.get())*Rs def IV_DC(): """DC IV procedure. Call subprocedure dc_scan of miniprograms module to run an IV measurement""" yoko_gpib = int(YokoAdr.get()) dmm_gpib = int(DMMAdr.get()) Rs = float(Rs_entr.get()) StartI = float(Ie_init.get())*Rs EndI = float(Ie_finl.get())*Rs StepI = float(Ie_step.get())*Rs def Mag_DC(): """DC Magnetic field dependence procedure. CAll subprocedure mag_field_dc_scan of miniprograms module to run a mag measurement""" mag_gpib = int(MagAdr.get()) dmm_gpib = int(DMMAdr.get()) mag_coef = float(Mg_entr.get()) StartH = float(He_init.get())/mag_coef EndH = float(He_finl.get())/mag_coef StepH = float(He_step.get())/mag_coef def file_save_as(event): """ Simple function, whose input is a mouse button click and its, opening a dialog box asking the user for a filename to save the data in and in return prints out a label to the right of the button which states the path of this file. Mostly serves as an indicator to the user where he/she saves his/her file.""" global fn fn = tkFileDialog.asksaveasfilename() FilenameDisplay.configure(text = fn,fg = 'white', bg = 'black') def query_Yokogawa(event): """ Real-time query of the current output of the Yokogawa power supply. Input is a mouse button click. Output is the current output displayed to the right of that button. Standard procedure really. """ yokogawa_gpib = int(YokoAdr.get()) def query_temperature(event): """ Real-time query of the current temperature in the bottom of the rod as measured by the Lakeshore 330 temperature controller. Input is a mouse button click. Output is the current temperature displayed to the right of that button. Standard procedure really. """ def query_temperature2(event): """ Real-time query of the current temperature in the bottom of the rod as measured by the Lakeshore 330 temperature controller. Input is a mouse button click. Output is the current temperature displayed to the right of that button. Standard procedure really. """ def query_field(event): """ Real-time query of the current external magnetic field in play. Input is a mouse button click. Output is the current magnetic field displayed to the right of that button. Standard procedure really. """ ########################################################## # # # END OF FUNCTIONS # # # ########################################################## # Define main windows and their subframes win = Tk() win.title('Control Panel') win2 = Tk() win2.title('Configuration and Monitoring') f = Frame(win, bd = 2, relief = 'groove') f2 = Frame(win2, bd = 2, relief = 'groove') # Define variables and their default values I_init = StringVar() H_init = StringVar() I_finl = StringVar() H_finl = StringVar() I_step = StringVar() H_step = StringVar() R_ser = IntVar() M_coef = IntVar() R_ser.set('10000') M_coef.set('1119') Yoko_adr = IntVar() Mag_adr = IntVar() DMM_adr = IntVar() Lake_adr = IntVar() Lake2_adr = IntVar() Yoko_adr.set('2') Mag_adr.set('10') DMM_adr.set('22') Lake_adr.set('12') Lake2_adr.set('1') # Variable input boxes from user Ie_init = Entry(f, textvariable = I_init) He_init = Entry(f, textvariable = H_init) Ie_finl = Entry(f, textvariable = I_finl) He_finl = Entry(f, textvariable = H_finl) Ie_step = Entry(f, textvariable = I_step) He_step = Entry(f, textvariable = H_step) Rs_entr = Entry(f, textvariable = R_ser) Mg_entr = Entry(f, textvariable = M_coef) Il_init = Label(f, text = 'Initial/set current [A]') Hl_init = Label(f, text = 'Initial field [Gauss]') Il_finl = Label(f, text = 'Final current [A]') Hl_finl = Label(f, text = 'Final field [Gauss]') Il_step = Label(f, text = 'Current step[A]') Hl_step = Label(f, text = 'Field step[Gauss]') Rs_labl = Label(f, text = 'Series Resistance [Ohm]', fg = 'magenta') Mg_labl = Label(f, text = 'Magnet Coef. [Gauss/A]', fg = 'magenta') YokoAdr = Entry(f2, textvariable = Yoko_adr) MagAdr = Entry(f2, textvariable = Mag_adr) DMMAdr = Entry(f2, textvariable = DMM_adr) LakeAdr = Entry(f2, textvariable = Lake_adr) Lake2Adr = Entry(f2, textvariable = Lake2_adr) YokoAdrLabel = Label(f2, text = 'Yoko address') MagAdrLabel = Label(f2, text = 'Magnet address') DMMAdrLabel = Label(f2, text = 'DMM address') LakeAdrLabel = Label(f2, text = 'Lakeshore (Rod) address') Lake2AdrLabel = Label(f2, text = 'Lakeshore (Cryostat) address') # Place input boxes and labels on a grid YokoAdrLabel.grid(row = 0, column = 0) YokoAdr.grid(row = 1, column = 0) MagAdrLabel.grid(row = 2, column = 0) MagAdr.grid(row = 3, column = 0) DMMAdrLabel.grid(row = 4, column = 0) DMMAdr.grid(row = 5, column = 0) LakeAdrLabel.grid(row = 6, column = 0) LakeAdr.grid(row = 7, column = 0) Lake2AdrLabel.grid(row = 8, column = 0) Lake2Adr.grid(row = 9, column = 0) Il_init.grid(row = 0, column = 0) Hl_init.grid(row = 0, column = 2) Ie_init.grid(row = 1, column = 0) He_init.grid(row = 1, column = 2) Il_finl.grid(row = 2, column = 0) Hl_finl.grid(row = 2, column = 2) Ie_finl.grid(row = 3, column = 0) He_finl.grid(row = 3, column = 2) Il_step.grid(row = 4, column = 0) Hl_step.grid(row = 4, column = 2) Ie_step.grid(row = 5, column = 0) He_step.grid(row = 5, column = 2) Rs_labl.grid(row = 6, column = 0) Rs_entr.grid(row = 7, column = 0) Mg_labl.grid(row = 6, column = 2) Mg_entr.grid(row = 7, column = 2) # Define execute 2D scan button RunFrame = Frame(win, bd = 2, relief = 'groove') Run2D = Button(RunFrame) Run2D.configure(text = 'Run 2D', fg = 'blue', command = exec_2D) Run2D.pack(side = LEFT) RunCooldown = Button(RunFrame) RunCooldown.configure(text = 'Cooldown', fg = 'blue', command = cooldown) RunCooldown.pack(side = LEFT) RunIVDC = Button(RunFrame) RunIVDC.configure(text = 'IV-DC', fg = 'blue', command = IV_DC) RunIVDC.pack(side = LEFT) RunRampYoko = Button(RunFrame) RunRampYoko.configure(text = 'Ramp Yoko', fg = 'blue', command = RampYoko) RunRampYoko.pack(side = LEFT) RunRampMag = Button(RunFrame) RunRampMag.configure(text = 'Ramp Field', fg = 'blue', command = RampMag) RunRampMag.pack(side = LEFT) RunMagDC = Button(RunFrame) RunMagDC.configure(text = 'Mag-DC', fg = 'blue', command = Mag_DC) RunMagDC.pack(side = LEFT) # Define Filename Frame FilenameFrame = Frame(win, bd = 2, relief = 'groove') Filename = Button(FilenameFrame) Filename.configure(text = 'Save in file...') Filename.bind("",file_save_as) Filename.pack(side=LEFT) FilenameDisplay = Label(FilenameFrame) FilenameDisplay.pack(side = LEFT) # Monitor Frame MonitorFrame = Frame(win2, bd = 2, relief = 'groove') QueryField = Button(MonitorFrame) QueryField.configure(text = 'Query Field', fg = 'DarkViolet') QueryField.bind("", query_field) PrintField = Label(MonitorFrame) QueryField.grid(row = 0, column = 0) PrintField.grid(row = 0, column = 1) QueryLake = Button(MonitorFrame) QueryLake.configure(text = 'Query Rod Temperature', fg = 'DarkViolet') QueryLake.bind("", query_temperature) PrintLake = Label(MonitorFrame) QueryLake.grid(row = 1, column = 0) PrintLake.grid(row = 1, column = 1) QueryLake2 = Button(MonitorFrame) QueryLake2.configure(text = 'Query Cryostat Temperature', fg = 'DarkViolet') QueryLake2.bind("", query_temperature2) PrintLake2 = Label(MonitorFrame) QueryLake2.grid(row = 2, column = 0) PrintLake2.grid(row = 2, column = 1) QueryYoko = Button(MonitorFrame) QueryYoko.configure(text = 'Query Yokogawa', fg = 'DarkViolet') QueryYoko.bind("", query_Yokogawa) PrintYoko = Label(MonitorFrame) QueryYoko.grid(row = 3, column = 0) PrintYoko.grid(row = 3, column = 1) # Pack everything together # Window 1 packing f.pack() FilenameFrame.pack() RunFrame.pack() # Window 2 packing f2.pack() MonitorFrame.pack() Two windows open, but in window number 2 I set some default text into 5 fields and they don't appear. If, however, I change "win2" to "win" in line 100 (the definition of "f2" frame), all the 5 default numbers appear in their respective widgets. Any idea why this happens? Thanks, Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080101/8494c247/attachment-0001.htm From godson.g at gmail.com Tue Jan 1 13:28:49 2008 From: godson.g at gmail.com (Godson Gera) Date: Tue, 1 Jan 2008 17:58:49 +0530 Subject: [Tkinter-discuss] Entry Widget - Setting a Default Text - continuted In-Reply-To: <477A101B.2000301@gmail.com> References: <477A101B.2000301@gmail.com> Message-ID: On Jan 1, 2008 3:34 PM, Amit Finkler wrote: > Hi, > > > I tried setting up the following GUI: > > > import Numeric, time > from Tkinter import * > import tkFileDialog > > def exec_2D(): > """Main execution function. Takes input values from user, i.e. > magnetic field and current values, filename, series resistance and runs a > two-dimensional scan, line scans over the current for each magnetic field > value.""" > yoko_gpib = int(YokoAdr.get()) > mag_gpib = int(MagAdr.get()) > dmm_gpib = int(DMMAdr.get()) > Rs = float(Rs_entr.get()) > mag_coef = float(Mg_entr.get()) > StartI = float(Ie_init.get())*Rs > EndI = float(Ie_finl.get())*Rs > StepI = float(Ie_step.get())*Rs > StartH = float(He_init.get())/mag_coef > EndH = float(He_finl.get())/mag_coef > StepH = float(He_step.get())/mag_coef > > def RampYoko(): > > yoko_gpib = int(YokoAdr.get()) > Rs = float(Rs_entr.get()) > StartI = float(Ie_init.get())*Rs > StepI = float(Ie_step.get())*Rs > > def RampMag(): > > mag_gpib = int(MagAdr.get()) > mag_coef = float(Mg_entr.get()) > StartH = float(He_init.get())/mag_coef > StepH = float(He_step.get())/mag_coef > > def cooldown(): > """Cooldown procedure. Call subprocedure of miniprograms to run a > cooldown measurement""" > > lake_gpib = int(LakeAdr.get()) > dmm_gpib = int(DMMAdr.get()) > yoko_gpib = int(YokoAdr.get()) > Rs = float(Rs_entr.get()) > StartI = float(Ie_init.get())*Rs > > def IV_DC(): > """DC IV procedure. Call subprocedure dc_scan of miniprograms module > to run an IV measurement""" > yoko_gpib = int(YokoAdr.get()) > dmm_gpib = int(DMMAdr.get()) > Rs = float(Rs_entr.get()) > StartI = float(Ie_init.get())*Rs > EndI = float(Ie_finl.get())*Rs > StepI = float(Ie_step.get())*Rs > > def Mag_DC(): > """DC Magnetic field dependence procedure. CAll subprocedure > mag_field_dc_scan of miniprograms module to run a mag measurement""" > > mag_gpib = int(MagAdr.get()) > dmm_gpib = int(DMMAdr.get()) > mag_coef = float(Mg_entr.get()) > StartH = float(He_init.get())/mag_coef > EndH = float(He_finl.get())/mag_coef > StepH = float(He_step.get())/mag_coef > > def file_save_as(event): > """ Simple function, whose input is a mouse button click and its, > opening a dialog box asking the user for a filename to save the data in and > in return prints out a label to the right of the button which states the > path of this file. Mostly serves as an indicator to the user where he/she > saves his/her file.""" > global fn > fn = tkFileDialog.asksaveasfilename() > FilenameDisplay.configure(text = fn,fg = 'white', bg = 'black') > > def query_Yokogawa(event): > """ Real-time query of the current output of the Yokogawa power > supply. Input is a mouse button click. Output is the current output > displayed to the right of that button. Standard procedure really. """ > > yokogawa_gpib = int(YokoAdr.get()) > > def query_temperature(event): > """ Real-time query of the current temperature in the bottom of the > rod as measured by the Lakeshore 330 temperature controller. Input is a > mouse button click. Output is the current temperature displayed to the right > of that button. Standard procedure really. """ > > > > def query_temperature2(event): > """ Real-time query of the current temperature in the bottom of the > rod as measured by the Lakeshore 330 temperature controller. Input is a > mouse button click. Output is the current temperature displayed to the right > of that button. Standard procedure really. """ > > > > def query_field(event): > """ Real-time query of the current external magnetic field in play. > Input is a mouse button click. Output is the current magnetic field > displayed to the right of that button. Standard procedure really. """ > > > ########################################################## > # # > # END OF FUNCTIONS # > # # > ########################################################## > > # Define main windows and their subframes > win = Tk() > win.title('Control Panel') > > win2 = Tk() > win2.title('Configuration and Monitoring') > > f = Frame(win, bd = 2, relief = 'groove') > f2 = Frame(win2, bd = 2, relief = 'groove') > > # Define variables and their default values > > I_init = StringVar() > H_init = StringVar() > I_finl = StringVar() > H_finl = StringVar() > I_step = StringVar() > H_step = StringVar() > R_ser = IntVar() > M_coef = IntVar() > R_ser.set('10000') > M_coef.set('1119') > > Yoko_adr = IntVar() > Mag_adr = IntVar() > DMM_adr = IntVar() > Lake_adr = IntVar() > Lake2_adr = IntVar() > Yoko_adr.set('2') > Mag_adr.set('10') > DMM_adr.set('22') > Lake_adr.set('12') > Lake2_adr.set('1') > > > > # Variable input boxes from user > > Ie_init = Entry(f, textvariable = I_init) > He_init = Entry(f, textvariable = H_init) > Ie_finl = Entry(f, textvariable = I_finl) > He_finl = Entry(f, textvariable = H_finl) > Ie_step = Entry(f, textvariable = I_step) > He_step = Entry(f, textvariable = H_step) > Rs_entr = Entry(f, textvariable = R_ser) > Mg_entr = Entry(f, textvariable = M_coef) > Il_init = Label(f, text = 'Initial/set current [A]') > Hl_init = Label(f, text = 'Initial field [Gauss]') > Il_finl = Label(f, text = 'Final current [A]') > Hl_finl = Label(f, text = 'Final field [Gauss]') > Il_step = Label(f, text = 'Current step[A]') > Hl_step = Label(f, text = 'Field step[Gauss]') > Rs_labl = Label(f, text = 'Series Resistance [Ohm]', fg = > 'magenta') > Mg_labl = Label(f, text = 'Magnet Coef. [Gauss/A]', fg = > 'magenta') > > YokoAdr = Entry(f2, textvariable = Yoko_adr) > MagAdr = Entry(f2, textvariable = Mag_adr) > DMMAdr = Entry(f2, textvariable = DMM_adr) > LakeAdr = Entry(f2, textvariable = Lake_adr) > Lake2Adr = Entry(f2, textvariable = Lake2_adr) > YokoAdrLabel = Label(f2, text = 'Yoko address') > MagAdrLabel = Label(f2, text = 'Magnet address') > DMMAdrLabel = Label(f2, text = 'DMM address') > LakeAdrLabel = Label(f2, text = 'Lakeshore (Rod) address') > Lake2AdrLabel = Label(f2, text = 'Lakeshore (Cryostat) address') > > > > # Place input boxes and labels on a grid > > YokoAdrLabel.grid(row = 0, column = 0) > YokoAdr.grid(row = 1, column = 0) > MagAdrLabel.grid(row = 2, column = 0) > MagAdr.grid(row = 3, column = 0) > DMMAdrLabel.grid(row = 4, column = 0) > DMMAdr.grid(row = 5, column = 0) > LakeAdrLabel.grid(row = 6, column = 0) > LakeAdr.grid(row = 7, column = 0) > Lake2AdrLabel.grid(row = 8, column = 0) > Lake2Adr.grid(row = 9, column = 0) > > Il_init.grid(row = 0, column = 0) > Hl_init.grid(row = 0, column = 2) > Ie_init.grid(row = 1, column = 0) > He_init.grid(row = 1, column = 2) > Il_finl.grid(row = 2, column = 0) > Hl_finl.grid(row = 2, column = 2) > Ie_finl.grid(row = 3, column = 0) > He_finl.grid(row = 3, column = 2) > Il_step.grid(row = 4, column = 0) > Hl_step.grid(row = 4, column = 2) > Ie_step.grid(row = 5, column = 0) > He_step.grid(row = 5, column = 2) > Rs_labl.grid(row = 6, column = 0) > Rs_entr.grid(row = 7, column = 0) > Mg_labl.grid(row = 6, column = 2) > Mg_entr.grid(row = 7, column = 2) > > # Define execute 2D scan button > RunFrame = Frame(win, bd = 2, relief = 'groove') > Run2D = Button(RunFrame) > Run2D.configure(text = 'Run 2D', fg = 'blue', command = exec_2D) > Run2D.pack(side = LEFT) > RunCooldown = Button(RunFrame) > RunCooldown.configure(text = 'Cooldown', fg = 'blue', command = cooldown) > RunCooldown.pack(side = LEFT) > RunIVDC = Button(RunFrame) > RunIVDC.configure(text = 'IV-DC', fg = 'blue', command = IV_DC) > RunIVDC.pack(side = LEFT) > RunRampYoko = Button(RunFrame) > RunRampYoko.configure(text = 'Ramp Yoko', fg = 'blue', command = RampYoko) > RunRampYoko.pack(side = LEFT) > RunRampMag = Button(RunFrame) > RunRampMag.configure(text = 'Ramp Field', fg = 'blue', command = RampMag) > RunRampMag.pack(side = LEFT) > RunMagDC = Button(RunFrame) > RunMagDC.configure(text = 'Mag-DC', fg = 'blue', command = Mag_DC) > RunMagDC.pack(side = LEFT) > > # Define Filename Frame > > FilenameFrame = Frame(win, bd = 2, relief = 'groove') > Filename = Button(FilenameFrame) > Filename.configure(text = 'Save in file...') > Filename.bind("",file_save_as) > Filename.pack(side=LEFT) > FilenameDisplay = Label(FilenameFrame) > FilenameDisplay.pack(side = LEFT) > > # Monitor Frame > > MonitorFrame = Frame(win2, bd = 2, relief = 'groove') > > QueryField = Button(MonitorFrame) > QueryField.configure(text = 'Query Field', fg = 'DarkViolet') > QueryField.bind("", query_field) > PrintField = Label(MonitorFrame) > QueryField.grid(row = 0, column = 0) > PrintField.grid(row = 0, column = 1) > > QueryLake = Button(MonitorFrame) > QueryLake.configure(text = 'Query Rod Temperature', fg = 'DarkViolet') > QueryLake.bind("", query_temperature) > PrintLake = Label(MonitorFrame) > QueryLake.grid(row = 1, column = 0) > PrintLake.grid(row = 1, column = 1) > > QueryLake2 = Button(MonitorFrame) > QueryLake2.configure(text = 'Query Cryostat Temperature', fg = > 'DarkViolet') > QueryLake2.bind("", query_temperature2) > PrintLake2 = Label(MonitorFrame) > QueryLake2.grid(row = 2, column = 0) > PrintLake2.grid(row = 2, column = 1) > > QueryYoko = Button(MonitorFrame) > QueryYoko.configure(text = 'Query Yokogawa', fg = 'DarkViolet') > QueryYoko.bind("", query_Yokogawa) > PrintYoko = Label(MonitorFrame) > QueryYoko.grid(row = 3, column = 0) > PrintYoko.grid(row = 3, column = 1) > > # Pack everything together > > # Window 1 packing > f.pack() > FilenameFrame.pack() > RunFrame.pack() > > # Window 2 packing > f2.pack() > MonitorFrame.pack() > > Two windows open, but in window number 2 I set some default text into 5 > fields and they don't appear. If, however, I change "win2" to "win" in line > 100 (the definition of "f2" frame), all the 5 default numbers appear in > their respective widgets. > > > Any idea why this happens? > > > Thanks, > > > Amit. > > > Hi Amit, There should be only one instance of Tk() in your Tkinter Application (if I remember correctly). So if you want to create additional windows use Toplevel() instead of Tk(). Toplevel takes optional parent window argument like Toplevel(win) so line 96 should look like win2=Toplevel() HTH -- Godson Gera, http://godson.in Python Tkinter India. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080101/ddd2cc15/attachment-0001.htm From amit.finkler at gmail.com Tue Jan 1 13:39:52 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Tue, 01 Jan 2008 14:39:52 +0200 Subject: [Tkinter-discuss] Entry Widget - Setting a Default Text - continuted Message-ID: <477A3498.2050809@gmail.com> Hi Amit, There should be only one instance of Tk() in your Tkinter Application (if I remember correctly). So if you want to create additional windows use Toplevel() instead of Tk(). Toplevel takes optional parent window argument like Toplevel(win) so line 96 should look like win2=Toplevel() HTH -- Godson Gera, http://godson.in Python Tkinter India. You remember correctly. This is indeed the solution. Thanks! Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080101/6150b916/attachment.htm From fredrik at pythonware.com Wed Jan 2 18:56:49 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 02 Jan 2008 18:56:49 +0100 Subject: [Tkinter-discuss] redirecting Python stdout/stderr to a Tkinter text widget from an embedded Python application In-Reply-To: References: Message-ID: Bernard B Yoo wrote: > I have a Python module that redirects stdout/stderr to a Tkinter text > widget. When I run this from the Python interpreter, it behaves as I > expect. When I run it from a Python batch file, it also behaves as > expected. > > When I embed the module in a C program, the Tkinter text widget does not > appear. > > Is there something special I must do in embedded Python programs to make > Tkinter widgets appear? you must keep the mainloop running, so that Tk(inter) gets around to process the events. can you perhaps provide some more details on how you're doing the redirecting and the embedding? From bob at passcal.nmt.edu Sun Jan 6 00:08:42 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 5 Jan 2008 16:08:42 -0700 Subject: [Tkinter-discuss] DISABLE'ed Entry fields Message-ID: If you create an Entry field with bg="white and fg="black" and then disable it the fg color goes to lightgrey and the fg to grey (with my specific color setup on a Solaris box). Is there a way to stop that and keep either the background white or the foreground black? Either one would be fine, but as it is it's kind of hard to read. Thanks! Bob From bob at passcal.nmt.edu Sun Jan 6 00:12:58 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 5 Jan 2008 16:12:58 -0700 Subject: [Tkinter-discuss] DISABLE'ed Entry fields In-Reply-To: References: Message-ID: <84A6EA1A-B697-475E-BDF5-8DDC68815F1B@passcal.nmt.edu> Doh. Grayson didn't list disabled- background and foreground where I was looking (under Entry()). On Jan 5, 2008, at 16:08, Bob Greschke wrote: > If you create an Entry field with bg="white and fg="black" and then > disable it the fg color goes to lightgrey and the fg to grey (with > my specific color setup on a Solaris box). Is there a way to stop > that and keep either the background white or the foreground black? > Either one would be fine, but as it is it's kind of hard to read. > > Thanks! > > Bob > From fredrik at pythonware.com Sun Jan 6 11:02:48 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Jan 2008 11:02:48 +0100 Subject: [Tkinter-discuss] DISABLE'ed Entry fields In-Reply-To: <84A6EA1A-B697-475E-BDF5-8DDC68815F1B@passcal.nmt.edu> References: <84A6EA1A-B697-475E-BDF5-8DDC68815F1B@passcal.nmt.edu> Message-ID: Bob Greschke wrote: > Doh. Grayson didn't list disabled- background and foreground where I > was looking (under Entry()). iirc, the disabled* options are relatively recent additions to Tk (for a suitable definition of recent, of course). From rajeev1204 at gmail.com Sun Jan 6 12:09:58 2008 From: rajeev1204 at gmail.com (Rajeev Nair) Date: Sun, 6 Jan 2008 16:39:58 +0530 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 47, Issue 5 In-Reply-To: References: Message-ID: hi can anyone tell me how to use the entry field to enter system password? So instead of system asking me in terminal i want to enter the password through the entry field. thanks rajeev From fredrik at pythonware.com Sun Jan 6 14:54:05 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Jan 2008 14:54:05 +0100 Subject: [Tkinter-discuss] use entry field to enter password (Re: Tkinter-discuss Digest, Vol 47, Issue 5) In-Reply-To: References: Message-ID: (please don't open new threads by replying to some random unrelated message. also, please use a proper subject. thanks!) Rajeev Nair wrote: > can anyone tell me how to use the entry field to enter system password? > So instead of system asking me in terminal i want to enter the > password through the entry field. not sure what you mean by "system" here, but to use the Entry widget to enter a password, you can set the "show" option: widget = Entry(parent, show="*", width=15) From timj at tolisgroup.com Sun Jan 6 16:30:21 2008 From: timj at tolisgroup.com (Tim Jones) Date: Sun, 6 Jan 2008 08:30:21 -0700 Subject: [Tkinter-discuss] use entry field to enter password (Re: Tkinter-discuss Digest, Vol 47, Issue 5) In-Reply-To: References: Message-ID: <47000953-DC35-4824-8DDB-3644FF452954@tolisgroup.com> On Jan 6, 2008, at 6:54 AM, Fredrik Lundh wrote: > Rajeev Nair wrote: > >> can anyone tell me how to use the entry field to enter system >> password? >> So instead of system asking me in terminal i want to enter the >> password through the entry field. > > not sure what you mean by "system" here, This sounds as if Rajeev is trying to place a wrapper around 'sudo'. If so, you'll need to get the username and password and the pass them through to the sudo'd command like this (assumes the user is in the / etc/sudoers file and that thePassword contains their password): echo thePassword | sudo -S theCommand If I've mis-guessed here, please explain what you're trying to achieve further. Tim From hsa01 at bitflipper.ca Mon Jan 7 22:06:12 2008 From: hsa01 at bitflipper.ca (Cam Farnell) Date: Mon, 07 Jan 2008 16:06:12 -0500 Subject: [Tkinter-discuss] Tkinter slows down In-Reply-To: <20070106203356.04da9827.klappnase@web.de> References: <459EDA4F.4030209@codebykevin.com> <20070106203356.04da9827.klappnase@web.de> Message-ID: <47829444.7020900@bitflipper.ca> I'm creating a program which displays spreadsheet-like data using hundreds of labels. At first this works fine, however after a few redisplays it starts slowing down dramatically. A small test program, without the distractions of the real program is: from Tkinter import * def Go(): LabelList = [] for J in range(30): print J for L in LabelList: L.grid_forget() LabelList = [] for Row in range(20): for Col in range(20): L = Label(r,text='%s'%J) L.grid(row=Row,column=Col) LabelList.append(L) r.update_idletasks() r = Tk() r.after(1000,Go) r.geometry('800x600') r.mainloop() This runs quickly at first but gradually slows down to a crawl during the latter iterations. Anyone have any idea what is causing this to go slow or how I could speed it up? I'm running Python 2.4.3 on an Ubuntu 6.06 system. Thanks Cam Farnell From fredrik at pythonware.com Mon Jan 7 23:10:13 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 07 Jan 2008 23:10:13 +0100 Subject: [Tkinter-discuss] Tkinter slows down In-Reply-To: <47829444.7020900@bitflipper.ca> References: <459EDA4F.4030209@codebykevin.com> <20070106203356.04da9827.klappnase@web.de> <47829444.7020900@bitflipper.ca> Message-ID: Cam Farnell wrote: > This runs quickly at first but gradually slows down to a crawl during > the latter iterations. Anyone have any idea what is causing this to go > slow or how I could speed it up? I'm running Python 2.4.3 on an Ubuntu > 6.06 system. grid_forget removes the widget from the screen, but it doesn't destroy it, nor does it remove them from the list of child widgets for the parent widget. either redesign your code to reuse widgets when possible, or make sure to call the "destroy" method on them. From timj at tolisgroup.com Tue Jan 8 00:11:52 2008 From: timj at tolisgroup.com (Tim Jones) Date: Mon, 7 Jan 2008 16:11:52 -0700 Subject: [Tkinter-discuss] Tkinter slows down In-Reply-To: <47829444.7020900@bitflipper.ca> References: <459EDA4F.4030209@codebykevin.com> <20070106203356.04da9827.klappnase@web.de> <47829444.7020900@bitflipper.ca> Message-ID: <23194BFA-1F51-4009-A7DA-9A082661CB82@tolisgroup.com> On Jan 7, 2008, at 2:06 PM, Cam Farnell wrote: > I'm creating a program which displays spreadsheet-like data using > hundreds of labels. At first this works fine, however after a few > redisplays it starts slowing down dramatically. > > A small test program, without the distractions of the real program is: > > from Tkinter import * > def Go(): > LabelList = [] > for J in range(30): > print J Cam - this next line is probably the culprit. Calling forget doesn't delete the instance of the control, so when you create the new Labels below, you're building a huge stack of controls. I'd recommend simply updating the label text so that you reuse the existing controls. > for L in LabelList: L.grid_forget() > LabelList = [] > for Row in range(20): > for Col in range(20): > L = Label(r,text='%s'%J > L.grid(row=Row,column=Col) > LabelList.append(L) > r.update_idletasks() > r = Tk() > r.after(1000,Go) > r.geometry('800x600') > r.mainloop() > > This runs quickly at first but gradually slows down to a crawl during > the latter iterations. Anyone have any idea what is causing this to go > slow or how I could speed it up? I'm running Python 2.4.3 on an Ubuntu > 6.06 system. HTH, Tim From timj at tolisgroup.com Tue Jan 8 00:32:10 2008 From: timj at tolisgroup.com (Tim Jones) Date: Mon, 7 Jan 2008 16:32:10 -0700 Subject: [Tkinter-discuss] Tkinter slows down In-Reply-To: <23194BFA-1F51-4009-A7DA-9A082661CB82@tolisgroup.com> References: <459EDA4F.4030209@codebykevin.com> <20070106203356.04da9827.klappnase@web.de> <47829444.7020900@bitflipper.ca> <23194BFA-1F51-4009-A7DA-9A082661CB82@tolisgroup.com> Message-ID: On Jan 7, 2008, at 2:06 PM, Cam Farnell wrote: > I'm creating a program which displays spreadsheet-like data using > hundreds of labels. At first this works fine, however after a few > redisplays it starts slowing down dramatically. Also, have you considered using tkTable (part of the Tile project - see http://tktable.sourceforge.net/)? Tim From brindly at gmail.com Tue Jan 8 08:45:34 2008 From: brindly at gmail.com (brindly sujith) Date: Tue, 8 Jan 2008 13:15:34 +0530 Subject: [Tkinter-discuss] how to open a file using tkinter Message-ID: hi i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other application please send me the tkinter coding for this -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080108/44627f5c/attachment.htm From brindly at gmail.com Tue Jan 8 09:46:27 2008 From: brindly at gmail.com (brindly sujith) Date: Tue, 8 Jan 2008 14:16:27 +0530 Subject: [Tkinter-discuss] how to close a window automatically Message-ID: hi i am using TKINTER to create a GUI appliction i want to know whether in tkinter we have a option to close a window automatically after a particular time. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080108/2d7d89c8/attachment.htm From fredrik at pythonware.com Tue Jan 8 12:07:46 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 08 Jan 2008 12:07:46 +0100 Subject: [Tkinter-discuss] how to open a file using tkinter In-Reply-To: References: Message-ID: brindly sujith wrote: > i am using TKINTER to create GUI application > > i want to know how to open a word document in open office or any other > application that's more of a Python question than a Tkinter question. on windows, you can use the "os.startfile" function: import os os.startfile("mydocument.doc") (this is the same as double-clicking on a document in the file explorer) on other platforms, use os.system() and specify what application to run: import os os.system("someapp mydocument.doc") From fredrik at pythonware.com Tue Jan 8 12:05:23 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 08 Jan 2008 12:05:23 +0100 Subject: [Tkinter-discuss] how to close a window automatically In-Reply-To: References: Message-ID: brindly sujith wrote: > i am using TKINTER to create a GUI appliction > > i want to know whether in tkinter we have a option to close a window > automatically after a particular time. use the "after" method. From brindly at gmail.com Wed Jan 9 11:27:42 2008 From: brindly at gmail.com (brindly sujith) Date: Wed, 9 Jan 2008 15:57:42 +0530 Subject: [Tkinter-discuss] how to open a file using os.system in TKINTER Message-ID: hi i am developing a GUI application using TKINTER i want to open a file from the askopenfile(which is a tkFileDialog) using OS.SYSTEM. i have already created the file open dilog using tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file') Now i want to open a file from this dialog using OS.SYSTEM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080109/c286584d/attachment.htm From fredrik at pythonware.com Wed Jan 9 11:34:22 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 09 Jan 2008 11:34:22 +0100 Subject: [Tkinter-discuss] how to open a file using os.system in TKINTER In-Reply-To: References: Message-ID: brindly sujith wrote: > i am developing a GUI application using TKINTER > > i want to open a file from the askopenfile(which is a tkFileDialog) > using OS.SYSTEM. > > i have already created the file open dilog using > tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file') > Now i want to open a file from this dialog using OS.SYSTEM there doesn't seem to be a question in there. what did you try, and what happened when you tried it? From brindly at gmail.com Wed Jan 9 18:21:55 2008 From: brindly at gmail.com (brindly sujith) Date: Wed, 9 Jan 2008 22:51:55 +0530 Subject: [Tkinter-discuss] how to mount and unmount Message-ID: hi i am developing a GUI application using TKINTER i want to know how to mount and unmount removable drives intkinter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080109/5eee6c78/attachment.htm From fredrik at pythonware.com Wed Jan 9 18:28:40 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 09 Jan 2008 18:28:40 +0100 Subject: [Tkinter-discuss] how to mount and unmount In-Reply-To: References: Message-ID: brindly sujith wrote: > i am developing a GUI application using TKINTER > > i want to know how to mount and unmount removable drives intkinter you're getting further and further off topic for every post; this list is about the Tkinter library itself, not general Python programming or Linux usage. (but the answer is of course the same as last time: figure out how to do what you want in Python, and use that mechanism. if Python cannot do what you want directly, figure out how to do it from the command line on the platform you're using, and then use Python's os.system() function to execute the corresponding command.) From ealhanatis at gmail.com Thu Jan 10 13:14:02 2008 From: ealhanatis at gmail.com (Elias Alhanatis) Date: Thu, 10 Jan 2008 14:14:02 +0200 Subject: [Tkinter-discuss] A hint for a "table" Message-ID: <83bb12d30801100414v7b4ab300y79b1bb4d026cc92f@mail.gmail.com> Hello!! I am working on a project with "sheet forms" and i would like a hint of how to imply them in Tkinter. I have tried it by creating a frame with multiple lines ( where each line divides to the fields i want ) , but in the end i must look after soooo many variables and its very difficult. Is there a way to create a table with simple X,Y coords for each of its cells? Thank you in advance... Elias Alhanatis Greece -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080110/d5e13255/attachment.htm From fredrik at pythonware.com Thu Jan 10 19:21:03 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 10 Jan 2008 19:21:03 +0100 Subject: [Tkinter-discuss] A hint for a "table" In-Reply-To: <83bb12d30801100414v7b4ab300y79b1bb4d026cc92f@mail.gmail.com> References: <83bb12d30801100414v7b4ab300y79b1bb4d026cc92f@mail.gmail.com> Message-ID: Elias Alhanatis wrote: > I am working on a project with "sheet forms" and i would like > a hint of how to imply them in Tkinter. I have tried it by creating > a frame with multiple lines ( where each line divides to the fields > i want ) , but in the end i must look after soooo many variables and > its very difficult. Is there a way to create a table with simple X,Y > coords for each of its cells? why not just a dictionary to map X,Y to cell widgets? or use a ready-made table widget: http://tkinter.unpythonic.net/wiki/TkTable http://tkinter.unpythonic.net/wiki/TableListWrapper From ron.longo at cox.net Wed Jan 9 13:00:12 2008 From: ron.longo at cox.net (Ron Provost) Date: Wed, 9 Jan 2008 07:00:12 -0500 Subject: [Tkinter-discuss] how to open a file using os.system in TKINTER References: Message-ID: <004801c852b7$30ed9af0$6501a8c0@aristotle> I belive that askopenfile() shows an open file dialog box and once the user has selected a file, it opens the file for you and returns the Python file object. All you have to do is read from that file. If what you want is a dialog box that returns a filename then you should use askopenfilename(). You can then use file() or open() to actually open the file. ----- Original Message ----- From: "Fredrik Lundh" To: Sent: Wednesday, January 09, 2008 5:34 AM Subject: Re: [Tkinter-discuss] how to open a file using os.system in TKINTER > brindly sujith wrote: > >> i am developing a GUI application using TKINTER >> >> i want to open a file from the askopenfile(which is a tkFileDialog) >> using OS.SYSTEM. >> >> i have already created the file open dilog using >> tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file') >> Now i want to open a file from this dialog using OS.SYSTEM > > there doesn't seem to be a question in there. what did you try, and > what happened when you tried it? > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From brindly at gmail.com Fri Jan 11 09:42:28 2008 From: brindly at gmail.com (brindly sujith) Date: Fri, 11 Jan 2008 14:12:28 +0530 Subject: [Tkinter-discuss] how to remove window borders Message-ID: hi i am developing a GUI application using TKINTER in my applicaton i dont want the window title bar(including MAX,MIN and CLOSE) how to do this plz send me the code for this -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080111/560ca7ea/attachment.htm From bob at passcal.nmt.edu Fri Jan 11 18:04:10 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 11 Jan 2008 10:04:10 -0700 Subject: [Tkinter-discuss] Slightly OT: signals Message-ID: I have a Tkinter program running on one of those ASUS EeePC's (Xandros Linux). When you close the lid the computer goes into standby. Does anyone know what/if any signal would be sent to my program? I've tried the obvious ones (SIGHUP, SIGTSTP, etc.) but haven't seen them. I need to close some virtual comm ports (for a USB to serial dongle) before the thing shuts down or it isn't pretty when the lid is reopened; the /dev/ttyUSBx devices just aren't there for the program to access. If the ports aren't in use when the lid is closed everything seems to come back up OK. Thanks! Bob From klappnase at web.de Fri Jan 11 22:24:32 2008 From: klappnase at web.de (Michael Lange) Date: Fri, 11 Jan 2008 22:24:32 +0100 Subject: [Tkinter-discuss] how to remove window borders In-Reply-To: References: Message-ID: <20080111222432.1673d678.klappnase@web.de> On Fri, 11 Jan 2008 14:12:28 +0530 "brindly sujith" wrote: > hi > > i am developing a GUI application using TKINTER > > in my applicaton i dont want the window title bar(including MAX,MIN and > CLOSE) > > how to do this > > plz send me the code for this > Hi Brindly, you will need to call the window's overrideredirect() method like this: window.overrideredirect(1) Michael From brindly at gmail.com Sat Jan 12 11:55:38 2008 From: brindly at gmail.com (brindly sujith) Date: Sat, 12 Jan 2008 16:25:38 +0530 Subject: [Tkinter-discuss] how to disable MIN, MAX and CLOSE options using tkinter Message-ID: hi in my application i dont want MIN,MAX,CLOSE options in window i need to disable these options how to do this in tkinter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080112/ae94b1f8/attachment.htm From brindly at gmail.com Mon Jan 14 16:57:02 2008 From: brindly at gmail.com (brindly sujith) Date: Mon, 14 Jan 2008 21:27:02 +0530 Subject: [Tkinter-discuss] how to change the values of keyboard keys in TKINTER Message-ID: hi i want to know how to change the values of keyboard keys(for example: I want to set alt+f4 to enter) do we have any modules in tkinter for doing this... plz tell me how we can do this -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080114/334cc6cc/attachment.htm From kw at codebykevin.com Mon Jan 14 17:04:43 2008 From: kw at codebykevin.com (Kevin Walzer) Date: Mon, 14 Jan 2008 11:04:43 -0500 Subject: [Tkinter-discuss] how to change the values of keyboard keys in TKINTER In-Reply-To: References: Message-ID: <478B881B.8090005@codebykevin.com> brindly sujith wrote: > hi > > i want to know how to change the values of keyboard keys(for example: > I want to set alt+f4 to enter) > > do we have any modules in tkinter for doing this... > > plz tell me how we can do this > Look at Tkinter/Tk's binding mechanism. It's very extensive and flexible. Have you taken a look at any of the online tutorials for Tkinter? http://www.pythonware.com/library/tkinter/introduction/index.htm http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html http://www.ferg.org/thinking_in_tkinter/index.html These are all good guides and might help with some of your questions. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From brindly at gmail.com Sat Jan 19 14:06:05 2008 From: brindly at gmail.com (brindly sujith) Date: Sat, 19 Jan 2008 18:36:05 +0530 Subject: [Tkinter-discuss] how to bind a event to a application in tkinter Message-ID: hi how to bind a event to a application consider i m opening openoffice using os.system("openoffice")... i want to bind a event on openoffice... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080119/9910216b/attachment.htm From fredrik at pythonware.com Sat Jan 19 16:10:59 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 19 Jan 2008 16:10:59 +0100 Subject: [Tkinter-discuss] how to bind a event to a application in tkinter In-Reply-To: References: Message-ID: brindly sujith wrote: > how to bind a event to a application > > consider i m opening openoffice using > > os.system("openoffice")... > > i want to bind a event on openoffice... maybe you should ask in an openoffice forum? From bob at passcal.nmt.edu Tue Jan 22 22:45:50 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Tue, 22 Jan 2008 14:45:50 -0700 Subject: [Tkinter-discuss] Threads and GUI Message-ID: Is there anything that is OK for a thread to do to the GUI? Like would just calling .update() on a Button() be OK? It seems to work, but is it OK? I'm calling it on a "Stop" button, specifically, in the thread every quarter second, instead of peppering the code with updates() to give the button a chance to set it's IntVar value and then stop everything when the code gets around to checking that. Thanks! Bob From mkieverpy at tlink.de Wed Jan 23 11:50:51 2008 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Wed, 23 Jan 2008 10:50:51 -0000 Subject: [Tkinter-discuss] Threads and GUI Message-ID: <20080123094522.CFBACBBD4@mail.terralink.de> Hello Bob, You wrote: >Is there anything that is OK for a thread to do to the GUI? Like >would just calling .update() on a Button() be OK? It seems to work, >but is it OK? >I'm calling it on a "Stop" button, specifically, in the thread every >quarter second, instead of peppering the code with updates() to give >the button a chance to set it's IntVar value and then stop everything >when the code gets around to checking that. From what I remember everybody says: Don't do that! Some refs I found googling for 'tkinter and threads': A clear warning http://mail.python.org/pipermail/tkinter-discuss/2005-February/000313.html (the cited reference is dead, though) In the following answer is a small example using threading. Another example using thread and Queue (from effbot): http://effbot.org/zone/tkinter-threads.htm I have used a solution from Mark Lutz (Programming Python/O'Reilly) but just for popup dialogs that block the GUI while a thread is running (communicating via a simple variable). This might be applicable to your scenario, too. In a socket testing application I have used 'after' in the GUI thread to look at a common buffer if new data have arrived. BTW have you found some info regarding your signals problem? Hope this helps, Matthias Kievernagel (mkiever/at/web/dot/de) From chazzhall at gmail.com Thu Jan 24 20:42:59 2008 From: chazzhall at gmail.com (Charlie Hall) Date: Thu, 24 Jan 2008 14:42:59 -0500 Subject: [Tkinter-discuss] Question on moving a scale value via the program Message-ID: <4798EA43.4050901@gmail.com> Hi, I'm fairly new at Python and even newer at Tkinter. For learning purposes, I'm attempting a program for a small, simple timer. I decided to use the Scale widget to indicate the status (or lapsed time). However, I can't seem to get the Scale widget to respond to a change in scale value. It seems that Scale is intended to respond to key clicks only. Is this correct. If someone knows how I can change the scale value from my program, I'd certainly appreciate some hints. Thank you very much, Charlie Hall From hexamorph at gmx.net Thu Jan 24 20:56:39 2008 From: hexamorph at gmx.net (Hexamorph) Date: Thu, 24 Jan 2008 20:56:39 +0100 Subject: [Tkinter-discuss] Question on moving a scale value via the program In-Reply-To: <4798EA43.4050901@gmail.com> References: <4798EA43.4050901@gmail.com> Message-ID: <4798ED77.3030503@gmx.net> Charlie Hall wrote: > Hi, > > I'm fairly new at Python and even newer at Tkinter. For learning > purposes, I'm attempting a program for a small, simple timer. I decided > to use the Scale widget to indicate the status (or lapsed time). > However, I can't seem to get the Scale widget to respond to a change in > scale value. It seems that Scale is intended to respond to key clicks > only. Is this correct. > > If someone knows how I can change the scale value from my program, I'd > certainly appreciate some hints. > > Thank you very much, > > Charlie Hall Hi! What's wrong with the Scale.set(value) method? From chazzhall at gmail.com Sun Jan 27 02:59:05 2008 From: chazzhall at gmail.com (Charlie Hall) Date: Sat, 26 Jan 2008 20:59:05 -0500 Subject: [Tkinter-discuss] Question on moving a scale value via the program In-Reply-To: <4798ED77.3030503@gmx.net> References: <4798EA43.4050901@gmail.com> <4798ED77.3030503@gmx.net> Message-ID: <479BE569.80202@gmail.com> Hexamorph wrote: > Charlie Hall wrote: > >> Hi, >> >> I'm fairly new at Python and even newer at Tkinter. For learning >> purposes, I'm attempting a program for a small, simple timer. I decided >> to use the Scale widget to indicate the status (or lapsed time). >> However, I can't seem to get the Scale widget to respond to a change in >> scale value. It seems that Scale is intended to respond to key clicks >> only. Is this correct. >> >> If someone knows how I can change the scale value from my program, I'd >> certainly appreciate some hints. >> >> Thank you very much, >> >> Charlie Hall >> > > Hi! > > What's wrong with the Scale.set(value) method? > > Hexamorph, Thanks for the quick reply. A quick answer to your question is: nothing is wrong with the Scale.set(value) method. My problem was two fold. First, I had assumed from either an error message, or something I read in one of the tutorials, that the "set" function was not available in the Scale widget, although the "get" is. Second, as a student of Python/Tkinter, I had a problem with scoping some of my variables. I believe all is worked out now, and I can now move my scale from my program thanks to your encouraging response to my question. All I needed was someone to get me on track again, and I appreciate it. Charlie From bob at passcal.nmt.edu Tue Jan 29 19:47:55 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Tue, 29 Jan 2008 11:47:55 -0700 Subject: [Tkinter-discuss] Threads and GUI In-Reply-To: <20080123094522.CFBACBBD4@mail.terralink.de> References: <20080123094522.CFBACBBD4@mail.terralink.de> Message-ID: <482532C7-2955-4604-91DC-7AF34E266C7E@passcal.nmt.edu> Hi! Well...you CAN do things to a GUI from a thread in Tkinter, but not on Windows (and, of course, not on Linux, Solaris or OSX just because you're not supposed to in the first place). I had, in essence: Stop = False def TickleButton(But): while Stop == False: sleep(.25) But.update() return StopBut = None def drawForm(): global StopBut Entry fields, Labels, Buttons, Texts, etc... StopBut = Button(text = "Stop", command = change Stop to True) return # Do stuff and output info to a Text field or draw on a Canvas. def doSomethingLongAndTedious(): start_new_thread(TickleButton, (StopBut)) Do lots of stuff while checking the value of Stop when appropriate. When finished Stop = True return At some point call drawForm() and bring up the form (usually a menu command in my case). At some point call doSomethingLongAndTedious() (usually from a GO button on the form in my case). Everything works fine, except on Windows. If the Button is on a form (form=a Frame with buttons, fields, Labels, etc.) that has a Text widget or a Canvas widget with Scrollbars (vertical in my case) attached to them everything is fine UNTIL the Text or Canvas gets full enough with output from the operation in the long and tedious function) to activate the Scrollbars. Then at that instant everything grinds to a severe halt (you have to practically use the Task Manager to kill the program). It's odd that it's OK on *NIXs, but not on Windows. I wouldn't know if it is a Tkinter problem, or a Python problem, or just a Scrollbar problem, or what (I'm not that smart). Is it ever going to be possible to do things like this? What with multiple core CPUs and many threads and stuff now upon us Tkinter is beginning to show signs of death, which is too bad since it runs like crazy everywhere with minimal fuss. So I'm back to just calling But.update() every once-in-a-while in the programs. It works OK, but not as well as I'd like. It's tricky figuring out in each long and scary function when to do the update (don't want to do it too often or it slows things down, but don't want to do it too slowly or the user thinks nothing is happening when they click the Stop button -- my Stop buttons go from red/NORMAL when running to yellow when the user clicks on them then to default color/ DISABLED when the long and tedious function actually gets to a safe stopping point). Bob On the EeePC signals thing, it doesn't look like the programs get any signals when the lid is closed and the Linux goes into standby (which makes some sense -- the programs aren't really supposed to know that anything happened when you go into standby), but there are little one- liner text files that get changed from things like "Lid: open" to "Lid: closed" that I can poll (again, polling! :) to see when the lid has been closed and shutdown the serial ports in time...maybe. I haven't gotten back to that program to implement it yet. On Jan 23, 2008, at 03:50, mkieverpy at tlink.de wrote: > > Hello Bob, > > You wrote: >> Is there anything that is OK for a thread to do to the GUI? Like >> would just calling .update() on a Button() be OK? It seems to work, >> but is it OK? > >> I'm calling it on a "Stop" button, specifically, in the thread every >> quarter second, instead of peppering the code with updates() to give >> the button a chance to set it's IntVar value and then stop everything >> when the code gets around to checking that. > >> From what I remember everybody says: Don't do that! > Some refs I found googling for 'tkinter and threads': > > A clear warning > http://mail.python.org/pipermail/tkinter-discuss/2005-February/ > 000313.html > (the cited reference is dead, though) > In the following answer is a small example using threading. > > Another example using thread and Queue (from effbot): > http://effbot.org/zone/tkinter-threads.htm > > I have used a solution from Mark Lutz (Programming Python/O'Reilly) > but just for popup dialogs that block the GUI while a thread > is running (communicating via a simple variable). > This might be applicable to your scenario, too. > > In a socket testing application I have used 'after' in the GUI thread > to look at a common buffer if new data have arrived. > > > BTW have you found some info regarding your signals problem? > > Hope this helps, > Matthias Kievernagel > (mkiever/at/web/dot/de) > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From brindly at gmail.com Wed Jan 30 08:25:49 2008 From: brindly at gmail.com (brindly sujith) Date: Wed, 30 Jan 2008 12:55:49 +0530 Subject: [Tkinter-discuss] how to make python program as executable Message-ID: hi i am developing a GUI application in python(tkinter) i want to know how to make the python program as a application ie i want to make it executable please guide me -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080130/720afed7/attachment.htm From brindly at gmail.com Wed Jan 30 10:34:23 2008 From: brindly at gmail.com (brindly sujith) Date: Wed, 30 Jan 2008 15:04:23 +0530 Subject: [Tkinter-discuss] how to enable overrideredirect Message-ID: from Tkinter import * import tkMessageBox import tkFileDialog,os def quit(): if tkMessageBox.askokcancel("Quit","DO u really want to quit"): root.destroy() def fiopen(): file1 = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a file') os.system("openoffice %s"%file1.name) root=Tk() label=Label(root,text="Welcome to PC-FREE PROJECTOR") label.pack() button=Button(root,text="select",command=fiopen) button.pack() button1=Button(root,text="Exit",command=quit) button1.pack() root.overrideredirect(True) root.geometry('%dx%d+%d+%d' % (root.winfo_screenwidth(), root.winfo_screenheight(), 0, 0)) root.lift() root.mainloop() the above program is my application please execute this program... while executing this program initially a window will open....after that the buttons 'select' and 'exit' is not working... i checked out by disabling root.overrideredirect(True) line in the program...then its working what is the problem here...i want this program to work perfectly plz do reply me thanx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080130/ee3ee627/attachment.htm From amit.finkler at gmail.com Wed Jan 30 10:54:40 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Wed, 30 Jan 2008 11:54:40 +0200 Subject: [Tkinter-discuss] Running GUI from console and quitting it Message-ID: <47A04960.6040800@gmail.com> Hi all, I wrote a short code in Python in which I check some boolean flag. If it's true, everything is OK. If it's false, I wanted it to pop-up a warning message on the user's screen. To implement this with Tkinter I naively tried to use tkMessageBox: tkMessageBox.showwarning( "Output check", "Output is not on") However, once the user presses the OK button, the root Tk() window remains. Note that in no place in the code did I create a Tk() instance. The only Tkinter instance is the MessageBox. Is it possible to run some console-based script which pops-up a GUI window and then by pressing OK just kill/destroy it? Thanks, Amit. From brindly at gmail.com Thu Jan 31 08:24:09 2008 From: brindly at gmail.com (brindly sujith) Date: Thu, 31 Jan 2008 12:54:09 +0530 Subject: [Tkinter-discuss] how to use freeze for making executable python file in linux Message-ID: can i use freeze to make my python program in to executable in linux if yes...plz tell me how to use freeze whether i need to install something or its default in python -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080131/c7a18f1d/attachment.htm From davidlinke at tiscali.de Thu Jan 31 09:48:19 2008 From: davidlinke at tiscali.de (David Linke) Date: Thu, 31 Jan 2008 08:48:19 +0000 (UTC) Subject: [Tkinter-discuss] Running GUI from console and quitting it References: <47A04960.6040800@gmail.com> Message-ID: Amit Finkler wrote: > Hi all, (...) > However, once the user presses the OK button, the root Tk() window > remains. Note that in no place in the code did I create a Tk() instance. > The only Tkinter instance is the MessageBox. > > Is it possible to run some console-based script which pops-up a GUI > window and then by pressing OK just kill/destroy it? Just create the root window yourself to have control over it and withdraw it: from Tkinter import * import tkMessageBox r = Tk() r.withdraw() tkMessageBox.showwarning( "Output check", "Output is not on") a= raw_input('hit key to continue') Regards, David From amit.finkler at gmail.com Thu Jan 31 11:46:23 2008 From: amit.finkler at gmail.com (Amit Finkler) Date: Thu, 31 Jan 2008 12:46:23 +0200 Subject: [Tkinter-discuss] Running GUI from console and quitting it Message-ID: <47A1A6FF.2060504@gmail.com> ust create the root window yourself to have control over it and withdraw it: from Tkinter import * import tkMessageBox r = Tk() r.withdraw() tkMessageBox.showwarning( "Output check", "Output is not on") a= raw_input('hit key to continue') Regards, David Excellent. This is exactly what I wanted. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080131/0744772e/attachment.htm