Rajeev Nair | 3 Nov 2007 12:09
Picon

Re-sudo password

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
Kevin Walzer | 3 Nov 2007 14:31
Favicon

Re: Re-sudo password

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='*', 
(Continue reading)

aonomus | 17 Nov 2007 19:19
Picon
Picon
Favicon

Tkinter.bind(), watching for mouse click and release inside a canvas


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('<Button-1>', func1)
canvas.bind('<B1-Motion>', func2)
canvas.bind('<ButtonRelease-1>', 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.
Michael O'Donnell | 18 Nov 2007 17:34
Picon
Picon
Favicon

Re: Tkinter-discuss Digest, Vol 45, Issue 2

> canvas.bind('<Button-1>', func1)
> canvas.bind('<B1-Motion>', func2)
> canvas.bind('<ButtonRelease-1>', 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
ron.longo | 19 Nov 2007 14:35
Picon
Picon

.mainloop(), what's the parameter for?


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.
mkieverpy | 20 Nov 2007 10:21
Picon

Re: .mainloop(), what's the parameter for?


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)
Mathias Uebelacker | 26 Nov 2007 13:54
Gravatar

Problems to show menubar

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

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
mkieverpy | 26 Nov 2007 16:28
Picon

Re: Problems to show menubar

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)
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Jose Ignacio Gisbert | 29 Nov 2007 08:15

General Doubt about tkinter windows...

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

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane