x = self.spinbox37.value() * 40
	  y = self.spinbox38.value() * 40
	  printer = str(self.comboBox4.currentText())
	  print_cmd = 'echo "IN;PU" x "," y | lpr -P %s %s'
	  self.LCDNumber18.display(x)
	  self.LCDNumber19.display(y)
	  #print_cmd = 'echo "IN;PU2100,11300;" | lpr -P %s %s'
	  os.system(print_cmd % (printer, ""))

In the above line I'm trying to use the x and y variable set by the spinbox values, I just can't seem to get the variable value it keeps giving me a literal x and y in the print command. The commented out print command with the forced x and y works great.

Any ideas or help would be appreciated!

In = str("IN;PU")
	  x = str(self.spinbox37.value() * 40) + ","
	  y = str(self.spinbox38.value() * 40) + ";"
	  print x
	  print y
	  printer = str(self.comboBox4.currentText())
	  print_cmd = 'echo str(In) + str(x) + str(y) | lpr -P %s %s'
	  self.LCDNumber18.display(x)
	  self.LCDNumber19.display(y)
	  #print_cmd = 'echo "IN;PU2100,11300;" | lpr -P %s %s'
	  os.system(print_cmd % (printer, ""))

I think I'm on the right track but if I remove the single quotes echo is unknown and if I everything thing else seems to give me a syntax error?

print_cmd = 'echo "IN;PU" x "," y | lpr -P %s %s'
should be written
print_cmd = 'echo "IN;PU%s,%s | lpr -P %s %s' % (x, y, printer, "")
and later use
os.system(print_cmd)

why do you mix single and double quotes here? what do you want to accomplish with this line (taking it as troublous line)

print_cmd = 'echo "IN;PU2100,11300;" | lpr -P %s %s'
In = str("IN;PU")
	  x = str(self.spinbox37.value() * 40) + ","
	  y = str(self.spinbox38.value() * 40) + ";"
	  print x
	  print y
	  printer = str(self.comboBox4.currentText())
	  print_cmd = 'echo str(In) + str(x) + str(y) | lpr -P %s %s'
	  self.LCDNumber18.display(x)
	  self.LCDNumber19.display(y)
	  #print_cmd = 'echo "IN;PU2100,11300;" | lpr -P %s %s'
	  os.system(print_cmd % (printer, ""))

I think I'm on the right track but if I remove the single quotes echo is unknown and if I everything thing else seems to give me a syntax error?

I tried so many combos that the confused line I posted was just my last attempt :) Your answer did the job after adding another double quote! I want to thankyou for taking the time to answer my question as this is my first app attempt and sometimes (more often then not I get lost)

Take for eg: :)
I need to refresh an lcdNumber fast 2 times a second and have everything working good but the lcd only display about 1 in 12 values it is sent. I tried a time.pause() it slowed the process down but also slowed the lcd refresh.
If your busy please ignore this question.

#class Timer(Thread):
#    def __init__ (self):
#        Thread.__init__(self)  
    def lcdxyz(self):
	import time
	pause = .195
	plotfile = os.system("(cat hpgl.plt | sed 's/;/;\\n/g' | sed '/^$/d') > .temp.plt")
	#os.system("cp .temp.plt hpgl.plt")
	plotfile = open(".temp.plt")
	while 1:
          lines = plotfile.readlines(1000)
	  fake = ""
          if not lines:
             break
          for line in lines:
           time.sleep(pause)
	   if  re.match(r'PD', line):
		 line = line.replace("!PZ","")
		 line = line.replace("PD","")
	         line = line.replace("PU","")
		 line = line.replace(";","")
	         x, y = line.split(",")
		 #x = line.replace(" ","")
		 print x
		 print y
		 self.LCDNumber18.display(x)
		 self.LCDNumber19.display(y)
		 #QApplication.processEvents

thanks

def lcdxyz(self):
	import time
	pause = .195
	plotfile = os.system("(cat hpgl.plt | sed 's/;/;\\n/g' | sed '/^$/d') > .temp.plt")
	plotfile = open(".temp.plt")
	while 1:
          lines = plotfile.readlines(1000)
          if not lines:
             break
          for line in lines:
             if  re.match(r'PD', line):
		 line = line.replace("PD","")
	         line = line.replace(";","")
	         x, y = line.split(",")
		 print x
		 print y
		 self.LCDNumber18.display(x)
		 self.LCDNumber19.display(y)
		 time.sleep(pause)
	   	 continue

Has no effect placed here but if I move it higher in the loop like under the while it just stalls when run , no error just stalls. control c to break.

pause = .195

Did you intend this to be 0.195 or 195?

yes it is .195
and may get as low as .005 but never higher than .5
I guess a thread? I attempted to make a class with a thread but it seg. faults when I run it.

#class Timer(HPGL):  ###HPGL is the name of the main app
#    def __init__ (self):
#        Thread.__init__(self)  
    def lcdxyz(self):
	import time
	pause = .195
	plotfile = os.system("(cat hpgl.plt | sed 's/;/;\\n/g' | sed '/^$/d') > .temp.plt")
	#os.system("cp .temp.plt hpgl.plt")
	plotfile = open(".temp.plt")
	while 1:
          lines = plotfile.readlines(1000)
	  fake = ""
          if not lines:
             break
          for line in lines:
           time.sleep(pause)
	   if  re.match(r'PD', line):
		 line = line.replace("!PZ","")
		 line = line.replace("PD","")
	         line = line.replace("PU","")
		 line = line.replace(";","")
	         x, y = line.split(",")
		 self.LCDNumber18.display(x)
		 self.LCDNumber19.display(y)
		 continue
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.