[Tkinter-discuss] Dragging and dropping into a database

Michael Lange klappnase at web.de
Mon May 1 14:09:05 EDT 2017


Hi,

On Mon, 1 May 2017 11:12:43 -0600
Bob Greschke <bob at passcal.nmt.edu> wrote:

> We have a Python/Tkinter inventory program that I wrote that users
> access using X-Windows (Xming, XQuartz, etc.). It can't directly access
> files on the users computer, of course, but cutting and pasting text
> into a Toplevel with a text widget in it does make that text available
> to the program. You can hit a Save button, the program will read the
> Text() and save it to the database, for example.
> 
> Could the same thing be done with a .gif or a .pdf file? If there was a
> Toplevel that was designed for dragging and dropping .gif/.png files
> to, could it "interpret" the dragged stuff in such a way that it could
> then take the info and turn it into let's say uuencode, display that in
> the window, then when the user hits a Save button that uuencoded text
> gets read, run through PhotoImage and saved in the database?
> 
> Actually, it might be nice to be able to do the same thing with a .csv
> file. Yearly we have to look for differences between a spreadsheet that
> "they" keep and what is in the inventory database. It's a manual labor
> thing. If the user could just drop the .csv into a window and run the
> comparison function on the resulting text that would be nicer than copy
> and paste. Right now the .csv has to be put in a specific place on the
> server (like by me) and then the comparison function executed. Adding
> pictures of items in the inventory is handled the same way. If I could
> access files on the remote (to the server) machines that would solve a
> bunch of things.
> 
> Dragging and dropping a file from 'outside' of a Toplevel would
> actually be like accessing the file on the users machine, wouldn't it?
> That doesn't sound good. Could the user copy and paste the file into
> the Toplevel?
> 
> I haven't even looked into dragging and dropping yet. That might be
> beyond my brain cell count as it is.

for drag and drop you might try the tkdnd wrapper from
http://tkinterdnd.sourceforge.net/
(it's pretty old Python2-code; from a quick glance I think that changing
the import line from
import Tkinter
into something like
try:
    import Tkinter
except ImportError:
    import tkinter as Tkinter
might be all that is needed to make it work with Python3 though)
With the tkdnd test script I can drop a bunch of filenames from Xfe onto a
Tk window here (Debian Jessie). However I am not sure if this helps you
any, since of course these files would still have to be read...

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

All your people must learn before you can reach for the stars.
		-- Kirk, "The Gamesters of Triskelion", stardate 3259.2


More information about the Tkinter-discuss mailing list