0

I am having trouble getting a Python program I created to run in Python's windowless mode (.pyw).

The program reads serial information from an Arduino and, based on what is received, rotates the screen.

In normal mode (.py) it runs properly. It reads the serial information and acts until the program is closed by a user.

In windowless mode (.pyw) it seems to run once and stop.

What is wrong?

import serial
import os

ser = serial.Serial('COM3', 115200)

orientation = "Null"

while True:
     comparison = str.strip(ser.readline())
     #Strip necessary for string comparison and for formatting.

     print comparison

     if (comparison=="Landscape") and (orientation != "Landscape"):
          print "Success Landscape!"
          os.system("start "+"C:\Display\One-0")
          orientation = "Landscape"
     elif comparison=="Portrait" and (orientation != "Portrait"):
          print "Success Portrait!"
          os.system("start "+"C:\Display\One-90")
          orientation = "Portrait"
Lemurs
  • 1
  • 2
  • Look here http://stackoverflow.com/questions/7006238/how-do-i-hide-the-console-when-i-use-os-system-or-subprocess-call – Sergey Nosov Dec 09 '15 at 18:05
  • I have no idea how to implement any of that. Why can't I just save it as a .pyw document? – Lemurs Dec 09 '15 at 19:46
  • Try setting pythonw.exe as the default application for files .pyw – Sergey Nosov Dec 09 '15 at 19:52
  • I tried that. It did not work. I don't know why that would make any difference. It did the same thing as when I ran it with a .pyw extension. Ran once and quit. Can someone explain why my program is not behaving the same way it does in windowless mode as in normal mode? Is there something wrong with the code? Are there certain functions available in one mode that are not available in the other? – Lemurs Dec 10 '15 at 14:01

0 Answers0