Reply
Thread Tools
Posts: 11 | Thanked: 1 time | Joined on Dec 2009 @ Lisbon, Portugal
#91
Originally Posted by attila77 View Post
Good news, everyone ! As of tonight, PyQt is available to the general public as a simple Extras install (look for python2.5-qt4-doc) from the Application Manager !

PS. Future versions will have a more intuitive package name but I did not want to break the quarantine waiting period
I do see python2.5-qt4-doc in the Application Manager.
Unfortunately I get an error of message stating missing packages
python2.5-qt4-core (=4.7 maemo2).

Anyone getting similar results?
PS : Found this thread,
http://talk.maemo.org/showthread.php...hon2.5-qt4-cor
looks like the solution is not ready yet.

Last edited by Nmigaz; 2010-02-12 at 22:36.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#92
Originally Posted by Nmigaz View Post
I do see python2.5-qt4-doc in the Application Manager.
Unfortunately I get an error of message stating missing packages
python2.5-qt4-core (=4.7 maemo2).

Anyone getting similar results?
PS : Found this thread,
http://talk.maemo.org/showthread.php...hon2.5-qt4-cor
looks like the solution is not ready yet.
http://talk.maemo.org/showthread.php...667#post522667
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following 3 Users Say Thank You to fatalsaint For This Useful Post:
Posts: 67 | Thanked: 26 times | Joined on Jan 2010
#93
cheers for an excellent intro to python. I was put off at first after past nokia experience of the complexity of installing the symbian setup but this was a breeze in comparison and i wrote my first app yesterday! (creates an m3u playlist of all songs once provided with a starting folder)
Nice one guys!
 

The Following 2 Users Say Thank You to toucan murphy For This Useful Post:
Posts: 89 | Thanked: 6 times | Joined on Feb 2010
#94
Hey fatalsaint,

This VMWare Development Environment can be downloaded?

Originally Posted by fatalsaint View Post
Ok, here's a quick tutorial on creating your first app and connecting some signals. The OP shows you how to set everything up so this is going to assume you already have Qt Designer and pyuic4 setup correctly. Screenshots are from the Ubuntu Virtual Machine with the SDK.. but same logic would apply to windows or anything.

So here we go, open up QT designer and create a Main Window:



Lets set the Main Window size to 800x400:


Now we want to create a "Quit" menu item just to show how they work later on in python code.


Now, using the widget selector screen


We click and drag 2 ListWidgets, on either side of the Main Window, and then 5 pushbuttons and a LineEdit in between them. I named the two listWidgets "listRight", and "listLeft" as so:


Using the same screens, I named the buttons:
"btnAdd", "btnAllAdd", "btnRemove", "btnAllRemove", "btnAddNew" and the LineEdit to "lineNew".

Because I like to make things expandable to fit the screen (in case it needs to be resized or is run on something other than a static 800x400 window), we are going to do some grouping too (this is all just for show case). So we add a vertical spacer widget select all the buttons in the middle with the Line Edit and do a Layout Vertically, as so:


Then add two Vertical Spacer widgets to the top and bottom, select them all, and do a layout vertically again.


Now add the Horizontal Spacer widgets shown above to either side, right click on the background Main Window page, and do a "Layout in a Grid". What we end up with is:


Now we're done with QT Designer! So we want to save, and I called it "list_example.ui":


This gives us a standard QT .ui file which would normally be used by a C++ app. But we want python code, so, doing what the OP and every other tutorial tells us to we use pyuic4:

Code:
pyuic4 -o list_example_ui.py list_example.ui
That gives us new python file. Unfortunately, we can't run that file directly as all it is is the GUI - we need to launch it somehow, so we create the main python app and I called it "list_example.py" with the following code:
Code:
#!/usr/bin/python2.5
import sys
from PyQt4 import QtGui,QtCore
from list_example_ui import *

class MyForm(QtGui.QMainWindow):
        def __init__(self, parent=None):
                #build parent user interface
                QtGui.QWidget.__init__(self, parent)
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)

if __name__ == "__main__":
        #This function means this was run directly, not called from another python file.
        app = QtGui.QApplication(sys.argv)
        myapp = MyForm()
        myapp.show()
        sys.exit(app.exec_())


Now we can run list_example.py directly. If it's on the N900, use "python list_example.py", if you're in the SDK/Scratchbox and want to see it show up properly in Xephyr you use "run-standalone.sh python list_example.py" and voila! We get:


But, of course, nothing works! So we close out and decide we want those buttons to actually do something. We know we have 5 buttons, and 1 menu item, so we know we are going to need 6 connects. So lets try some:
Code:
class MyForm(QtGui.QMainWindow):
        def __init__(self, parent=None):
                #build parent user interface
                QtGui.QWidget.__init__(self, parent)
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)

                #connect buttons
                QtCore.QObject.connect(self.ui.btnAdd, QtCore.SIGNAL('clicked()'), self.doAdd)
                QtCore.QObject.connect(self.ui.btnAllAdd, QtCore.SIGNAL('clicked()'), self.doAllAdd)
                QtCore.QObject.connect(self.ui.btnRemove, QtCore.SIGNAL('clicked()'), self.doRemove)
                QtCore.QObject.connect(self.ui.btnAllRemove, QtCore.SIGNAL('clicked()'), self.doAllRemove)
                QtCore.QObject.connect(self.ui.btnAddNew, QtCore.SIGNAL('clicked()'), self.doAddNew)
                QtCore.QObject.connect(self.ui.actionQuit, QtCore.SIGNAL('triggered()'), QtGui.qApp, QtCore.SLOT('quit()'))
Now, we've connected all 6 items to something. But python has no idea what the things like "self.doAdd" and "self.doAllAdd" are. The only one of those connects that will work is the last one for the "Quit" menu item because we connected it to a built-in qt "quit" slot.

So, now we create various functions (also called methods) that correspond to the names we connected the buttons to:
Code:
        #Create Sub's
        def doAdd(self):
                add = 1
                for i in range(self.ui.listRight.count()): #let's not create duplicates, so lets do a search.
                        if self.ui.listRight.item(i).text() == self.ui.listLeft.currentItem().text():
                                add = 0
                if add: #Okay, it wasn't found.  Let's add it.
                        self.ui.listRight.addItem(self.ui.listLeft.currentItem().text())

        def doAllAdd(self): #This ones easy, just clear the right one, go through all the left items and add them.
                self.ui.listRight.clear() 
                for i in range(self.ui.listLeft.count()):
                        self.ui.listRight.addItem(self.ui.listLeft.item(i).text())

        def doRemove(self): #Easy again, just remove the selected item.
                self.ui.listRight.takeItem(self.ui.listRight.currentRow())

        def doAllRemove(self): #Super Easy.
                self.ui.listRight.clear()

        def doAddNew(self): #Pretty easy, just add to the left what is in the text box, then clear it out.
                self.ui.listLeft.addItem(self.ui.lineNew.text())
                self.ui.lineNew.clear()
So, we put it all together and we have (without the above comments):
Code:
#!/usr/bin/python2.5
import sys
from PyQt4 import QtGui,QtCore
from list_example_ui import *

class MyForm(QtGui.QMainWindow):
	def __init__(self, parent=None):
		#build parent user interface
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		#connect buttons
		QtCore.QObject.connect(self.ui.btnAdd, QtCore.SIGNAL('clicked()'), self.doAdd)
		QtCore.QObject.connect(self.ui.btnAllAdd, QtCore.SIGNAL('clicked()'), self.doAllAdd)
		QtCore.QObject.connect(self.ui.btnRemove, QtCore.SIGNAL('clicked()'), self.doRemove)
		QtCore.QObject.connect(self.ui.btnAllRemove, QtCore.SIGNAL('clicked()'), self.doAllRemove)
		QtCore.QObject.connect(self.ui.btnAddNew, QtCore.SIGNAL('clicked()'), self.doAddNew)
		QtCore.QObject.connect(self.ui.actionQuit, QtCore.SIGNAL('triggered()'), QtGui.qApp, QtCore.SLOT('quit()'))

		#Create Sub's
	def doAdd(self):
		add = 1
		for i in range(self.ui.listRight.count()):
			if self.ui.listRight.item(i).text() == self.ui.listLeft.currentItem().text():
				add = 0
		if add:
			self.ui.listRight.addItem(self.ui.listLeft.currentItem().text())

	def doAllAdd(self):
		self.ui.listRight.clear()
		for i in range(self.ui.listLeft.count()):
			self.ui.listRight.addItem(self.ui.listLeft.item(i).text())

	def doRemove(self):
		self.ui.listRight.takeItem(self.ui.listRight.currentRow())

	def doAllRemove(self):
		self.ui.listRight.clear()

	def doAddNew(self):
		self.ui.listLeft.addItem(self.ui.lineNew.text())
		self.ui.lineNew.clear()

if __name__ == "__main__":
	app = QtGui.QApplication(sys.argv)
	myapp = MyForm()
	myapp.show()
	sys.exit(app.exec_())
And our final application:


Yay, not the most useful app.. this is entirely just a "look, it works".. leave it up to you guys to make something useful.

I don't know if anyone will actually *find* any of this any more/less useful than other tutorials.. but maybe some of the images can be used for whoever does the wiki article.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#95
Originally Posted by jozeph View Post
Hey fatalsaint,

This VMWare Development Environment can be downloaded?
Yes

(Don't need to copy my entire tutorial.. it's quite big to be constantly repeated.)
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following User Says Thank You to fatalsaint For This Useful Post:
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#96
1st, thx for the tutorials, they are great, I think. Why? >>> Read on.

Sigh, This is what I get for going 64 bit?
Code:
C:\Widget>pyuic4 -x untitled.ui -o untitled.py
Traceback (most recent call last):
  File "C:\Python26\Lib\site-packages\PyQt4\uic\pyuic.py", line 4, in <module>
    from PyQt4 import QtCore
ImportError: DLL load failed: %1 is not a valid Win32 application.

C:\Widget>
I have python 2.6 installed like adviced in the tutorial on page 1,
and the PyQt for python 2.6, but no go.
I am frustrated!
 
mikec's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#97
Originally Posted by eitama View Post
1st, thx for the tutorials, they are great, I think. Why? >>> Read on.

Sigh, This is what I get for going 64 bit?
Code:
C:\Widget>pyuic4 -x untitled.ui -o untitled.py
Traceback (most recent call last):
  File "C:\Python26\Lib\site-packages\PyQt4\uic\pyuic.py", line 4, in <module>
    from PyQt4 import QtCore
ImportError: DLL load failed: %1 is not a valid Win32 application.

C:\Widget>
I have python 2.6 installed like adviced in the tutorial on page 1,
and the PyQt for python 2.6, but no go.
I am frustrated!

Have a look at this post

http://talk.maemo.org/showpost.php?p...1&postcount=58

Might help
__________________
N900_Email_Options Wiki Page
 
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#98
Originally Posted by mikec View Post
Have a look at this post

http://talk.maemo.org/showpost.php?p...1&postcount=58

Might help
I don't think so, he is talking about stuff not working on his n900,
I am having problems converting the UI file to PY file on my windows 7 machine... way before putting anything on my n900.

I know I can install windows xp vm / ubuntu / but for the 1st time since years, I actually have an OS on my PC (windows 7) that I really like, and really enjoy working on. (Iv'e tried ubutnu several times...).
 
Posts: 6 | Thanked: 2 times | Joined on Dec 2009
#99
Originally Posted by eitama View Post
Sigh, This is what I get for going 64 bit?
Did you find a solution? I have the same problem on my 64 bits windows7 machine...

EDIT:
I found the solution!
It's quite simple... We got an error because we installed the 64 bits version of python 2.6. I removed the 64 bits version and installed the 32 bits one and Presto! It works fine...

Last edited by Eddie1802; 2010-02-20 at 23:24.
 

The Following 2 Users Say Thank You to Eddie1802 For This Useful Post:
eitama's Avatar
Posts: 702 | Thanked: 334 times | Joined on Feb 2010 @ Israel.
#100
Originally Posted by Eddie1802 View Post
Did you find a solution? I have the same problem on my 64 bits windows7 machine...

EDIT:
I found the solution!
It's quite simple... We got an error because we installed the 64 bits version of python 2.6. I removed the 64 bits version and installed the 32 bits one and Presto! It works fine...
O'G - it works!!! you are my hero
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 05:44.