-1

I am trying to send 3 arguments to pythonw program when running the progam from the CMD prompt in Windows 10. My code is:

import sys
from PyQt4.QtCore import (QTimer, Qt)
from PyQt4.QtGui import (QApplication, QLabel)

arg_no= len(sys.argv)
app = QApplication(sys.argv)

message = "%i arguments given, %i arguments after QApplication %s" % (arg_no, len(sys.argv), str(sys.argv))

label = QLabel("<font color=red size=72><b>{0}</b></font>"
               .format(message))
label.setWindowFlags(Qt.SplashScreen)
label.show()
QTimer.singleShot(60000, app.quit) # 1 minute
app.exec_()

For example, when I try the following from the CMD prompt:

C:\Temp\pyqtbook26\chap04>alert.pyw 07:50 wake up now

Python is only seeing the first argument (C:\Temp\pyqtbook26\chap04>alert.pyw), and, is not seeing the remaining three arguments (07:50 wake up now). My instinct is that this could be some type of registry problem, but, I am not sure how to fix it?

Philip Whitten
  • 293
  • 2
  • 16
  • 1
    You need to show your code. – BrenBarn Nov 15 '16 at 21:15
  • 2
    Make sure that the default value for `[HKCU | HKLM]\Software\Classes\Python.NoConFile\Shell\open\command` is correctly configured. It should run either pyw.exe or pythonw.exe with the arguments `"%1" %*`. – Eryk Sun Nov 15 '16 at 21:25
  • My computer registry does not have an entry under `[HKCU | HKLM]\Software\Classes\Python.NoConFile\Shell\open\command`. Is it something that should be manually added, or, is it indicative of a more significant installation error? – Philip Whitten Nov 16 '16 at 05:55
  • I assumed some familiarity with the Windows registry. `HKCU` is short for `HKEY_CURRENT_USER` and `HKLM` is short for `HKEY_LOCAL_MACHINE`. By `HKCU | HKLM` I meant that the `Python.NoConFile` key will be defined in one or the other location, depending on whether you installed Python for just the current user or for all users. – Eryk Sun Nov 16 '16 at 15:53
  • I understood the use of the HKCU and HKLM acronyms. I do not find any keys called "Python.NoConFile" when I search the entire registry of my computer. – Philip Whitten Nov 17 '16 at 01:41
  • Did you install Python using the official installer from python.org or some other distribution such as Anaconda or ActivePython? – Eryk Sun Nov 17 '16 at 03:09
  • See what's currently selected as the user choice for .pyw files: `HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pyw\UserChoice`. It should be the `ProgId` value in that key. – Eryk Sun Nov 17 '16 at 03:13

1 Answers1

0

This question was answered before.

I had to reassign the HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command and HKEY_CLASSES_ROOT\Applications\pythonw.exe\shell\open\command registry keys to "C:\Python27\python.exe" "%1" %* and "C:\Python27\pythonw.exe" "%1" %* respectively. The origin of my problem is likely due to a previous installation of python on the same computer. This answer is essentially the same as the comments made by eryksun although the key names were slightly different.

Community
  • 1
  • 1
Philip Whitten
  • 293
  • 2
  • 16