[Tkinter-discuss] Dragging and dropping into a database

Bob Greschke bob at passcal.nmt.edu
Mon May 1 13:12:43 EDT 2017


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.

Thanks!



More information about the Tkinter-discuss mailing list