Reply
Thread Tools
Posts: 1,751 | Thanked: 844 times | Joined on Feb 2010 @ Sweden
#1
I am a total noob when i comes to Python. But i wanted to give it a try as i need a GUI. I understand bash shell scripting a lot better so i want to use that in my "program" even though i know it would be better to do it all in python.

So where am i going wrong?

(attaching the complete file below)

Code:
        self.retranslateUi(dialog)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), dialog.open)
        QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), dialog.open)
        QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL(_fromUtf8("clicked()")), dialog.open)
        QtCore.QObject.connect(self.pushButton_4, QtCore.SIGNAL(_fromUtf8("clicked()")), dialog.close)
        QtCore.QMetaObject.connectSlotsByName(dialog)
        dialog.setTabOrder(self.pushButton, self.pushButton_3)
        dialog.setTabOrder(self.pushButton_3, self.pushButton_2)
        dialog.setTabOrder(self.pushButton_2, self.pushButton_4)

	def self(dialog):
		f = ("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");
		import subprocess
		subprocess.call("/bin/sh " + f, shell=True);
		print "open(self) started"
Attached Files
File Type: gz awoken.tar.gz (1.2 KB, 67 views)
__________________
You like what i do? Donate!

Make your desktop look awesome - use the AwOken Theme with the AwOken Icon Theme.

Add me on twitter @almehdin
Visit the swedish maemo/meego community forums

Last edited by AlMehdi; 2011-02-28 at 22:57.
 
Posts: 1,751 | Thanked: 844 times | Joined on Feb 2010 @ Sweden
#2
***bump***
__________________
You like what i do? Donate!

Make your desktop look awesome - use the AwOken Theme with the AwOken Icon Theme.

Add me on twitter @almehdin
Visit the swedish maemo/meego community forums
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#3
subprocess.call(["/bin/sh", f])
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post:
Posts: 1,751 | Thanked: 844 times | Joined on Feb 2010 @ Sweden
#4
Originally Posted by attila77 View Post
subprocess.call(["/bin/sh", f])
Thanks, but i already figurred that one out.

Right now i am trying with this two:
Code:
	def open(dialog):
		f = ("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");
		import subprocess
		subprocess.call("/bin/sh " + f, shell=True);

	def dialog(pushButton_2):
		f = ("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");
		from subprocess import Popen
		Popen('/bin/sh ' + f);
I somehow can't "connect" the button click event with the subprocess. When i run it nothing happens. So i think i am doing the "def" string wrong.
__________________
You like what i do? Donate!

Make your desktop look awesome - use the AwOken Theme with the AwOken Icon Theme.

Add me on twitter @almehdin
Visit the swedish maemo/meego community forums
 
Posts: 1,751 | Thanked: 844 times | Joined on Feb 2010 @ Sweden
#5
When i do this i get an error.

Code:
        self.retranslateUi(dialog)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.open)
	def open(self):
		f = ("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");
		import subprocess
		subprocess.call(["/bin/sh " + f]);
The error:
Code:
Traceback (most recent call last):
  File "awoken.py", line 82, in <module>
    ui.setupUi(dialog)
  File "awoken.py", line 43, in setupUi
    QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.open)
__________________
You like what i do? Donate!

Make your desktop look awesome - use the AwOken Theme with the AwOken Icon Theme.

Add me on twitter @almehdin
Visit the swedish maemo/meego community forums
 
Posts: 1,751 | Thanked: 844 times | Joined on Feb 2010 @ Sweden
#6
Solved! I got some help from my friend Wellef and sorted it out. I will attach the file in case someone els finds it useful.

This is how it should look:
Code:
        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.change)
        QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL(_fromUtf8("clicked()")), self.backup)
        QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.reset)
        QtCore.QObject.connect(self.pushButton_4, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def change(self):
	os.system("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");

    def backup(self):
	os.system("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");

    def reset(self):
	os.system("/home/daniel/Hämtningar/n900/awoken-extras/test.sh");
Attached Files
File Type: gz awoken.tar.gz (1.2 KB, 68 views)
__________________
You like what i do? Donate!

Make your desktop look awesome - use the AwOken Theme with the AwOken Icon Theme.

Add me on twitter @almehdin
Visit the swedish maemo/meego community forums

Last edited by AlMehdi; 2011-02-26 at 16:27.
 
Reply


 
Forum Jump


All times are GMT. The time now is 17:47.