使用wxPython帮助打印 [英] HELP Printing with wxPython

查看:83
本文介绍了使用wxPython帮助打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正努力使用wxPython将一些简单的文本从

python打印到默认打印机,经过几天的互联网

搜索我找到了这个页面: http://wiki.wxpython.org/index.cgi /打印但是

是不可能使用这个脚本,即使我完全按照那里说的那样。我认为

脚本是有缺陷的,或者我无法使用它,即使看起来非常简单,也可以使用
...


任何人都可以给我一个关于如何轻松打印一些文字的提示吗?

是否有可以下载和使用的库?像SendPrinter(一些

text \ n)之类的东西?


如果有人能提供任何帮助,请提前致谢。


Mario

Hello all, I''m trying hard to make possible to print some simple text from
python to the default printer using wxPython, after days of internet
searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but
is impossible to use this script even if I do exactly as said there. I think
the script is buggy or I am not able to use it, even if seems very simple to
use...

Anyone can give me an hint on how to easily and simply print some text? Is
there a library ready to download and use? Something like SendPrinter("some
text\n")?

Thanks in advance if anyone can give any help.

Mario

推荐答案

>各位大家好,我正努力使用wxPython打印一些简单的文本

> Hello all, I''m trying hard to make possible to print some simple text
from
python到默认打印机,经过几天的互联网
搜索我找到了这个页面:
http://wiki.wxpython。 org / index.cgi / Printing 但是即使我完全按照那里所说,也不可能使用这个脚本。
我认为脚本有问题,或者我无法使用它,即使看起来非常简单易用b $ b ...

任何人都可以给我一个提示如何轻松简单地打印一些
的文字?是否有可供下载和使用的库?比如
SendPrinter(some text \\\
)?
python to the default printer using wxPython, after days of internet
searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but is impossible to use this script even if I do exactly as said there. I think the script is buggy or I am not able to use it, even if seems very simple to use...

Anyone can give me an hint on how to easily and simply print some text? Is there a library ready to download and use? Something like SendPrinter("some text\n")?




在严格的wxPython前面,我不能帮助

你,但我可能会提供一些帮助。

取决于你绑多少钱给wxPython
以及你多少钱需要跨平台。


基本上,如果你在Windows上(并且不需要

来运行其他任何东西)那么考虑一些这里的

解决方案:

http://tgolden.sc.sabren.com/python/...o_i/print.html


如果你是在Unix /任何不需要做的事情

其他任何东西,那么我肯定有直接的方式将东西推送到打印机。 (使用lpr的东西

他认为,希望有真正知识的人可以筹码

)。


如果你真的*想要使用wxPython进行跨平台

的需求,或者只是因为你认为它更干净,那么如果你还没有在wxPython列表上尝试




TJG



On the strict wxPython front, I can''t help
you, but I might be able to offer some help.
Depends a little bit on how much you''re tied
to wxPython and how much you need to be cross-platform.

Essentially, if you''re on Windows (and have no need
to run on anything else) then consider some of the
solutions here:

http://tgolden.sc.sabren.com/python/...o_i/print.html

If you''re on Unix / whatever with no need to do
anything else, then I''m sure there are straightforward
ways to push stuff to a printer. (Something using lpr
he thinks, hoping someone with real knowledge can chip
in).

If you *really* want to use wxPython for cross-platform
needs, or just because you think it''s cleaner, then try
on the wxPython lists if you haven''t already.

TJG


马里奥,


这是一个功能从使用printpreview的工作程序中删除
来自wxWindows的
从用户正在工作的网格中打印单元格

on。希望这可以指出你正确的方向。


问候,

拉里贝茨


def DO_printpreview(self ,事件):

if self._trace:

self.logf.writelines(" T",Entering OuterFrame.DO_printpreview)

self.SetStatusText(''生成打印预览'',0)



#定义打印输出上的列



columndefs =((" Cust#",8.0 / 16.0,wxALIGN_LEFT),

(" Customer Name",29.0 / 16.0,wxALIGN_LEFT),
(" Reference",16.0 / 16.0,wxALIGN_LEFT),

(" Type",6.0 / 16.0,wxALIGN_CENTRE),

(" Inv。#",8.0 / 16.0,wxALIGN_CENTRE),

(" InvDate",9.0 / 16.0,wxALIGN_CENTRE),

(" L#", 4.0 / 16.0,wxALIGN_CENTRE),

(" Item#",12.0 / 16.0,wxALIGN_CENTRE),

(" I tem Description",45.0 / 16.0,wxALIGN_LEFT),

(数量,6.0 / 16.0,wxALIGN_RIGHT),

(成本,10.0 / 16.0, wxALIGN_RIGHT),

(" OMMC
Mario,

Here is a function stripped from a working program that uses printpreview
from wxWindows to print out cells from a grid that the user is working
on. Hopefully this can point you in the proper direction.

Regards,
Larry Bates

def DO_printpreview(self, event):
if self._trace:
self.logf.writelines("T","Entering OuterFrame.DO_printpreview")
self.SetStatusText(''Generating Print Preview'', 0)
#
# Define the columns on the printout
#
columndefs=(("Cust#", 8.0/16.0, wxALIGN_LEFT),
("Customer Name", 29.0/16.0, wxALIGN_LEFT),
("Reference", 16.0/16.0, wxALIGN_LEFT),
("Type", 6.0/16.0, wxALIGN_CENTRE),
("Inv. #", 8.0/16.0, wxALIGN_CENTRE),
("InvDate", 9.0/16.0, wxALIGN_CENTRE),
("L#", 4.0/16.0, wxALIGN_CENTRE),
("Item #", 12.0/16.0, wxALIGN_CENTRE),
("Item Description",45.0/16.0, wxALIGN_LEFT),
("Qty", 6.0/16.0, wxALIGN_RIGHT),
("Cost", 10.0/16.0, wxALIGN_RIGHT),
("OMMC


",10.0 / 16.0,wxALIGN_RIGHT)



columncount = len(columndefs)



#为打印预览创建一个新框架并将其交给PrintTable



self.previewframe = PreviewFrame(无,sys.stdout)

如果self._trace:

log.writelines(" T"," DO_ppv-创建PrintTable实例")

prt = PrintTable(self.previewframe)



#设置打印输出列宽



if self._trace:self.logf.writelines(" T"," DO_ppv-Setting column widths")

prt.set_column = [ a [1] for a columndefs]



#设置列标签(标题)



如果self._trace:

self.logf .writelines(" T"," DO-ppv-Setting column headings")

prt.label = [a [0] for a columndef]



#设置列对齐



if self._trace:

self.logf.writelines(" ; T",DO-ppv-Setting column alignment")

map(prt.SetColAlignment,range(columncount),[a [2] for a columndef])



#从网格中获取所选数据的值



data = self._getdata(''1' ')



#跳过第一个(标志)列和列11,13,15,16

#将它们从打印输出。



data = [[v [1],v [2],v [3],v [4] [0:2],v [ 5],v [6],

v [7],v [8],v [9],v [10],v [12],v [14]]对于数据中的v]



#循环线并在客户之间插入一个空行



blankline = columncount * [''''#创建空白输出行

lastcustomer =无

pda ta = []

表示数据中的值:

if lastcustomer!= None和values [0]!= lastcustomer:

pdata.append (blankline)


lastcustomer = values [0]

pdata.append(values)


pdata.append (blankline)

prt.data = pdata

prt.left_margin = 0.3

prt.SetLandscape()

prt.SetHeader(OMMC回顾列表 - 硬件项目)

prt.SetFooter()

prt.SetFooter(" Date:",type ="日期&时间,\

align = wxALIGN_LEFT,\ nindent = prt.left_margin)



#覆盖默认字体大小



prt.text_font_size = 8

#prt.label_font_size = 7

prt.cell_left_margin = 1.0 / 32.0 <如果是self._trace:

self.logf.writelines(" T",Entering OuterFrame.DO_printpreview)
;)

返回

Mario写道:
", 10.0/16.0, wxALIGN_RIGHT)
)
columncount=len(columndefs)
#
# Create a new frame for the print preview and give it to PrintTable
#
self.previewframe=PreviewFrame(None, sys.stdout)
if self._trace:
log.writelines("T","DO_ppv-Creating PrintTable instance")
prt=PrintTable(self.previewframe)
#
# Set printout column widths
#
if self._trace: self.logf.writelines("T","DO_ppv-Setting column widths")
prt.set_column=[a[1] for a in columndefs]
#
# Set the column labels (headings)
#
if self._trace:
self.logf.writelines("T","DO-ppv-Setting column headings")
prt.label=[a[0] for a in columndefs]
#
# Set the column alignments
#
if self._trace:
self.logf.writelines("T", "DO-ppv-Setting column alignments")
map(prt.SetColAlignment, range(columncount), [a[2] for a in columndefs])
#
# Get the data values from the grid that are selected
#
data=self._getdata(''1'')
#
# Skip the first (flag) column and columns 11,13,15,16
# to delete them from the printout.
#
data=[[v[1],v[2],v[3],v[4][0:2],v[5],v[6],
v[7],v[8],v[9],v[10],v[12],v[14]] for v in data]
#
# Loop over the lines and insert a blank line between customers
#
blankline=columncount*[''''] # Create a blank output line
lastcustomer=None
pdata=[]
for values in data:
if lastcustomer != None and values[0] != lastcustomer:
pdata.append(blankline)

lastcustomer=values[0]
pdata.append(values)

pdata.append(blankline)
prt.data=pdata
prt.left_margin=0.3
prt.SetLandscape()
prt.SetHeader("OMMC Recap Listing-Hardware Items")
prt.SetFooter()
prt.SetFooter("Date: ", type = "Date & Time", \
align=wxALIGN_LEFT, \indent=prt.left_margin)
#
# Override the default font sizes
#
prt.text_font_size = 8
#prt.label_font_size= 7
prt.cell_left_margin = 1.0/32.0
prt.Preview()
if self._trace:
self.logf.writelines("T","Entering OuterFrame.DO_printpreview")
return
Mario wrote:
大家好,我正在努力打造一些简单的文字来自
python到使用wxPython的默认打印机,经过数天的互联网搜索后我找到了这个页面: http://wiki.wxpython.org/index.cgi/Printing 但即使我完全按照那里所说的那样使用这个脚本也是不可能的。我认为这个剧本是错误的,或者我无法使用它,即使看起来很简单也可以使用......

任何人都可以给我一个关于如何使用的提示轻松简单地打印一些文字?是否有可以下载和使用的库?像SendPrinter(some
text\ n)之类的东西?

如果有人能提供任何帮助,请提前致谢。

马里奥
Hello all, I''m trying hard to make possible to print some simple text from
python to the default printer using wxPython, after days of internet
searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but
is impossible to use this script even if I do exactly as said there. I think
the script is buggy or I am not able to use it, even if seems very simple to
use...

Anyone can give me an hint on how to easily and simply print some text? Is
there a library ready to download and use? Something like SendPrinter("some
text\n")?

Thanks in advance if anyone can give any help.

Mario



这篇关于使用wxPython帮助打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆