LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2014, 05:01 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
pyside (or pyqt4) stdio & combo box problem


This is the code I am using.

Code:
def init_combo(self):
        recent = ResDir + '/combo_list.sh'
        process = subprocess.Popen([recent], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        combo_list = process.communicate()[0]
        for workspace in combo_list:
            self.cmbWorkspaces.addItem(workspace)
The 'combo_list.sh' script returns directory paths one line at a time. My intent is to add each path to the combo box. Unfortunately, each character is getting added instead.

Any tips on how to get lines instead of characters from stdio into the combo box is appreciated.

Cheers,
 
Old 04-16-2014, 12:36 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
If combo_list needs to be split into a list of lines, then use combo_list.split('\n') to split it.

As in:

Code:
combo_list = process.communicate()[0]
combo_list = combo_list.split('\n')
for workspace in combo_list:
And pardon this unsolicited advice, but I find it very unlikely that combo_list.sh won't be better if it's a) written in Python and b) part of your main PyQt application. If you need help porting it, I can provide assistance.

Last edited by dugan; 04-16-2014 at 01:50 AM.
 
Old 04-16-2014, 11:31 AM   #3
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Quote:
Originally Posted by dugan View Post
If combo_list needs to be split into a list of lines, then use combo_list.split('\n') to split it.

As in:

Code:
combo_list = process.communicate()[0]
combo_list = combo_list.split('\n')
for workspace in combo_list:
And pardon this unsolicited advice, but I find it very unlikely that combo_list.sh won't be better if it's a) written in Python and b) part of your main PyQt application. If you need help porting it, I can provide assistance.
Dugan! You get a pizza!

Thanks,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] python pyside & QInputDialog error sharky Programming 2 01-15-2014 06:59 AM
GTK+ style combo box MTK358 Linux - Desktop 3 10-01-2010 09:14 AM
pyqt4 and mysql problem almost solved but not quite gary_in_springhill Programming 1 08-22-2010 11:06 PM
c# combo box entry and help trscookie Programming 2 10-12-2006 12:46 PM
Combo,combo box and combo entry box diff santhosh.linux Programming 4 02-27-2006 12:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration