Quantcast
Channel: User Samuel - Stack Overflow
Browsing latest articles
Browse All 44 View Live

Comment by Samuel on Winforms Textbox - Using Ctrl-Backspace to Delete Whole...

Thanks for the tip! Apparently wxPython uses this control for a wx.TextEntry, which is inherited by things like wx.TextCtrl and wx.ComboBox. If you implement the AutoComplete method of wx.TextEntry it...

View Article



Comment by Samuel on Solve Equation (String) with Python to every Symbol

Thanks! FYI, if you want to get an equation back to a string (which was the original question) then you can use str(), like this: str(list(solve(sympy_eq).values())[0]).

View Article

Comment by Samuel on How to make a python, command-line program autocomplete...

Try readline = pyreadline.Readline(); readline.parse_and_bind("tab: complete");.

View Article

Comment by Samuel on Assign to variable exported from shared library via...

This corrects his SyntaxError, but it doesn't answer the main question of how to write to a variable in a shared object library from python. I tried ctypes.c_int.in_dll(lib, "value").value = 2 but it...

View Article

Comment by Samuel on How to suppress warning that gcc option is deprecated

I have the same question about the -I- option: github.com/att/ast/issues/20.

View Article


Comment by Samuel on Casting enum definition to unsigned int

"In your case the enum constant is int but you are giving it a value that does not fit in a int". But 1 << 31 does fit in an int, it equals 0x80000000 in hex, which is some negative value in...

View Article

Comment by Samuel on Double-click to select text in Windows Terminal selects...

This works, but unfortunately the selection doesn't wrap to the next line when you double click: github.com/microsoft/terminal/issues/6178

View Article

Comment by Samuel on Layout Management with wxPython

The Widget Inspection Tool is really helpful for debugging wxPython layout issues: wiki.wxpython.org/…

View Article


Comment by Samuel on How to obtain the total numbers of rows from a CSV file...

This doesn't work if you do len(list(csvfile)) followed by "for index, row in enumerate(csvfile):", the enumerate() doesn't return any entries.

View Article


Comment by Samuel on Is there a standard, how to pack non-byte-aligned bits...

I think you got the little and big numbers backwards in your last sentence, before the PS.

View Article

Comment by Samuel on Static assert in C

It can use memory.... That's not good.

View Article

Comment by Samuel on How do I download files from perforce to a location...

Genius. Instructions for setting up git p4 are here: stackoverflow.com/a/35360825/1045004

View Article

Comment by Samuel on "No such file or directory" but it exists

@meztelentsiga I was gettting an error when using objdump <file> without any parameters, I added -f to get it process the file, like so: objdump -f <file>

View Article


Comment by Samuel on How to set vscode to display the number of selected lines?

Ctrl + Alt + [Up | Down] enables a multi-line cursor for me (Shift + Alt copies a line). You can use Ctrl + Alt + [Up | Down] to count lines, which is nearly the same as Shift + Alt + I, except that...

View Article

Answer by Samuel for How to RSYNC a single file?

To date, two of the answers aren't quite right, they'll get more than one file, and the other isn't as simple as it could be, here's a simpler answer IMO.The following gets exactly one file, but you...

View Article


Answer by Samuel for Python exceptions - catching all exceptions but the one...

This worked for me:try:<code> raise Exception("my error")except Exception as e: raise eIf my error occurs then the error message "my errror" is seen. If an unknown exception occurs then it...

View Article

Answer by Samuel for Using python's wx.grid, how can you merge columns?

Your question mentioned using wx.Grid, but for those who don't need this, wx.GridBagSizer can be used instead. It allows items to span multiple columns and/or rows.

View Article


Answer by Samuel for ImportError: no module named win32api

The following should work:pip install pywin32But it didn't for me. I fixed this by downloading and installing the exe from here:https://github.com/mhammond/pywin32/releases

View Article

Answer by Samuel for Python argparse - disable help for subcommands?

Short answer, add "add_help=False" to ArgumentParser, like this:parser = argparse.ArgumentParser(add_help=False)This is from https://docs.python.org/2/library/argparse.html#add-help.

View Article

Answer by Samuel for converting large int list to byte string python

I needed to use struct.unpack() and it accepts a byte string rather than a list of ints. I was able to convert my list of ints to a byte string with:bytearray(mylist)Tested on python 2.7.

View Article

Answer by Samuel for How to redirect the output of the time command to a file...

If you want just the time in a shell variable then this works:var=`{ time <command> ; } 2>&1 1>/dev/null`

View Article


Answer by Samuel for How to translate the wslpath /home/user/ to windows path

To convert a WSL Linux path to a Windows path use wlspath -w. For example:$ wslpath -w /mnt/c/UsersC:\Users$ wslpath -w /usr/bin\\wsl$\Debian\usr\bin(Yep, the answer is in the question, but some...

View Article


Answer by Samuel for How to get the current cursor position in python readline

I downloaded the pyreadline source code and figured this out. The following works in pyreadline (Windows port of readline) on Python 2.7:from pyreadline import Readlinereadline = Readline()cursor =...

View Article

Answer by Samuel for Pip error: option --single-version-externally-managed...

I had this problem too. I was using the newest python to date, v3.9.5. From reading the Pyton.NET docs @ http://pythonnet.github.io/, I found that "Python.NET is currently compatible and tested with...

View Article

Answer by Samuel for Pip Pythonnet option --single-version-externally-managed...

This is mostly a duplicate of Pip Pythonnet option --single-version-externally-managed not recognized, just different platforms.I answered the question there. The answer for me was to use an older,...

View Article


Answer by Samuel for How to remove the 'resize triangle' from StatusStrip in...

From Stefanos's comment, do this:statusStripObject.SizingGrip = False

View Article

Answer by Samuel for Disable resizing of a Windows Forms form

None of these answers worked for me, perhaps because my window had a status bar. To fix I did this:StatusStripObject.SizingGrip = FalseThe same works for a StatusBar object,...

View Article

Answer by Samuel for Slicing a Python OrderedDict

I was able to slice an OrderedDict using the following:list(myordereddict.values())[start:stop]I didn't test the performance.

View Article

Answer by Samuel for wx.ListCtrl and column header tooltips

I couldn't find a way to do this for column headers, but this works for individual cells: self.lc = wx.ListCtrl(self, style=wx.LC_REPORT) # ... self.lc.Bind(wx.EVT_MOTION, self.OnMouseMotion)def...

View Article



Answer by Samuel for How to prevent exe created by pyinstaller from being...

PyInstaller does seem to be the most popular choice for converting a python script into an exe, but there are other choices:How do I convert a Python program to a runnable .exe Windows program?When I...

View Article

Answer by Samuel for show() method does not open window

For me I had some code like this:from matplotlib import pyplot as pltfigure = plt.Figure()axes = figure.add_subplot()axes.plot([1,2], [1,2])plt.show()plt.show() didn't block or do anything. If I...

View Article

Answer by Samuel for return value from python script to shell script

You can also use exit() without sys; one less thing to import. Here's an example:$ python>>> exit(1)$ echo $?1$ python>>> exit(0)$ echo $?0

View Article

Answer by Samuel for how to add white color to wxpython box

Replacing wx.Choice() with BitmapComboBox() and style=wx.CB_READONLY fixed the color issue for me. There's some odd fading in and out when changing the selection though (at least on Win 10). wxPython...

View Article


How to Reorder Commits (rebase) with TortoiseGit

I want to push several single commits to our main git repository. After doing some reading though it sounds like I have to reorder the commits in order to do this, because git will only push all...

View Article

GetOptions Check Option Values

I am updating an existing Perl script that uses GetOptions from Getopt::Long. I want to add an option that takes a string as its parameter and can only have one of 3 values: small, medium, or large. Is...

View Article

Answer by Samuel for Failed building wheel for pythonnet

Possible duplicates:Pip Pythonnet option --single-version-externally-managed not recognizedPip error: option --single-version-externally-managed not recognizedI answered the question @...

View Article


Answer by Samuel for fatal error : aux.h No such file or directory (Ubuntu)

You said you are using a Virtual Machine, so I assume Windows is your host. Windows doesn't allow files name aux*, but there are ways around it, e.g rename in WSL or cygwin... and perhaps a virtual...

View Article


Why does PyCharm use 120 Character Lines even though PEP8 Specifies 79?

PEP8 clearly specifies 79 characters, however, PyCharm defaults to 120 and gives me the warning "PEP8: line too long (... > 120 characters)". Did previous versions of PEP8 use 120 and PyCharm not...

View Article

Answer by Samuel for No module named usb.core

python -m pip install pyusb libusbFixed this for me.

View Article

Answer by Samuel for Git index.lock File exists when I try to commit, but I...

I had this problem with TortoiseGit with Cygwin on Windows. I wasn't able to delete remove ./.git/index.lock even with administrative privileges. I tried both Cygwin and a command prompt, but it said...

View Article

Answer by Samuel for wxPython panel color does not match with frame background

Here's another option:panel = wx.Panel(frame)panel.SetBackgroundColour(frame.GetBackgroundColour())

View Article


Answer by Samuel for Static assert in C

I'm surprised this one hasn't been mentioned:#define STATIC_ASSERT(condition, message) ((void)sizeof(char[1 - 2*!(condition)]))It does have the limitation that you can only use it in function scope,...

View Article

Answer by Samuel for How can I push a specific commit to a remote, and not...

The other answers are lacking on the reordering descriptions.git push <remotename> <commit SHA>:<remotebranchname>will push a single commit, but that commit has to be the OLDEST of...

View Article


Unable to Debug Multi-Threaded Application with gdb

I am debugging a multi-threaded application with gdb, but when I start the program in gdb I get the warning:warning: Unable to find libthread_db matching inferior's thread library, thread debugging...

View Article
Browsing latest articles
Browse All 44 View Live




Latest Images