[wxPython] Grid to Execl paste

Hello wxPython users :slight_smile:

Is there an esay way to make a copy/cut-paste from our (wxPythons) grid
to MS Execl ?
May be someone has implamented it or can give me some hints on how to do
it ?

Thankx

Przemek

路路路

--
Przemyslaw G. Gawronski
UIN:8358522
mailto:gawronskip@usa.net
mailto:gawron@obop.com.pl

If you place tab-delimited text on the clipboard from your grid and then paste that into Excel, the right thing will happen.

If you need more details, let me know and I will try and dig up some sample code.

-greg

路路路

At 10:14 AM 7/4/2000 +0200, you wrote:

Hello wxPython users :slight_smile:

Is there an esay way to make a copy/cut-paste from our (wxPythons) grid
to MS Execl ?
May be someone has implamented it or can give me some hints on how to do
it ?

----
greg Landrum (greglandrum@earthlink.net)
Software Carpenter/Computational Chemist

Hi

Well, at least for importing data from Excel, the following seems to work
for me: (I apologize in advance for the fact that this code fragment is not
self-contained, but it should shed SOME (although I guess not necessarily a
HUGE amount of...!) light on the problem...)

def GetColumnsFromClipboard(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽extrastring="Please enter the numbers of the two
"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"columns of interest"):
聽聽聽聽if wxTheClipboard.Open():
聽聽聽聽聽聽聽聽data = wxTextDataObject()
聽聽聽聽聽聽聽聽if not wxTheClipboard.GetData(data):
聽聽聽聽聽聽聽聽聽聽聽聽dlg = wxMessageDialog(frame,"Unable to get text from the "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"clipboard...", "Clipboard error",wxOK)
聽聽聽聽聽聽聽聽聽聽聽聽wxTheClipboard.Close()
聽聽聽聽聽聽聽聽聽聽聽聽dlg.ShowModal()
聽聽聽聽聽聽聽聽聽聽聽聽return
聽聽聽聽聽聽聽聽wxTheClipboard.Close()
聽聽聽聽聽聽聽聽# now data.GetText () is the data that was copied to the
clipboard...
聽聽聽聽聽聽聽聽# If this consists of text of more than two columns, then we want to
聽聽聽聽聽聽聽聽#receive a certain amount of direction from the user, to wit which
聽聽聽聽聽聽聽聽#of the columns actually contain the relevant data...
聽聽聽聽聽聽聽聽s = data.GetText()
聽聽聽聽聽聽聽聽m = re.search(r'.+', s)
## print "First line of data on clipboard contains the words: ",\
## string.split(m.string[m.start(0):m.end(0)])
聽聽聽聽聽聽聽聽w = len(string.split(m.string[m.start(0):m.end(0)]))
# print w,"columns counted to the clipboard data"
聽聽聽聽聽聽聽聽if w < 2:
聽聽聽聽聽聽聽聽聽聽聽聽dlg = wxMessageDialog(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"There appear fewer than the necessary "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"two columns to the clipboard data, at "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"least based on the first non-blank line.
"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Are you sure that the correct data has "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"been copied to the clipboard?",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Clipboard error",wxOK)
聽聽聽聽聽聽聽聽聽聽聽聽dlg.ShowModal()
聽聽聽聽聽聽聽聽聽聽聽聽return

聽聽聽聽聽聽聽聽column1,column2 = 1,2

聽聽聽聽聽聽聽聽if w > 2:
聽聽聽聽聽聽聽聽聽聽聽聽rexec_instance = rexec.RExec()
聽聽聽聽聽聽聽聽聽聽聽聽repeat = ""
聽聽聽聽聽聽聽聽聽聽聽聽while 1:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dlg = wxTextEntryDialog(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"%sThe data on the clipboard "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"appears to have"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽" %d columns [at "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"least \nbased on the first non-blank
line)."
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽" \n%s\n(as a comma-separated "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"list of numbers)." %
(repeat,w,extrastring),
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Which columns?",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"1,%d" % w,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wxOK | wxCANCEL)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if dlg.ShowModal() == wxID_CANCEL:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dlg.Destroy()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽return
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽columns = dlg.GetValue()
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dlg.Destroy()
# column1,column2 = rexec_instance.r_eval('(' + columns +
')');break
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽try:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽column1,column2 = rexec_instance.r_eval('('+columns+')')
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Errors.InformationalMessagesWindow('column1,column2 '
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽'= %d,%d\n'
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽% (column1,column2))
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽except:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽repeat = "There was an error interpreting your comma-"\
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"separated values (%s)...\n"\
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Please re-enter them.\n\n" % columns
聽聽聽聽聽聽聽聽def myatof(s):
# try:
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽return string.atof(s)
## except:
## return 0.
聽聽聽聽聽聽聽聽try:
聽聽聽聽聽聽聽聽聽聽聽聽a = reshape(array(map(myatof,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽string.split(s[m.start():]))),
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(-1,w))
聽聽聽聽聽聽聽聽聽聽聽聽# ...rather inefficient!
# print a
聽聽聽聽聽聽聽聽聽聽聽聽b = take(a,(column1 - 1,column2 - 1),1)
# print b
聽聽聽聽聽聽聽聽聽聽聽聽Errors.InformationalMessagesWindow("Data read from clipboard:
%s\n"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽% `b`)
聽聽聽聽聽聽聽聽聽聽聽聽return b

聽聽聽聽聽聽聽聽except:
聽聽聽聽聽聽聽聽聽聽聽聽Errors.NonFatalError(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"There was an error in attempting to use "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"the data on the clipboard...<p>Just "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"for interest, this data on the clipboard
is:"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"<p><pre>%s</pre>" % s,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tback=1)
聽聽聽聽聽聽聽聽聽聽聽聽return None

def GeometryImport(frame):
聽聽聽聽data = GetColumnsFromClipboard(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Please enter the columns containing the
"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"relevant geometry data (i.e., the
column\n"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"of the distance coordinate along the "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"seam, followed by that describing the\n"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"thickness of the material (e.g.,
coal).")
聽聽聽聽if data is None:# i.e., the user selected Cancel when asked about
columns
聽聽聽聽聽聽聽聽return

聽聽聽聽pr = frame.problem
聽聽聽聽pr.UnSaved = 1
## pr.SmallestThickness = min(transpose(data[:,1]))
## pr.LargestThickness = max(transpose(data[:,1]))
## sortedthicknesses = sort(transpose(data[:,1]))
## pr.ThicknessDelta = min(sortedthicknesses[:-1] -
sortedthicknesses[1:])
聽聽聽聽pr.SeamGeometry = PLFunc(data[:,0], data[:,1])
聽聽聽聽#pr.SetupGeometryAndSite(frame)
聽聽聽聽dlg = HTMLDialog.HTMLDialog(frame,
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽caption="Geometry imported from clipboard.",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽text="A set of geometry data for the seam
`%s'"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽" has been pasted from the clipboard. You "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"may view/edit this data by selecting the "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"appropriate tab of the left-hand portion "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"of the program window.<p>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Please note that the cumulative mass versus
"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"thickness data (which may just be "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"some randomly selected data) is probably "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"meaningless for this new seam geometry--"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"therefore, you will "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"Probably not be able to begin "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"computations without error "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"until a new CMVT data set has "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"entered. (If you just imported a CMVT "
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"data set, please ignore this message.)",
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽pythonpowered=0)
聽聽聽聽dlg.ShowModal()
聽聽聽聽dlg.Destroy()

聽聽聽聽pr.SetupGeometry(frame,newgeometry=1)
聽聽聽聽pr.SetupGeometryAndSite(frame)

Cheerio, Chris

路路路

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Przemys艂aw G.
Gawro艅ski
Sent: Tuesday, 4 July 2000 6:15 PM
To: wxpython-users@wxwindows.org
Subject: [wxPython] Grid to Execl paste

Hello wxPython users :slight_smile:

Is there an esay way to make a copy/cut-paste from our (wxPythons) grid
to MS Execl ?
May be someone has implamented it or can give me some hints on how to do
it ?

Thankx

Przemek

--
Przemyslaw G. Gawronski
UIN:8358522
mailto:gawronskip@usa.net
mailto:gawron@obop.com.pl

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

Big thanks !!!

Przemek

路路路

--
Przemyslaw G. Gawronski
UIN:8358522
mailto:gawronskip@usa.net
mailto:gawron@obop.com.pl