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?

4

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.