0

I am attempting to build a GUI for a project at work; one requirement of this GUI is that it must give fields for the user to scan-in important data that is contained in barcodes. I am capturing the result of each Field and storing that in a Global variable, to be saved into a CSV later.

As PyGame 1.9.3 doesn't appear to have a built-in Text Field module, I have tried using both presently-available third-party systems; "EzText" and "Text_Input". However, I've had issues with installing both of these on my machine (I am running Windows 7 SP1, 64-bit).

Here's the rundown of that, for context: After performing installations of PyVisa(1), PyGame(2), Git(3) 32-bit, and cx_Freeze(4), I attempted to do a pip-install of both Eztext and Text_Input, as neither Ez nor TI's GitHub(a(5),b(6)) or Pygame(a(7),b(8)) pages had special instructions for installation otherwise. The instructions for doing this I took from here(9), here(10), and here(11). python -m pip install -e git+https://github.com/ffavela/eztext.git#egg=eztext python -m pip install -e git+https://github.com/Nearoo/pygame-text-input#egg=pygame-text-input

The resulting output of both attempts was about the same (accounting for difference in Github address and module name): Pip error 1 (12) Pip error 2 (13)

I have since been attempting to do an of the or the files, wherein the Class functions I am seeking are built. To do this, I have followed the Checked answer for How to import a module given the full path?.

import time
import sys
import visa # Used for commands later in the GUI.
import os
from pygame.locals import *
import pygame
#import eztext
import imp
foo = imp.load_source('module.eztext','C:/Python27/src/eztext/eztext.py')
foo.Input()
pygame.init()

#... Later on in the code; skipping source commentary and version history
# Declare Global Variables
global serialnum
serialnum = "default" # Init value

#... skip to creation of PyGame object.
gameDisplay = pygame.display.set_mode(1000,750)

#... Later on in the code; the instance of using the function from <eztext.py>
def PopupOne():
  intro = True

  #... Skip error-trapping segment.
  global serialnum
  serialnumField = eztext.Input(maxlength=45,color=(255,0,0),prompt='Serial#:')

  # Capture Events for this Field.
  events = pygame.event.get()
  serialnum = serialnumField.update(events)

  # Draw and position the Field [indicates preference of Eztext over Text_Input, due to built-in functions]
  serialnumField.set_pos(150,200)
  serialnumField.draw(gameDisplay)

  #... skip ahead to the end of the Method
  pygame.display.update()
# End of <PopupOne()>

Now, for the issues that I see on Run---this is the output from IDLE (slight alterations to filepath of for anonymity):

Warning (from warnings module):
 File "C:/Python27/src/eztext/eztext.py", line 2
  from pygame.locals import *
RuntimeWarning: Parent module 'module' not found while handling absolute import

Warning (from warnings module):
 File "C:/Python27/src/eztext/eztext.py", line 3
  import pygame, string
RuntimeWarning: Parent module 'module' not found while handling absolute import

Traceback (most recent call last):
 File "Z:\******\Programming\PyGame\pg_sys_master2.py", line 22, in <module>
foo.Input()
 File "C:/Python27/src/eztext/eztext.py", line 25, in __init__
  ['maxlength', '-1'], ['prompt', '\'\''],['focus','False'])
 File "C:/Python27/src/eztext/eztext.py", line 13, in __init__
  else: exec('self.'+key[0]+' = '+key[1])
 File "<string>", line 1, in <module>
error: font not initialized
>>>

My query: Has Python 2.7.13 changed to the point where the approach mentioned in 67631, linked above, is no longer valid? Am I limited to copy-paste the contents of into my Main file?

phd
  • 82,685
  • 13
  • 120
  • 165
  • Since I'm still so new here, I had to edit the links into here; [1]: http://pyvisa.readthedocs.io/en/stable/getting.html [2]: https://www.pygame.org/wiki/GettingStarted#Pygame%20Installation [3]: https://git-scm.com/download/win [4]: https://anthony-tuininga.github.io/cx_Freeze/ [5]: https://github.com/ffavela/eztext [6]: https://github.com/Nearoo/pygame-text-input [7]: http://www.pygame.org/project-EzText-920-.html [8]: http://pygame.org/project-Pygame+Text+Input-3013-5031.html – Thomas Solley Aug 11 '17 at 20:58
  • [9]: https://www.reddit.com/r/Python/comments/2crput/how_to_install_with_pip_directly_from_github/ [10]: https://stackoverflow.com/questions/11835396/why-egg-foo-when-pip-installing-from-git-repo [11]: https://stackoverflow.com/questions/35991403/python-pip-install-gives-command-python-setup-py-egg-info-failed-with-error-c [12]: https://i.stack.imgur.com/H4NTp.png [13]: https://i.stack.imgur.com/E3QRM.png – Thomas Solley Aug 11 '17 at 20:59
  • All theese links should be in the post. Please [edit] your question. See [help on formatting](https://stackoverflow.com/help/formatting). – phd Aug 11 '17 at 21:34
  • Hi, I don't have enough reputation to put more than 2 links into my original; I had to reserve those for the images.. – Thomas Solley Aug 14 '17 at 12:08

1 Answers1

0

eztext has setup.py that doesn't install it but merely compiles using cx_Freeze. pygame-text-input doesn't have setup.py at all. Hence both packages are not suitable for installation with pip. git clone them ind manually copy to your site-packages.

phd
  • 82,685
  • 13
  • 120
  • 165