Gumboil
Posts: 44
Joined: Thu Dec 25, 2014 10:20 pm

Cant run tkinter program using GPIO

Sat Jan 17, 2015 8:12 pm

I am writing a program using tkinter which has callbacks to functions which use GPIO.
Using GPIO the program has be be run via sudo but when I do this the first tkinter function, root = Tk()
causes a traceback "Client is not authorised to connect to server".

Obviously this can be done - my lack of knowledge is the cause of the problem!
Can someone give me the answer?

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Cant run tkinter program using GPIO

Sun Jan 18, 2015 1:56 am

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Cant run tkinter program using GPIO

Sun Jan 18, 2015 8:16 am

Try gksudo instead of sudo. (In this instance, not as a general solution.)

Gumboil
Posts: 44
Joined: Thu Dec 25, 2014 10:20 pm

Re: Cant run tkinter program using GPIO

Sun Jan 18, 2015 4:33 pm

Thank you B.Goode - gksudo worked ok. I got a warning message about a missing RANDR extension but furckling around on the web it appears this may be to do with me running the pi headless from my mac and can be safely ignored.
pigpiod looks like a good general solution - thanks Dougie. Presumably when I install it and invoke the daemon my program will run without needing alteration i.e just using the usual GPIO methods.
Being new to linux I would like the daemon to run at startup. Apparently I need to add it to the /etc/rc.d/rc.local file ?

Return to “Python”