From rajeev1204 at gmail.com Sat Nov 3 12:09:22 2007 From: rajeev1204 at gmail.com (Rajeev Nair) Date: Sat, 3 Nov 2007 16:39:22 +0530 Subject: [Tkinter-discuss] Re-sudo password Message-ID: hi I have a function defined using os.system("mount ....."). as a callback to a button. On clicking this button the system asks for password in terminal. How do i enter this password in a tk window so that the system reads it ?.Iam using the entry widget to do this. regards rajeev From kw at codebykevin.com Sat Nov 3 14:31:23 2007 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 03 Nov 2007 09:31:23 -0400 Subject: [Tkinter-discuss] Re-sudo password In-Reply-To: References: Message-ID: <472C782B.1000809@codebykevin.com> Rajeev Nair wrote: > hi > > I have a function defined using os.system("mount ....."). as a > callback to a button. > > On clicking this button the system asks for password in terminal. How > do i enter this password in a tk window so that the system reads it > ?.Iam using the entry widget to do this. > > Here's code I use for this: #get user password to run commands as root def authorizeCommand(self, cmd): self.passtext = StringVar() self.password = Toplevel(self) self.password.title('Password Required') self.passtop = Tkinter.Frame(self.password, padding=5) self.passtop.pack(side=TOP, fill=BOTH, expand=YES) self.passlabel = Tkinter.Label(self.passtop, text='You must enter your password.') self.passlabel.pack(side=TOP, fill=BOTH, expand=YES) self.passlabel.image=self.lock self.passentry = Tkinter.Entry(self.passtop, show='*', textvariable=self.passtext) self.passentry.pack(side=BOTTOM, fill=BOTH, expand=YES) self.passentry.bind('', (lambda event: self.runCommand(cmd))) self.passbottom = Tkinter.Frame(self.password, padding=5) self.passbottom.pack(side=BOTTOM, fill=BOTH, expand=YES) self.bottomupper = Tkinter.Frame(self.passbottom) self.bottomupper.pack(side=TOP, fill=BOTH, expand=YES) self.bottomlower = Tkinter.Frame(self.passbottom, padding = 5) self.bottomlower.pack(side=BOTTOM, fill=BOTH, expand=NO) self.passinstall = Tkinter.Button(self.bottomlower, text='OK', default=ACTIVE, command=lambda: self.runCommand(cmd)) self.passinstall.grid(row = 1, column = 1, sticky = NSEW) self.passcancel = Tkinter.Button(self.bottomlower, text='Cancel', command=self.password.destroy) self.passcancel.grid(row=1, column = 0, sticky = NSEW) #run command with root privileges def runCommand(self, cmd): self.passtext=self.passtext.get() self.password.destroy() cmd() -- Kevin Walzer Code by Kevin http://www.codebykevin.com From n.chu at utoronto.ca Sat Nov 17 19:19:02 2007 From: n.chu at utoronto.ca (aonomus) Date: Sat, 17 Nov 2007 10:19:02 -0800 (PST) Subject: [Tkinter-discuss] Tkinter.bind(), watching for mouse click and release inside a canvas Message-ID: <13811890.post@talk.nabble.com> My goal is to write a clip of code so that a user can click inside a canvas, drag and release to make a crop box of his size, then crop. So after looking around at pages like http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm, I figure I can: canvas.bind('', func1) canvas.bind('', func2) canvas.bind('', func3) Currently I can print the variables, but is there any way to actually return the x,y coordinates of the mouse and store them in a variable? This is part of a larger photo editor project, but in general I want to be able to watch for mouse clicks and return position values... any idea as to how? -- View this message in context: http://www.nabble.com/Tkinter.bind%28%29%2C-watching-for-mouse-click-and-release-inside-a-canvas-tf4827513.html#a13811890 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Sun Nov 18 17:34:38 2007 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 18 Nov 2007 17:34:38 +0100 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 45, Issue 2 In-Reply-To: References: Message-ID: <47e491110711180834m62b6de6epbacd96e871795e78@mail.gmail.com> > canvas.bind('', func1) > canvas.bind('', func2) > canvas.bind('', func3) > > Currently I can print the variables, but is there any way to actually return > the x,y coordinates of the mouse and store them in a variable? This is part > of a larger photo editor project, but in general I want to be able to watch > for mouse clicks and return position values... any idea as to how? func1, func2 and func3 are called with one argument, which is an event object. You can then access event.x and event.y e.g., def func1(event): print event.x, event.y Mick From longorh at npt.nuwc.navy.mil Mon Nov 19 14:35:24 2007 From: longorh at npt.nuwc.navy.mil (ron.longo) Date: Mon, 19 Nov 2007 05:35:24 -0800 (PST) Subject: [Tkinter-discuss] .mainloop(), what's the parameter for? Message-ID: <13836178.post@talk.nabble.com> Tkinter.py defines mainloop with a single parameter n=0. Does anyone know what this parameter is for? I've tried some experimenting and found that if I pass anything other than 0, mainloop seems to execute at least one complete interation without reporting an error, then it returns. Could this be what the parameter is for? To allow a user to write his own mainloop? Thanks, Ron -- View this message in context: http://www.nabble.com/.mainloop%28%29%2C-what%27s-the-parameter-for--tf4836365.html#a13836178 Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From mkieverpy at tlink.de Tue Nov 20 10:21:31 2007 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Tue, 20 Nov 2007 09:21:31 -0000 Subject: [Tkinter-discuss] .mainloop(), what's the parameter for? Message-ID: <20071120081954.71D3EB9AA@mail.terralink.de> Hi Ron, I didn't know that parameter either, so I thought I'd take a look. I found the following loop in 'Tkapp_MainLoop' in '_tkinter.c': while (Tk_GetNumMainWindows() > threshold && !quitMainLoop && !errorInCmd) { ... The parameter 'n' is the 'threshold' in the above 'if'. If I understand the man-page of 'Tk_GetNumMainWindows' right the code above drops out of the 'mainloop' when the number of toplevel windows drops to 'threshold' or below. Has anyone used this for values other than '0'? I have never seen code using this. What is the idea? Close the application when one of the main windows gets closed? Regards, Matthias Kievernagel (mkiever/at/web/dot/de) From m.uebelacker at googlemail.com Mon Nov 26 13:54:39 2007 From: m.uebelacker at googlemail.com (Mathias Uebelacker) Date: Mon, 26 Nov 2007 13:54:39 +0100 Subject: [Tkinter-discuss] Problems to show menubar Message-ID: Hello, i just starts with Tkinter and started with a small GUI where i want to show a menubar. but it does not work. Here is the code: --------------------------------------------------------------------------------------------------- from Tkinter import * class DistManager(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid() self.createMenuBar() #self.createLogin() def createLogin(self): Label(self, text="Bitte geben Sie Ihre Zugangsdaten ein", pady=10).grid(row=0, column=0, columnspan=2) Label(self, text="Name: ", pady=10).grid(row=1, column=0) Label(self, text="Passwort: ", pady=10).grid(row=2, column=0) NameEntry=Entry(self) PasswortEntry=Entry(self, show="*") NameEntry.grid(row=1, column=1) PasswortEntry.grid(row=2, column=1) AbbruchButton=Button(self, text="abbrechen") AnmeldenButton=Button(self, text="anmelden") AbbruchButton.grid(row=3, column=0) AnmeldenButton.grid(row=3, column=1, sticky="e") def createMenuBar(self): menubar=Menu(self) kundenmenu=Menu(menubar, tearoff=0) kundenmenu.add_command(label="Kunden anzeigen") kundenmenu.add_command(label="Kunden anlegen") kundenmenu.add_command(label="Kunden bearbeiten") menubar.add_cascade(label="Kunden", menu=kundenmenu) self.config(menu=menubar) app=DistManager() app.master.title("CCB- DistributionsManager") app.master.geometry("800x600") app.mainloop() ------------------------------------------------------------------------------------------------- The menu option in self.config should be the problem. Does anybody know how to show the menubar works (in my case) br Mathias -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20071126/2bf03833/attachment.htm From mkieverpy at tlink.de Mon Nov 26 16:28:55 2007 From: mkieverpy at tlink.de (mkieverpy at tlink.de) Date: Mon, 26 Nov 2007 15:28:55 -0000 Subject: [Tkinter-discuss] Problems to show menubar Message-ID: <20071126142925.CC0EEC1B1@mail.terralink.de> Hi Mathias, you need to attach your menubar to a Toplevel window. A simple Frame cannot have a menubar. It works, if you change your code like this: ------------------------------------------------ from Tkinter import * class DistManager(Frame): ... def createMenuBar(self): menubar=Menu(self) kundenmenu=Menu(menubar, tearoff=0) kundenmenu.add_command(label="Kunden anzeigen") kundenmenu.add_command(label="Kunden anlegen") kundenmenu.add_command(label="Kunden bearbeiten") menubar.add_cascade(label="Kunden", menu=kundenmenu) self.master.config(menu=menubar) tk = Tk() app=DistManager(tk) app.master.title("CCB- DistributionsManager") app.master.geometry("800x600") tk.mainloop() ---------------------------------------------------- The menu is attached to the master. The master must be a widget that can have a menu, like Tk itself or a Toplevel window. Another method would be to derive DistManager from Toplevel (haven't tried though). Sch?ne Gr??e, Matthias Kievernagel (mkiever/at/web/dot/de) From jigisbert.etra-id at grupoetra.com Thu Nov 29 08:15:18 2007 From: jigisbert.etra-id at grupoetra.com (Jose Ignacio Gisbert) Date: Thu, 29 Nov 2007 08:15:18 +0100 Subject: [Tkinter-discuss] General Doubt about tkinter windows... Message-ID: <002101c83257$99c00160$2000a8c0@depid.local> Hi all, I am trying to develop a simple application in python (I am very newby), but I have some general doubts my main window is Tk(), I am using grid manager, and when in the application user changes the view, what I do is take a frame out of the grid and put another one (and sometimes there are position changes of other remaining frames :-S). My doubt is how can I change the window?? Because if I use Toplevel window, main window remains under it, and user can also continue changing it, what I don?t want, I just want one active window in every moment. Could you give me some hints of how doing it? Thanks in advance Best regards, _______________________________ Jos? Ignacio Gisbert Sanus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20071129/72509585/attachment.htm