amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

python gui

Fri Apr 25, 2014 9:55 pm

okay so i am new to programming python an my knowledge is very limited on the subject currently trying to make buttons and such for a project for the raspberry. but cannot get any of the code i find on tutorials to work??? i am usuing IDLE 3. could someone point me to a good how to website or know a good book?

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: python gui

Sat Apr 26, 2014 6:24 am

amerant wrote:okay so i am new to programming python an my knowledge is very limited on the subject currently trying to make buttons and such for a project for the raspberry. but cannot get any of the code i find on tutorials to work??? i am usuing IDLE 3. could someone point me to a good how to website or know a good book?
Without knowing what you have already tried it is possible that people will simply recommend things that have already caused you difficulty.

If you are using IDLE3, are you taking care to follow only tutorials that use Python3 as their scripting language? [Note, that is NOT the same thing as 'Python', which on the Raspbian OS will default to using Python Version 2.]

Which GUI toolkit do you hope to learn and use?

Also, since IDLE3 is itself a Python3 gui application I wonder if there might be conflicts if you try to use it to execute a script which itself tries to create a gui? [Using the Editor in IDLE3 should not be a problem - running the script might be. What happens if you run your script using something like python3 my_gui_script.py at a shell (terminal) prompt?]
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

masterdrain
Posts: 36
Joined: Fri Jun 07, 2013 7:44 pm
Location: Isle of Wight
Contact: Website

Re: python gui

Sat Apr 26, 2014 11:34 am

I have found a very promising program called 'gui2py' - see https://code.google.com/gui2py/ . Although it says that it will run on Linux, most of the downloads appear to be for Windows, with a few Ubuntu files.

Any suggestions as to how to get this running on the RPi? I do not want to use this on my Windows machines as this rather defeats the object of programming on the RPi! I did try 'sudo apt-get install gui2py' but it did not want to know.

Any ideas?

Iain

gkreidl
Posts: 6195
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: python gui

Sat Apr 26, 2014 12:51 pm

https://code.google.com/p/gui2py/wiki/InstallationGuide

BTW, your original link is not working!
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

Re: python gui

Sat Apr 26, 2014 8:55 pm

I just tried some things i find on Google that would work. I've Done scripting work my knowledge on gui route programming is none. I want to attach my pi to my car run a auto start. Turn on and off kc lights lock unlock. Just trying to figure out how to make buttons to control gpio pins

amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

Re: python gui

Mon Apr 28, 2014 2:59 am

from all the reading i have done tkinter should work on the idle 3 or the idle 2.7 and i tried both with no luck.. this is a copy of a button coding i had found and it will not work

Code: Select all

from Tkinter import *
 
import time
import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
def say_hi():
	print "Lighting up LED"
	GPIO.output(17, GPIO.HIGH)
	time.sleep(5)
	GPIO.output(17, GPIO.LOW)
	
def check_button():
	if (GPIO.input(18) == GPIO.LOW):
		labelText.set("Button Pressed.")
	else:
		labelText.set("")
	root.after(10,check_button)
 
root = Tk()
 
button = Button(root, text="Quit.", fg="red", command=quit)
button.pack(side=RIGHT, padx=10, pady=10, ipadx=10, ipady=10)
 
hi_there = Button(root, text="Light my LED!", command=say_hi)
hi_there.pack(side=LEFT, padx=10, pady=10, ipadx=10, ipady=10)
 
labelText = StringVar()
labelText.set("Button Pressed.")
label1 = Label(root, textvariable=labelText, height=4)
label1.pack(side=LEFT)
 
root.title("LED Blinker")
root.geometry('500x300+200+200')
 
root.after(10,check_button)
root.mainloop()

TrevorAppleton
Posts: 74
Joined: Wed May 30, 2012 7:26 pm
Contact: Website

Re: python gui

Mon Apr 28, 2014 10:04 am

Hi,

I have written a few blog posts about using Tkinter. Once you get the hang of it it really is easy to churn out GUIs quite easily with it.

Have a look at this post as it may well help you.

http://trevorappleton.blogspot.co.uk/20 ... e-gui.html

Trevor
Check out my blog post for Raspberry Pi and Python tutorials.

http://trevorappleton.blogspot.co.uk/

amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

Re: python gui

Mon Apr 28, 2014 10:53 pm

Okay another question..... is there a way to make the file executable without having to run it through python?

TrevorAppleton
Posts: 74
Joined: Wed May 30, 2012 7:26 pm
Contact: Website

Re: python gui

Tue Apr 29, 2014 2:33 pm

To make an .exe file so you don't have to use Python you could use py2exe.
Check out my blog post for Raspberry Pi and Python tutorials.

http://trevorappleton.blogspot.co.uk/

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: python gui

Tue Apr 29, 2014 2:49 pm

...only problem is, tkinter is UGLY!

Why not make your own gui library with pygame..?
note: I may or may not know what I'm talking about...

gkreidl
Posts: 6195
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: python gui

Tue Apr 29, 2014 3:33 pm

TrevorAppleton wrote:To make an .exe file so you don't have to use Python you could use py2exe.
On the RPi?
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

Re: python gui

Tue Apr 29, 2014 5:50 pm

toxibunny wrote:...only problem is, tkinter is UGLY!

Why not make your own gui library with pygame..?
I don't have much knowledge I'm python didn't know that was possible. I will do some Looking into it and try and figure her out. Also found a good book on tkinter programming " tkinter gui applications and development" written by hotshot. For anyone who is looking for a book to read up on it

amerant
Posts: 9
Joined: Fri Apr 25, 2014 1:05 pm

Re: python gui

Wed Apr 30, 2014 11:25 pm

Hey where can I get a list of all the widgets for tkinter that are there for 2.7 python

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: python gui

Thu May 01, 2014 6:47 am

amerant wrote:where can I get a list of all the widgets for tkinter that are there for 2.7 python
Google knows!

https://wiki.python.org/moin/TkInter

http://infohost.nmt.edu/tcc/help/pubs/t ... index.html
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

gkreidl
Posts: 6195
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: python gui

Thu May 01, 2014 6:52 am

amerant wrote:Hey where can I get a list of all the widgets for tkinter that are there for 2.7 python
http://infohost.nmt.edu/tcc/help/pubs/t ... index.html

edit: same idea at the same time :-)
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
adcomp
Posts: 6
Joined: Tue Nov 08, 2011 7:43 pm
Location: Belgium
Contact: Website

Re: python gui

Fri May 02, 2014 3:23 pm

Hello,

TkDocs - Information you need to build high-quality Tk user interfaces.
http://www.tkdocs.com/

Tinkering with Tkinter : PyCon Australia
https://www.youtube.com/watch?v=yI7NYgP54sw

SteveLipton
Posts: 1
Joined: Fri Apr 11, 2014 3:11 pm
Location: Chicago, IL USA
Contact: Website

Re: python gui

Sun May 04, 2014 2:08 am

amerant wrote:okay so i am new to programming python an my knowledge is very limited on the subject currently trying to make buttons and such for a project for the raspberry. but cannot get any of the code i find on tutorials to work??? i am usuing IDLE 3. could someone point me to a good how to website or know a good book?
I 'm in the middle of producing a set of tutorials on this exact topic in my series From Apple to Raspberry Pi which should give you a lot of what you are looking for, including examples. Head over to[ url]http://makeapppie.com/raspberry-pi/[/url] and look at the Tkinter section. I'll be covering stylized buttons and controls this week, and list boxes next week, but to get you some GUI buttons (including graphic ones) for now I think you will be able to get any simple button up and running.
Steven Lipton
Making App Pie -- makeAppPie.com

Return to “Python”