maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Python help and suggestions please (https://talk.maemo.org/showthread.php?t=25467)

Munk 2008-12-09 02:16

Python help and suggestions please
 
Hi, I'm working on my first Python application ever and I have some questions that I couldn't find doing searches or possibly just not understand when I found it.

First, I've been developing it on my Windows XP machine with Python runtime and PyGame installed. What I make on it transfers over to my N810 and runs perfectly fine just a million times slower. I use nano on the N810 to do additional editing when I am away from the laptop. My question on this one is if I should be doing my development and transferring another way?

Second, how the heck do I get the icon that I've created to show up in the task bar? If I switch away from the screen, I can't toggle back but still hear the audio it was playing continue on. Do I need to use GTK window items which I'm not sure I even understand what that is. Or, do I just simply need to make an icon and stick it in the right directory? I do have it showing up in the maemo menu to launch the app with no issues so at least I'm doing part of it right.

Third, I eventually want to make a .deb file but my program uses two different sub-directories. I use a "data" sub-directory to store my icons, audio files, xml data, etc. I also use a directory where I store larger ".wav" files that I currently have under "\media\mmc1\wav_files" so I'm not eating away from the built-in storage area. Is it possible to make a .deb installation that would create and install my different files into different locations?

Fourth, is there a maximum amount of files that I can have in my .deb install? I currently am using about 120 files and that could grow by the time I am done. Will this be a nightmare to maintain too?

Last, I need the screen to undim at times, is there a way to do this from Python? I read somewhere that someone tried it but they couldn't get it to work. Am I now crossing over into this "dbus" world and is it as scary as I feel it is?

Please be kind as I really am trying to get this working without being a pest.

yerga 2008-12-09 12:52

Re: Python help and suggestions please
 
Quote:

Originally Posted by Munk (Post 248013)
Hi, I'm working on my first Python application ever and I have some questions that I couldn't find doing searches or possibly just not understand when I found it.

Welcome to the awesome python world ;)

Quote:

First, I've been developing it on my Windows XP machine with Python runtime and PyGame installed. What I make on it transfers over to my N810 and runs perfectly fine just a million times slower. I use nano on the N810 to do additional editing when I am away from the laptop. My question on this one is if I should be doing my development and transferring another way?
It depends on the tastes of everyone.
I, generally, develop in the scratchbox environment because I can have a more realistic view as it works. But my applications are all hildon/gtk based, and the UI can look different that in the desktop (smaller widgets, etc.). If you develop with pygame it looks similar in the desktop as in the tablet, but as you say slower ;)
Sometimes I write code in the train when I return to home in weekdays, python allow us to do it without compile nothing. I use leafpad or pygtkeditor in the tablet.

When I am in the desktop I transfer the files for ssh using gftp. There people who have a more automatic process with rsync or other tools.

Quote:

Second, how the heck do I get the icon that I've created to show up in the task bar? If I switch away from the screen, I can't toggle back but still hear the audio it was playing continue on. Do I need to use GTK window items which I'm not sure I even understand what that is. Or, do I just simply need to make an icon and stick it in the right directory? I do have it showing up in the maemo menu to launch the app with no issues so at least I'm doing part of it right.
Yeah, as it's a pygame application, it needs some special code to be shown in the taskbar.
Where you have you main code put:
Code:

import os
os.environ["SDL_VIDEO_X11_WMCLASS"]="here_your_binary_name"

I think it's the only thing necessary, but I haven't coded any pygame application. If it doesn't works, you could look at the code of some existing pygame projects as mclok, pyano or others.


Quote:

Third, I eventually want to make a .deb file but my program uses two different sub-directories. I use a "data" sub-directory to store my icons, audio files, xml data, etc. I also use a directory where I store larger ".wav" files that I currently have under "\media\mmc1\wav_files" so I'm not eating away from the built-in storage area. Is it possible to make a .deb installation that would create and install my different files into different locations?
Yeah, it's possible if you use "The Right Way (TM)" with debian tools. I don't know if you can to do it if you use other tools, specially if you haven't a debian system.
A recommendation is you don't hard-coded the large files to a specific directory. I mean if you put the files automatically to /media/mmc1, people could not have that directory in the memory card (i.e n810 if you haven't an external card).
A good script in the debian/postinst file could help here, allow to the user choose the card where put the files.

Quote:

Fourth, is there a maximum amount of files that I can have in my .deb install? I currently am using about 120 files and that could grow by the time I am done. Will this be a nightmare to maintain too?
No, you can put the files you estimate necessary. When you have done the framework for the debian packages (I mean you have all directories and everything put in the right order), the creation of debian packages is practically automatic and you can easily add new files to this process. Again I am talking about the debian way to do packages, with other tools I don't know.

Quote:

Last, I need the screen to undim at times, is there a way to do this from Python? I read somewhere that someone tried it but they couldn't get it to work. Am I now crossing over into this "dbus" world and is it as scary as I feel it is?
Yeah, I agree completely dbus is really scary :)
It's posiible dim/undim it with dbus commands, so you don't need send dbus signals with dbus code, else you can run a dbus command with os.popen or os.command.
I think the necessary command is somewhere here in the forum.

Quote:

Please be kind as I really am trying to get this working without being a pest.
I think I was kind enough ;)

Munk 2008-12-09 20:00

Re: Python help and suggestions please
 
Wow, Daniel (Yerga), thank you for responding to all of my questions. Next, I will try your suggestions with what I have working and see where I go from there.

Thanks again.

Munk 2008-12-18 06:21

Re: Python help and suggestions please
 
Hi yerga, (and everyone else that has helped me learn Python)

I finally put that little piece of code into my Python program and have it showing the icon in the task manager. Thanks, thanks, thanks. I'm getting close to releasing my program, but there's still more coding, centering, bug trapping, etc. to do. Also, I need to master the .deb creation process. I'm not quite ready to release it, so this is not really an "Announce" post, but rather a thanks and here's what I've been up to.

My program, called "traveller" (European spelling) is yet another clock, but it was aimed at the traveler who goes to hotel rooms and needs an atmospheric sound to drown out the noisy cars, guest, etc. The user can load up their own .wav files and pick which sounds to play letting it loop for an atmospheric background. I paid $80 for a hardware device to do this and it was pretty limited too. While I was at it, I figured that I might as well add a weather update, horoscope, alarms, world time, etc. World time will come later or maybe not at all. Not sure yet.

For now, here's what I've been up to for the last three months (geesh time flys):

http://www.xbox1.com/temp/traveller-Atmosphere.png
http://www.xbox1.com/temp/traveller-Weather.png
http://www.xbox1.com/temp/traveller-Horoscope.png
http://www.xbox1.com/temp/traveller-Alarms.png
http://www.xbox1.com/temp/traveller-Alarm.png

I'm so busy all of the time that it's taking forever and I'm afraid the N900 will be out by the time this is ready. :(

thp 2008-12-18 12:24

Re: Python help and suggestions please
 
Quote:

Originally Posted by Munk (Post 250524)
I'm so busy all of the time that it's taking forever and I'm afraid the N900 will be out by the time this is ready. :(

That's not a problem at all. To my knowledge the current tablets won't stop working when the N900 is out. Something many people forget.

Also, if you would do a release on maemo.org (with all the unfinished bits disabled/hidden) maybe other people like your ideas and start contributing. Give it a try! Good luck!

pycage 2008-12-18 12:47

Re: Python help and suggestions please
 
If you don't rely too heavily on D-Bus API and maemo-specific stuff, chances are good that the software will work unchanged on the next OS release thanks to Python.

Munk 2008-12-18 22:57

Re: Python help and suggestions please
 
Quote:

Originally Posted by pycage (Post 250594)
If you don't rely too heavily on D-Bus API and maemo-specific stuff, chances are good that the software will work unchanged on the next OS release thanks to Python.

Well, no problems here as I really am not using any d-bus calls yet. But, during my internet update and downloading XML data it can sometime pause for a long time. I saw somewhere where someone was using the d-bus and I believe it was called streams so they could get the data without halting the show. Is this advisable?

pycage 2008-12-21 23:04

Re: Python help and suggestions please
 
This has nothing to do with D-Bus. What you want is to use a separate thread for downloading the stuff, so that it doesn't block your application.
Another alternative (esp. when using PyGTK) is gobject.io_add_watch for asynchronous but non-threaded IO. Threads and PyGTK generally don't behave very well together.

Munk 2008-12-26 20:32

Re: Python help and suggestions please
 
Another question on Python. In my searches I could not find the answer.

Is there a way that I can have Python launch the web browser and a specific URL? Just to reword it, there's a giant button that says open this web page on the screen of the Python Pygame app. The user clicks it and then the browser opens up and is browsing to a specific URL?

qwerty12 2008-12-26 20:42

Re: Python help and suggestions please
 
Sorry, I don't really know much so better off waiting for a better answer...
You can do
Code:

os.system(browser --url=<url>)
to launch it using the equivalent of launching it from the command line in a new window but it can also be launched via dbus. I kinda know how to do it in c, not really sure how python works :/

mikkov 2008-12-26 21:03

Re: Python help and suggestions please
 
Quote:

Originally Posted by Munk (Post 252686)
Another question on Python. In my searches I could not find the answer.

Is there a way that I can have Python launch the web browser and a specific URL? Just to reword it, there's a giant button that says open this web page on the screen of the Python Pygame app. The user clicks it and then the browser opens up and is browsing to a specific URL?

Use the webbrowser module
http://docs.python.org/library/webbrowser.html

ciroip 2008-12-27 07:51

Re: Python help and suggestions please
 
Quote:

Originally Posted by Munk (Post 250524)
Hi yerga, (and everyone else that has helped me learn Python)

I finally put that little piece of code into my Python program and have it showing the icon in the task manager. Thanks, thanks, thanks. I'm getting close to releasing my program, but there's still more coding, centering, bug trapping, etc. to do. ...
IMG]http://www.xbox1.com/temp/traveller-Alarm.png[/IMG]
..

Hey it seem we had the same idea at the same time and we are walking in the same path (1st application in python, pygame and a full screen clock), but your project seem really more advanced than mine :
http://www.internettablettalk.com/fo...ad.php?t=25582
I decided to show my miseries pretty fast (just after I was able to make some number movings :) ) and the support from people in the forum is great. Kudos to your project (that seem pretty advanced). Once youll release your version we should merge the thread since the topic is pretty the same :)
Developing for the nokia tablet is a joy and, since the hardware is exactly the same for everyone, pretty easy to spot particular technics, optimizations and tricks that every developer use.
P.S. Xbox1?

Munk 2008-12-27 09:19

Re: Python help and suggestions please
 
Quote:

Originally Posted by ciroip (Post 252771)
Hey it seem we had the same idea at the same time and we are walking in the same path (1st application in python, pygame and a full screen clock), but your project seem really more advanced than mine :
http://www.internettablettalk.com/fo...ad.php?t=25582
I decided to show my miseries pretty fast (just after I was able to make some number movings :) ) and the support from people in the forum is great. Kudos to your project (that seem pretty advanced). Once youll release your version we should merge the thread since the topic is pretty the same :)
Developing for the nokia tablet is a joy and, since the hardware is exactly the same for everyone, pretty easy to spot particular technics, optimizations and tricks that every developer use.
P.S. Xbox1?

Croip, man, that is absolutely beautiful stuff you have going there. I really wish my graphics ability was even 1/10th of yours. Thanks for saying the nice stuff too. I see we both have Amiga backgrounds too. I had an A500 and A1200 both with HD's, expanded processors and memory, on and on. With my friends going with A2000's, etc. In fact the only real program I made on Windows Mobile was an Amiga UAE front end launcher that explained all of the items such as fast RAM, 68000 vs 010 vs 020 etc. before saving the config file out and launching the emulator. It's been updated since this release now that others have worked on it but you gbet the idea.

http://xbox1.com/puaelauncher/

The xbox1.com was a fan site I made a long time ago and then let die because a new way of thinking was taking place for me. I find that I, and many others, take sides. Sometimes to a fault. So take it with a grain of salt.

I got permission from accuweaher.com to use their data and they gave me a custom xml link for this program. But there were a few rules to follow in exchange including: displaying their logo, having at least two days of forecasts showing and making each day a link to theri website with expanded details. So this is why I am after this knowledge. Oh and BTW, the people at Accuweather.com couldn't have been any cooler, kinder and more down to earth. They were simply great.

The people of this forum are also some of the best people I know without knowing them. So helpful and similar in thoughts and at times so different. Sometimes a little strong on the Linux platform side. Just a good group. I love my NIT and hope this program could help others.

Sorry for rambling. :o

ciroip 2008-12-27 20:19

Re: Python help and suggestions please
 
Quote:

Originally Posted by Munk (Post 252777)
I really wish my graphics ability was even 1/10th of yours
...

well the graphics was initially meant to be used by other people. ( i have a big problem to call myself a developer...:) )
So if you spot something could be usefull for your projects just use it; i have no problem in case you need, togenerate particular sizes since I translated the approach of the kontori theme maker (1 file source) and i can easily create a different version with few steps.
Size changes= ok
hue changes(tones) =ok
completely new graphics= heavy challenged by time and mood

Munk 2008-12-27 22:40

Re: Python help and suggestions please
 
Quote:

Originally Posted by mikkov (Post 252691)

mikkov, thank you soooo much. In my quick checking, this works on my laptop with no issues but fails on the NIT. I'll do some more testing, configuring, etc. But, thank you. This is the answer I just need to do it correctly.

Munk 2008-12-29 03:58

Re: Python help and suggestions please
 
Anyone know why "webbrowser.open" seems to work perfectly on Windows but doesn't error or actually pop-up a browser on the NIT? Maybe I should just use the suggested command line from Qwerty12 of "os.system(browser --url=<url>)"

Sometimes, programming success is fast and exciting. Other times, I can waste an entire day just trying to pull a simple little item up. :mad:

mikkov 2008-12-29 15:36

Re: Python help and suggestions please
 
Well at least for me it works fine

this is what I do at python console
Code:

>>> import webbrowser
>>> webbrowser.open("http://www.maemo.org")
True



All times are GMT. The time now is 22:01.

vBulletin® Version 3.8.8