The Following 79 Users Say Thank You to kojacker For This Useful Post: | ||
alephito, ArchiMark, Artyom, attila77, binu_ji, bull81, casper27, ccarter, cfh11, cheve, clovis86, codeMonkey, conny, dana.s, Dave999, dgls82, drangina, DrWilken, dzano, fmo, fw190, giannoug, helex, helihyv, Helmuth, HtheB, ibrakalifa, igorgomes, imo, ioan, ir.miringila, ivyking, jackdoor, jacobkorf, jd4200, JonJennings, joshv06, Keir, kinggo, lcuk, LippiVan, lostinmirkwood, m2cm2c, malfunctioning, mbo, mikec, mikecomputing, MINKIN2, mmlado, mwrf, nicholes, noobmonkey, NvyUs, ny-hardcore, Patola, Pretoriano, ranbaxy, rpgAmazon, saned, santiago, Sash, shanttu, SHARP66, sifo, sixwheeledbeast, smoothc, stickymick, taixzo, tgalal, topet2k12001, uppercase, vdx29, vkv.raju, wierdo, wimmme, yogi900, ysss, ziggadebo |
|
2013-02-04
, 12:34
|
|
Posts: 7,074 |
Thanked: 9,069 times |
Joined on Oct 2009
@ Moon! It's not the East or the West side... it's the Dark Side
|
#3
|
The Following User Says Thank You to Dave999 For This Useful Post: | ||
|
2013-02-04
, 13:36
|
|
Posts: 1,079 |
Thanked: 1,019 times |
Joined on Mar 2010
|
#4
|
|
2013-02-04
, 15:44
|
Posts: 1,269 |
Thanked: 3,961 times |
Joined on May 2011
@ Brazil
|
#5
|
|
2013-02-04
, 16:39
|
Posts: 1,548 |
Thanked: 7,510 times |
Joined on Apr 2010
@ Czech Republic
|
#6
|
PyQt (with QtWidgets) don't work* on MeeGo Harmattan. Use Qt/Qt Quick (with C/C++ or Python) instead.
(*) : no vkb, small fonts, etc.
The Following User Says Thank You to MartinK For This Useful Post: | ||
|
2013-07-09
, 08:06
|
|
Posts: 1,974 |
Thanked: 1,834 times |
Joined on Mar 2013
@ india
|
#7
|
The Following User Says Thank You to nokiabot For This Useful Post: | ||
|
2013-07-09
, 12:57
|
Posts: 1,086 |
Thanked: 2,964 times |
Joined on Jan 2010
|
#8
|
Wow with the help of kojackers nobel ideas and his innovative coding skills my n900 now can fart wish it could produce pleasent aromatic feeling also just a feature request : using the front camera or back camera to fart. So that i can keep the phone on sofa and when somebody sits beside it would fart
The Following User Says Thank You to kojacker For This Useful Post: | ||
This is a beginner tutorial in association with the N900 coding competition , running til July 21st. Please get involved
This tutorial covers:
• GUI creation with Qt Designer
• Sound playback with phonon
• Getting around the lack of a switch/case statement in python
• The mystical art of naming fart sounds
Pre-requisites:
If you are a beginner please go through the starter tutorials from MikeC and FatalSaint first, which are both many times more informative and better thought out than this one and will also help get your environments set up.
• MikeC - http://talk.maemo.org/showthread.php?t=43663
• FatalSaint - http://talk.maemo.org/showpost.php?p...8&postcount=59
• Python and PyQt should be installed correctly on your PC and n900
• You should have WinSCP on your PC and OpenSSH client-server on your n900 (or equivalents) for copying the files over.
Caveats
I am also a beginner, this tutorial is put out there in the hope it helps but should not be seen as well written or particularly ‘good’.
Step 1:
Go and grab yourself 5 or 6 fart sounds from the internet. A simple google search should find plenty of .wav farting audible goodness, e.g. http://www.fartgreetings.com/fartwavs.asp might be a start. Or you can use the ones I have attached in the zip file.
Step 2:
Fire up your copy of Qt Designer, from the first dialog choose the Main Window template and set the canvas size to 800*400. We only need two widgets - a List Widget, which is used to select the fart sound, and a Push Button widget to trigger the sound to be played. Drag both widgets onto the canvas, with the list to the left and the button to the right. Space them out and resize them until you’re happy with how they look. For more info on using a layout and use of spacings see FatalSaint’s tutorial linked at the beginning.
Step 3:
Left click on the List Widget, and in the Property Editor change it’s name to ‘soundList’. Then right click on the List Widget and choose “Edit Items” from the mouse’s popup menu. A small window called the “Edit List Widget” will appear, and this is where you enter the fart names that the user will see and click on. Click on the green + symbol on the bottom left corner of the widget and add a name for each of the fart sounds you have gathered from step 1. You can also set the properties for each list item, I have chosen text size 14 and centered. Click OK when finished.
Step 4:
Left click on the Push Button widget, and change it’s name to ‘pushbutton’ in the Property Editor. I have also changed the font size to 33 and the text to read “Fart!”. In addition, by clicking on the styleSheet property you can bring up the Style Sheet Editor widget window to assign a colour to the button, in this case I have chosen a dangerous hue of red.
Step 5:
That is the GUI designed, save (File->Save As) the project as maeFart.ui and close down Qt Designer out of your way. Next we use pyuic4 to generate our python code. Open up a command line prompt, and CD into the folder you have saved the maeFart.ui file. From there, type:
Step 6:
We now have our python GUI, we need a main to call it. Create a new python file called main.py and copy in the following code:
Step7:
Qt uses the Phonon multimedia framework and can playback most of the common multimedia formats. The architecture of Phonon is that, when playing back audio, you create a media object and connect it via a path to an audio output node, which ouputs audio to the sound card or device.
First step to using phonon is to import it into our project, so at the top add:
Connecting the button. We will write a method called playFart(), triggered by the pushButton, that will play the fart sound. First we need to hook up the “clicked()” signal of the button to call the method as so:
Implementing the playFart method by adding the following code to the main.py file
In this case the dictionary only contains keys and the associated filenames as the sound files will be placed in the same folder as the main.py file, otherwise the path would also need to be added to the filenames.
Step 10:
The completed files maeFart.py and main.py should look as follows, test them out locally and make sure everything is ok.
main.py
Use WinSCP and OpenSSH to transfer the files into your N900’s Opt directory. To run, open Xterm and cd into the opt directory and run the main.py file.
That's it for now.. happy farting!
Follow me on my neglected twitter @kojacker
Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun
Last edited by kojacker; 2010-05-29 at 09:02.