From bob at passcal.nmt.edu Mon May 1 13:12:43 2017 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 1 May 2017 11:12:43 -0600 Subject: [Tkinter-discuss] Dragging and dropping into a database Message-ID: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> 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! From klappnase at web.de Mon May 1 14:09:05 2017 From: klappnase at web.de (Michael Lange) Date: Mon, 1 May 2017 20:09:05 +0200 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> Message-ID: <20170501200905.5501d418e46d8dd54fa01ffd@web.de> Hi, On Mon, 1 May 2017 11:12:43 -0600 Bob Greschke 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 From bob at passcal.nmt.edu Mon May 1 14:39:10 2017 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 1 May 2017 12:39:10 -0600 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <20170501200905.5501d418e46d8dd54fa01ffd@web.de> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> <20170501200905.5501d418e46d8dd54fa01ffd@web.de> Message-ID: <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> > On 2017-05-01, at 12:09, Michael Lange wrote: > > Hi, > > On Mon, 1 May 2017 11:12:43 -0600 > Bob Greschke 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? > > 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 Hi Michael! Yeah, quickly searching went right to tkdnd. We're still Python2, so no problem there. I'm starting to think that copy and paste into a window may be the only option, but I'm not sure what Xming/XQuartz will do with the file. Oh, well, I Command-C'ed a text file on my Mac to a Toplevel in the program with Ctrl-V and the file name was typed in the Text(). That's cute. :) "Paste" didn't even show up in the XQuartz Edit menu after the Command-C. This may just not be possible. I guess I could give everyone a little utility that produces a uuencode'd file from their .gif, or whatever, on their Desktop, and then they copy and paste the contents of that into a program's Toplevel/Text() after opening it with their favorite text editor. Then select a menu item to suck in whatever it was they pasted. Are users that smart? Dang. ;) Thanks! From klappnase at web.de Tue May 2 05:45:45 2017 From: klappnase at web.de (Michael Lange) Date: Tue, 2 May 2017 11:45:45 +0200 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> <20170501200905.5501d418e46d8dd54fa01ffd@web.de> <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> Message-ID: <20170502114545.1912cff105befaab998d1fbd@web.de> Hi, On Mon, 1 May 2017 12:39:10 -0600 Bob Greschke wrote: (...) > > Yeah, quickly searching went right to tkdnd. We're still Python2, so no > problem there. > > I'm starting to think that copy and paste into a window may be the only > option, but I'm not sure what Xming/XQuartz will do with the file. > > Oh, well, I Command-C'ed a text file on my Mac to a Toplevel in the > program with Ctrl-V and the file name was typed in the Text(). That's > cute. :) "Paste" didn't even show up in the XQuartz Edit menu after the > Command-C. This may just not be possible. > > I guess I could give everyone a little utility that produces a > uuencode'd file from their .gif, or whatever, on their Desktop, and > then they copy and paste the contents of that into a program's > Toplevel/Text() after opening it with their favorite text editor. Then > select a menu item to suck in whatever it was they pasted. > > Are users that smart? Dang. ;) Maybe you could set up some minimalist file browser from which they could pick a file, copy the (uuencoded) contents to the clipboard and then paste this into the window on the other side. If "the other side" detects uuencoded data it might display an icon instead of bothering the users with a portion of cryptic looking text and handle the text data somehow internally. Not sure if this is possible, but if it is, it might be more intuitive to use. Maybe this could even be done with DnD :) Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 From greg.ewing at canterbury.ac.nz Tue May 2 01:58:07 2017 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 02 May 2017 17:58:07 +1200 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> <20170501200905.5501d418e46d8dd54fa01ffd@web.de> <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> Message-ID: <59081FEF.7040904@canterbury.ac.nz> Bob Greschke wrote: > I guess I could give everyone a little utility that produces a uuencode'd > file from their .gif, or whatever, on their Desktop, and then they copy and > paste the contents of that into a program's Toplevel/Text() What's wrong with giving the user a tk file chooser to select the file? -- Greg From bob at passcal.nmt.edu Tue May 2 10:28:19 2017 From: bob at passcal.nmt.edu (Bob Greschke) Date: Tue, 2 May 2017 08:28:19 -0600 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <59081FEF.7040904@canterbury.ac.nz> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> <20170501200905.5501d418e46d8dd54fa01ffd@web.de> <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> <59081FEF.7040904@canterbury.ac.nz> Message-ID: <565A56F7-766C-4122-AC5E-CB91400356A8@passcal.nmt.edu> > On 2017-05-01, at 23:58, Greg Ewing wrote: > > Bob Greschke wrote: >> I guess I could give everyone a little utility that produces a uuencode'd >> file from their .gif, or whatever, on their Desktop, and then they copy and >> paste the contents of that into a program's Toplevel/Text() > > What's wrong with giving the user a tk file chooser to select the file? > > -- > Greg Hi! Oh, because the Python/Tkinter program isn't running on the user's machine. It's actually running on the remote server, so any files they can select will only be on the server. I'm trying to get a file on, let's say, their ~/Desktop. Bob From bob at passcal.nmt.edu Tue May 2 10:30:48 2017 From: bob at passcal.nmt.edu (Bob Greschke) Date: Tue, 2 May 2017 08:30:48 -0600 Subject: [Tkinter-discuss] Dragging and dropping into a database In-Reply-To: <20170502114545.1912cff105befaab998d1fbd@web.de> References: <351A386B-5A6B-44BA-800B-9750BCE19B26@passcal.nmt.edu> <20170501200905.5501d418e46d8dd54fa01ffd@web.de> <26C16E8B-371A-48C9-98D7-865B9ABE3E8C@passcal.nmt.edu> <20170502114545.1912cff105befaab998d1fbd@web.de> Message-ID: <755E4DB1-9686-4E9B-8D8A-8256B9D9F09F@passcal.nmt.edu> > On 2017-05-02, at 03:45, Michael Lange wrote: > > Hi, > > On Mon, 1 May 2017 12:39:10 -0600 > Bob Greschke wrote: > > (...) >> >> Yeah, quickly searching went right to tkdnd. We're still Python2, so no >> problem there. >> >> I'm starting to think that copy and paste into a window may be the only >> option, but I'm not sure what Xming/XQuartz will do with the file. >> >> Oh, well, I Command-C'ed a text file on my Mac to a Toplevel in the >> program with Ctrl-V and the file name was typed in the Text(). That's >> cute. :) "Paste" didn't even show up in the XQuartz Edit menu after the >> Command-C. This may just not be possible. >> >> I guess I could give everyone a little utility that produces a >> uuencode'd file from their .gif, or whatever, on their Desktop, and >> then they copy and paste the contents of that into a program's >> Toplevel/Text() after opening it with their favorite text editor. Then >> select a menu item to suck in whatever it was they pasted. >> >> Are users that smart? Dang. ;) > > Maybe you could set up some minimalist file browser from which they > could pick a file, copy the (uuencoded) contents to the clipboard and then > paste this into the window on the other side. If "the other side" detects > uuencoded data it might display an icon instead of bothering the users > with a portion of cryptic looking text and handle the text data somehow > internally. Not sure if this is possible, but if it is, it might be more > intuitive to use. Maybe this could even be done with DnD :) > > Regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Extreme feminine beauty is always disturbing. > -- Spock, "The Cloud Minders", stardate 5818.4 > Someone should be paying you. :) That would be better. I think I can do this. I've never stuck things on the clipboard from Python before, but I'll figure it out. Thanks! (Again!) Bob