El Amir
04-05-2010, 02:45 PM
Hi guys,
I've started learning a bit of python and Qt in order to develop my own application, this has been a bit of a goal for some time now.
I've finally got the python side working well, but i'm really struggling with the UI part.
My application is a simple "clicker" program: you can increment/decrement (by one) the current value, reset the current value to 0 and quit the application.
I know there already is a similar app on the OVI store, but this is more of a first step into developing for me.
Ideally, to do this, the program should have a "+", "-", "reset" and "quit" button and should look like something like this:
http://farm5.static.flickr.com/4036/4493775653_cce8fda99a.jpg
Since, Maemo (and Meego I guess) are all open open source, i dont mind sharing my code, not that it would take most of you more than 5min to do on your own!
This is it:
# Clicker V1 for Nokia N900
# by Amir B (aka "El Amir" or "benjezzy")
print ""
print " * TIP : Press 'q' to exit and 'r' to reset back to 0 * "
print " Also, 'l' will print the last result "
print ""
print " The default value is '0' "
print ""
var = 1
x = 0
while var == 1:
y = raw_input("Press '+' to add one or '-' to substract one: ")
if y == "q":
exit()
elif y == "+":
x = x + 1
print x
elif y == "-":
x = x - 1
print x
elif y == "r":
x = 0
print x
elif y == "":
print 'Please enter something'
elif y == "l":
print x
else:
print 'Input error'
As you can see the code is very simple. I've tried to link the code to the UI but with very little succes:
- I can get the program to create a window,
- to get a working quit button
but
-I can't seem to link any of the buttons to a specific function
-i can't link the program to the LCD object (even though I can connect it to the slider, like in the QT documentation, but that's not really what I need)
So here it is: I'm really lost! And I could do with some help. Any advice is more than welcome, and as soon as I get my app in the repo, i'll be adding some name to the "thanks to/contribution" tab :)
I've started learning a bit of python and Qt in order to develop my own application, this has been a bit of a goal for some time now.
I've finally got the python side working well, but i'm really struggling with the UI part.
My application is a simple "clicker" program: you can increment/decrement (by one) the current value, reset the current value to 0 and quit the application.
I know there already is a similar app on the OVI store, but this is more of a first step into developing for me.
Ideally, to do this, the program should have a "+", "-", "reset" and "quit" button and should look like something like this:
http://farm5.static.flickr.com/4036/4493775653_cce8fda99a.jpg
Since, Maemo (and Meego I guess) are all open open source, i dont mind sharing my code, not that it would take most of you more than 5min to do on your own!
This is it:
# Clicker V1 for Nokia N900
# by Amir B (aka "El Amir" or "benjezzy")
print ""
print " * TIP : Press 'q' to exit and 'r' to reset back to 0 * "
print " Also, 'l' will print the last result "
print ""
print " The default value is '0' "
print ""
var = 1
x = 0
while var == 1:
y = raw_input("Press '+' to add one or '-' to substract one: ")
if y == "q":
exit()
elif y == "+":
x = x + 1
print x
elif y == "-":
x = x - 1
print x
elif y == "r":
x = 0
print x
elif y == "":
print 'Please enter something'
elif y == "l":
print x
else:
print 'Input error'
As you can see the code is very simple. I've tried to link the code to the UI but with very little succes:
- I can get the program to create a window,
- to get a working quit button
but
-I can't seem to link any of the buttons to a specific function
-i can't link the program to the LCD object (even though I can connect it to the slider, like in the QT documentation, but that's not really what I need)
So here it is: I'm really lost! And I could do with some help. Any advice is more than welcome, and as soon as I get my app in the repo, i'll be adding some name to the "thanks to/contribution" tab :)