Tkinter layout changes from Spyder to Command Prompt - python-3.x

I have built a simple GUI in tkinter that goes through an algorithm to fit Radial Velocity data. Everything works fine in Spyder, however when I try to run the file in command prompt the GUI's dimensions change drastically. This is how it is supposed to look and how it looks in Spyder. This is how it looks when it's run in command prompt. The plots that are produced show the same behavior described. I've tried setting all the windows in Tkinter so that they are unable to be resized. I'm not sure what else to try. Is there a way to fix this? I am on Windows 10 64bit, Python 3.5.4, and Spyder 3.2.5.

I found out what the problem was. It's due to the fact that Spyder automatically overrides high DPI scaling, whereas both Python.exe and Pythonw.exe do not. The solution was to check the 'Override High DPI Scaling behavior' option under the compatibility tab for both python.exe and pythonw.exe.

Related

matplotlib randomly shows no plot in figure window

I am using Python 3.8.16 on Ubuntu 18.04.6 LTS and work with matplotlib 3.6.2, but do not use Jupyter in this case. When I plot a graph with matplotlib, sometimes happens that I get the figure window, but without any content, except the window title "Figure 1". I cannot close the figure with "q", and usually cannot break the execution with ctrl C, however ctrl \ usually works. When I run the program again, usually everything is fine. I would say that the probability, that the plot will be shown properly is around 80-90%. I had the same behaviours with Python 3.7 and with previous versions of matplotlib - seems it is not version specific. The problem occures in diferent programs. The matplotlib.get_backend() command returns TkAgg, and the posts in discussion groups suggest it is ok in case of Ubuntu. I couldn't find any solutions on internet forums so would appreciate any hint.

How to get terminal size in Spyder?

I am trying to get the terminal size using the function shutil.get_terminal_size().
This works well in a Python console or an Ipython console, but not in the Ipython console inside the Spyder editor, and I don't understand why.
Any ideas ?
Thanks in advance!
(Spyder maintainer here) Spyder consoles are not "real" consoles, i.e. they are not based on the same technologies as those used in terminal-based consoles (such as cmd.exe or Terminal.app). Therefore, shutil.get_terminal_size() doesn't work as expected.
Actually, our console's width is fixed at 80 characters and right now (October 2020) that limit can't be changed.

How can Pycharm (with matplotlib) show me my graphs in the same Py charm, next to my code?. Not in additional windows

i am using Matplotlib with Pycharm in a Mac osx. When I am making a graph, and I code plt.show() pycharm opens another window. And if there is 2 graphs, to see the 2nd one I have to close the first one. And I want to see both together.
There is a option to show the two graph in the same window, where my code is?
Thanks very much.
This link may help:
IPython magic commands
Using Jupyter notebooks you can achieve what you want by using %matplotlib inline. It seems from the link above that PyCharm may have some way to enable this same functionality.
See also: Inline plots in the scientific view

running a Program from vim that opens another window messes up the formating of my terminal

Im using vim inside a gnome-Terminal to edit a Python Program. Im also using a tiling Window manager calles awesome-wm.
Inside my Python program im plotting some data to a matplotlib graph (when executed that opens another window). When i want to test my Program i use the following comand to run the Program from inside of vim.
:!python3 %
when the Program runs it prints three messages to the shell and opens a matplotlib window to plot the data.
Sometimes i can only see the messed up linebreaks and have to scroll up to see the messages.
My question now is why is the formating inside the console messed up an how do i fix it?
My guess would be that the Terminal Window does not notice that it is beeing resized when the plot window is beeing opend, but i dont know how to refresh the terminal in that case.
using :!clear; python3 % does not help.
Thanks in advance.
(Well, it isn't a direct solution to your problem, but here it goes.)
Most terminal don't handle reflow in resize properly. There is no right ways to do it so most don't attempt to pull all the tricks in the book to make this better. After all, for classic floating window manger, resizing isn't something you do very often. LibVTE/Gnome-terminal isn't designed for tiling WMs and has not been patched over the years to make it better.
Urxvt is probably the most common terminal for AwesomeWM (the default is xterm because it is much more commonly installed by default). It has more advanced features like tabs and transparency you expect from modern terminals. Note that some of them (tabs) are disabled by default.
Sometime using software like tmux can be used to mitigate some of the limitations of any given terminal, but it comes with limitations of its own.

Terminal output is invisible

I've just installed Xmonad as my windows manager for Linux Mint 16. Its working fine except for one thing, there is no visible output when using terminal.
For example if I launch Firefox via terminal, the program loads up fine. However there is no output in terminal to show I have done this. Its as if the terminal output is being written in black rather than white.
Another example to more clearly illustrate my point, if I press the up arrow key, none of my previous executed input is shown.
I haven't touched any config files, its a clean install of Xmonad.
Any help would be appreciated. Again i've tried searching for the issue on Google but couldn't find anything.
SOLVED. Terminal was changing the output font to black due to the Xmonad settings. Solved by changing the terminal colour scheme to explicit white on black rather than system default.

Resources