You are not logged in.

1

Thursday, July 21st 2005, 5:36pm

How to open Linux terminal window from QT button clik?

Hello

All who use Fedora core might know that on right clicking on the desktop in menu their is one option that to open terminal window?

Well I am developing an PyQt application and I also want similar functionality. i.e. on clicking one button on my dialog box i want that terminal window to get opened.......

This is much basic thing which is required... Apart from this If possible then can i pass command to the ahell which has been opened i.e. terminal window from my application... Just once

Well say user clicks button in my app. dlg. box
Terminal window should open and
oneof my command say mkdir or some other should execute..

Well mainly i want to run one another application from command line passes to this new terminal window. This application has nothing to do related to my application. I am calling the another application which takes arguments from user in chain one after another and then creates a file..

this file is useful for my application. I hope you got the point and did not misinterpret it with commands which can be executed with say "import sys"

:)

TIA

Sandeep
Leave Your Mark Wherever You Go

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

2

Thursday, July 21st 2005, 6:55pm

RE: How to open Linux terminal window from QT button clik?

You might execute your favourite terminal application (like konsole or xterm) by using QProcess and then send the command you want to be executed to the stdin of the process by using an appropriate QProcess call (writeToStdin, AFAIR).

3

Thursday, July 21st 2005, 8:51pm

Thansk wysota

Well i did work. I just need to look in the MAN pages of QProcess and xterm

well my code is like this

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
proc = QProcess()
proc.addArgument("xterm")
proc.addArgument("-e")
proc.addArgument("myProg")
if proc.start():  
 print "I am started"
 #********************
 # Well upto this stage myProgram has been started  in xterm and my program asks for user inputs. Now at this stage I want to add some parameters to my program say path of file. How to do this? I am trying to pass arguments to my program i.e. myProg like following. But this is not working...
 proc.addArgument("[B]path for working directory[/B]") # Required User input no. 1 then user must press enter , so thart program will prompt for another user input
 proc.addArgument("[B]My filename[/B]") #required user input no. 2. here also user provided file name and press enter..

I tried the above two command with writeToStdin with same quoted string arguments like for 1.0 "\home\field" and for 2.0 "test"

Well it does not workkkkk

I was just trying to take file path from user as in filedialog and provide these fragments to myProg as command line inputs and then show the terminal window.. 

Is this possible else. I will prompt user to select the file  which is created by myProg application mentioned above...

You might be thinking.......Oh God quite a being explanation .... :)  ZZZZ

Sandeep
Leave Your Mark Wherever You Go

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

4

Thursday, July 21st 2005, 9:07pm

Quoted

Originally posted by d0153030
I am trying to pass arguments to my program i.e. myProg like following. But this is not working...
proc.addArgument("path for working directory") # Required User input no. 1 then user must press enter , so thart program will prompt for another user input
proc.addArgument("My filename") #required user input no. 2. here also user provided file name and press enter..

I tried the above two command with writeToStdin with same quoted string arguments like for 1.0 "\home\field" and for 2.0 "test"

Well it does not workkkkk


Why do you use addArgument for this? addArgument is just for starting the process... You then communicate with it using its stdin/stdout:

Source code

1
2
3
4
5
6
7
proc.start()
proc.writeToStdin("/home/field\n") 
# \n is needed, the app needs a carriage return
# for line based reading like scanf
if proc.canReadLineStdout(): 
    out = proc.readLineStdout()
# etc.