EzText 和 PyGame 模块Text_Input Pip-Git 错误 &&Direct imp.load_source()



我正在尝试为工作中的项目构建一个GUI;这个GUI的一个要求是它必须为用户提供字段来扫描条形码中包含的重要数据。我正在捕获每个字段的结果并将其存储在全局变量中,以便稍后保存到 CSV 中。

由于 PyGame 1.9.3 似乎没有内置的文本字段模块,因此我尝试使用当前可用的两个第三方系统;"EzText"和"Text_Input"。但是,我在计算机上安装这两个时遇到了问题(我运行的是Windows 7 SP1,64位(。

以下是上下文的概要: 在执行了 PyVisa(1(、PyGame(2(、Git(3( 32 位和 cx_Freeze(4( 的安装后,我尝试对 Eztext 和 Text_Input 进行 pip-install,因为 Ez 和 TI 的 GitHub(a(5(、b(6(( 或 Pygame(a(7(,b(8(( 页面都没有特殊的安装说明。执行此操作的说明我从这里(9(,这里(10(和这里(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

两次尝试的结果输出大致相同(考虑到 Github 地址和模块名称的差异(: 点差错误 1 (12( 点差错误 2 (13(

从那以后,我一直在尝试做一个 or 文件,其中构建了我正在寻找的类函数。为此,我遵循了如何在给定完整路径的情况下导入模块的检查答案。

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()>

现在,对于我在 Run--- 上看到的问题,这是 IDLE 的输出(为了匿名而对文件路径进行了轻微更改(:

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:******ProgrammingPyGamepg_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
>>>

我的查询: Python 2.7.13 是否已经更改为上面链接的 67631 中提到的方法不再有效?我是否只能将 的内容复制粘贴到我的主文件中?

eztext 有setup.py它没有安装它,而只是使用 cx_Freeze 进行编译setup.py。因此,这两个软件包都不适合与pip一起安装。git clone它们手动复制到您的site-packages

最新更新