Re: tksheet - Copy and Paste with headers
在 2023/4/15 2:33, angela vales 写道: Hello All, I found this small group in a google search, so not sure if it is still active but giving it a try nonetheless. I have recently created a tkinter app and need the ability to copy and paste data from tksheet table into an Excel file. I do have a button for export, but it will be beneficial to also allow the user to simply copy,paste. I have enabled the appropriate bindings but cannot find a solution to also copy the header information during the copy and paste. My table is generated after a query is run. Here is a small snippet. df = pd.read_sql_query(query, conn) results_table.set_sheet_data(df.values.tolist()) results_table.headers(df.columns.tolist()) results_table.enable_bindings( "drag_select", "select_all", "column_drag_and_drop", "row_drag_and_drop", "column_select", "row_select", "arrowkeys", "right_click_popup_menu", "copy", "paste", "undo" ) best Angela Vales I am not sure how to solve your problem. The newsgroup may not be able to wait for an answer, so I suggest that you go to Stack Overflow to ask questions after conducting a thorough Google search. Of course, you can also wait for someone who knows the answer to come and answer:D -- https://mail.python.org/mailman/listinfo/python-list
Re: tksheet - Copy and Paste with headers
> 在 2023/4/15 2:33, angela vales 写道: >> I have recently created a tkinter app and need the ability to copy and > paste data from tksheet table into an Excel file. First thanks for drawing my attention to tksheet. I've long been desiring a decent table widget in tkinter and was on the verge of trying to create one of my own. tksheet looks like it will do all I need. As to copy/paste I couldn't see any explicit mention but it does say the underlying data is in a Tk Canvas so it may be that copy/paste will just work, did you try it? What happened if you paste into a text editor in the first instance? And Excel in the second? If all else fails you can probably write handlers and bind to Ctrl-C and Ctrl-V to do something yourself that mimics cut/paste. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: tksheet - Copy and Paste with headers
On 4/16/2023 9:01 AM, Alan Gauld wrote: 在 2023/4/15 2:33, angela vales 写道: I have recently created a tkinter app and need the ability to copy and paste data from tksheet table into an Excel file. First thanks for drawing my attention to tksheet. I've long been desiring a decent table widget in tkinter and was on the verge of trying to create one of my own. tksheet looks like it will do all I need. As to copy/paste I couldn't see any explicit mention but it does say the underlying data is in a Tk Canvas so it may be that copy/paste will just work, did you try it? What happened if you paste into a text editor in the first instance? And Excel in the second? If all else fails you can probably write handlers and bind to Ctrl-C and Ctrl-V to do something yourself that mimics cut/paste. I have not used tksheet, but in its documentation at https://github.com/ragardner/tksheet/wiki#14-getting-selected-cells, there is the method get_currently_selected() Returns namedtuple of (row, column, type_) e.g. (0, 0, "column") type_ can be "row", "column" or "cell" There are companion methods for rows, columns, etc. That would be a good starting point. -- https://mail.python.org/mailman/listinfo/python-list
Re: tksheet - Copy and Paste with headers
On 4/14/23 14:33, angela vales wrote: I have recently created a tkinter app and need the ability to copy and paste data from tksheet table into an Excel file. I do have a button for export, but it will be beneficial to also allow the user to simply copy,paste. I have enabled the appropriate bindings but cannot find a solution to also copy the header information during the copy and paste. the csv export code runs through a different path than the ctrl_c code, one operating on the sheet level, one on the main table level (I didn't dig in to the depths but my assumptions would be that main table doesn't mathematically consider the headers in the same way). def yield_sheet_rows in _tksheet.py vs def ctrl_c in _tksheet_main_table.py Comparing how the each path functions, without a larger redesign of tksheet, you could create a custom button press combo binding to something other than ctrl-c utilizing the yield_sheet_rows (or - disallow all other ctrl-c functionality in favor of ONLY a csv style everything dump when using ctrl-c): Import these: import csv as csv_module import io This would be your custom binding functionality: rows = self.sheet.yield_sheet_rows(get_header = True, get_index = False) s = io.StringIO() writer = csv_module.writer(s, dialect = csv_module.excel_tab, lineterminator = "\n") for row in rows: writer.writerow(row) self.clipboard_clear() self.clipboard_append(s.getvalue()) It would need something deeper if you wanted to integrate it to ctrl-c and keep the existing ctrl-c functionality -- https://mail.python.org/mailman/listinfo/python-list
Cannot install pkg_resources using pip
Python3-3.9.10 installed on this Slackware64-14.2 desktop. Trying to run meson to build an application I'm told it's missing pkg_resources, which is part of setuptools. The command fails: # pip install setuptools bash: /usr/bin/pip: /usr/bin/python3.7: bad interpreter: No such file or directory There is no python3.7 here: # ls /usr/bin/python3.7 ls: cannot access '/usr/bin/python3.7': No such file or directory How do I clean this up? TIA, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On 4/16/2023 4:42 PM, Rich Shepard wrote: Python3-3.9.10 installed on this Slackware64-14.2 desktop. Trying to run meson to build an application I'm told it's missing pkg_resources, which is part of setuptools. The command fails: # pip install setuptools bash: /usr/bin/pip: /usr/bin/python3.7: bad interpreter: No such file or directory There is no python3.7 here: # ls /usr/bin/python3.7 ls: cannot access '/usr/bin/python3.7': No such file or directory How do I clean this up? What is there to clean up? If you have Python 3.9 installed, why are you fooling around trying to run Python 3.7? It seems you are not telling us something ... It's better to always run pip with the version of Python that you intend to use. If that is launched when you type "python3", then run pip this way: python3 -m pip If instead you want to use, say, python3.9, then type this: python3.9 -m pip -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On Sun, 16 Apr 2023, Thomas Passin wrote: It worked then because your path found a pip script. When there are more than one Python installations, it can be unclear which one will get run, depending on how the path got set up after the last version was installed. Thomas, I probably last used pip with a python-3.7 version. To check your version of Python, run python3 -V $ python3 -V Python 3.9.10 Then try to run pip: python3.9 -m pip $ python3.9 -m pip /usr/bin/python3.9: No module named pip If pip has not been installed (very possible on Linux), then you will need to get it. If python3.9 is not the system-upgraded version, then do an internet search for "linux python install pip". There's a pip website that has an installer for it. I never remember what it's called, so I always have to search for it myself. https://www.redhat.com/sysadmin/install-python-pip-linux I'll download the installer from ther. If it appears that python3.9 *is* the version installed by the system, then use the system installer to install the right version of pip - as I said above, the package name can vary across distros. It should have been installed with the upgrade to 3.9.10 Your message doesn't seem to have been copied to the mailing list. If you don't mind, it could help other people if you copied it and this reply to the list. I always respond to the mail list if that's the 'reply to' address. Sometimes I don't check the address used in my reply, assuming it's correct. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On Sun, 16 Apr 2023, Rich Shepard wrote: I'll download the installer from there. But, I still cannot install the pkg_resources module that meson wants to start the build of pulseaudio-equalizer: # pip install pkg_resources ERROR: Could not find a version that satisfies the requirement pkg_resources (from versions: none) ERROR: No matching distribution found for pkg_resources Rich -- https://mail.python.org/mailman/listinfo/python-list
Fwd: pip is not installed
To whom it may concern, I have tried to reinstall, repair, and run in command prompt, but it seems as though pip won't install. I am using Windows 10 and Python 3.11.3. Are there any other suggestions for troubleshooting? Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: pip is not installed
On 2023-04-16 21:54, Khoinguyen Nguyen wrote: To whom it may concern, I have tried to reinstall, repair, and run in command prompt, but it seems as though pip won't install. I am using Windows 10 and Python 3.11.3. Are there any other suggestions for troubleshooting? Thank you. Have you tried using pip via the Python Launcher? py -m pip That's installed by default by the installer from python.org. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: pip is not installed
On 16Apr2023 16:54, Khoinguyen Nguyen wrote: I have tried to reinstall, repair, and run in command prompt, but it seems as though pip won't install. I am using Windows 10 and Python 3.11.3. Are there any other suggestions for troubleshooting? Have you tried invoking pip _via_ Python? This is actually the recommended approach because it uses the pip for that specific Python. Example: py -m pip install foo This invokes the "pip" module for thePython invoked by "py" (which I believe is how Python is normally invoked from a Windows command line), to install some package "foo". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On 4/16/2023 6:27 PM, Rich Shepard wrote: On Sun, 16 Apr 2023, Thomas Passin wrote: [snip] It should have been installed with the upgrade to 3.9.10 In my experience, on Windows pip is always included but on Linux hardly ever. I have always needed to install the system installer pip package or get it from the pip site, depending, as I wrote earlier, on whether your version of Python was installed by the system or not. [I'm no great Linux expert but I've had to go through this for probably a dozen VMs over the last few years]. -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On 4/16/2023 6:34 PM, Rich Shepard wrote: On Sun, 16 Apr 2023, Rich Shepard wrote: I'll download the installer from there. But, I still cannot install the pkg_resources module that meson wants to start the build of pulseaudio-equalizer: # pip install pkg_resources ERROR: Could not find a version that satisfies the requirement pkg_resources (from versions: none) ERROR: No matching distribution found for pkg_resources Rich Sorry, Rich, I've never dealt with this so someone else will have to give suggestions. I would try to see if there are any versions available. It could be that meson says it needs version x but only version y > x is available. Pip will quit but meson may very well work with the available version anyway. So I would try to install pkg_resources on its own, and then see if the meson build can succeed. No guarantees, but I've seen this work before. So python3.9 -m pip install --user pkg_resources Or, to see what versions if any are available: python3.9 -m pip install --user pkg_resources== # NO spaces allowed before the "==". There is a pip option to ignore the version specification and just leave the existing package installed as is, and this could help if the full installation wants to downgrade the pgk_resources that you just installed. You can also use the --dry-run option to see what would happen without actually changing anything. -- https://mail.python.org/mailman/listinfo/python-list
Re: Cannot install pkg_resources using pip
On 4/16/2023 6:27 PM, Rich Shepard wrote: If pip has not been installed (very possible on Linux), then you will need to get it. If python3.9 is not the system-upgraded version, then do an internet search for "linux python install pip". There's a pip website that has an installer for it. I never remember what it's called, so I always have to search for it myself. https://www.redhat.com/sysadmin/install-python-pip-linux I'll download the installer from ther. The page I was thinking of is https://pip.pypa.io/en/stable/installation/ I found it by an internet search for "pip installer". It covers several ways to install pip on Linux, MacOS, and Windows. On Linux, use it for Python installations that were *not* installed by the system. Use the package manager if the Python installation or upgrade *was* installed by the system. That Redhat link basically uses the pypa.io instructions. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: pip is not installed
On 4/16/2023 10:09 PM, MRAB wrote: On 2023-04-16 21:54, Khoinguyen Nguyen wrote: To whom it may concern, I have tried to reinstall, repair, and run in command prompt, but it seems as though pip won't install. I am using Windows 10 and Python 3.11.3. Are there any other suggestions for troubleshooting? Thank you. Have you tried using pip via the Python Launcher? py -m pip That's installed by default by the installer from python.org. To elaborate, Python might have been installed using an installer from python.org, from the Windows store, or in some other way. "py" may only be available for a python.org installer. In general, you would do best to always launch pip with the command pythonx -m pip where "pythonx" means the command that launches the version of python you want to work with. This might be "py", "python3.11", "py -3.11", or something else, so use what you will be using on your system. -- https://mail.python.org/mailman/listinfo/python-list