python spyder editor change menu and font size - python

I have shared displays and the menu font size (e.g. File Edit Search ..) but also the font of the names of python files above the editor window, are really small, making it hard to read.
I looked in "Preferences" and elsewhere, but I don't find any option to modify the font size of menu and filenames (while it is easy to modify the editor python code font size).
I attach a screenshot for illustration.
Thanks for your help.
screenshot of the Spyder window: the menu font size is really small, while the editing Python font size can be increased

If your computer has a high-resolution screen, the menu in the interface is rather small.
This can be corrected by activating scaling for high-resolution screens in
tools/preferences/application/interface/.

Go to tools/preferences/application/interface/ and setup a high DPI scaling of 1

Related

Using ttk theme azure-dark and Changing background color of ttk combobox widget

I am using the ttk azure theme dark Azure-ttk-theme. It sets the background color to nice modern looking UI. However, as seen in the images the background color of the tk window, Text widget and combobox widget is set as same. This looks bad when we are using all these together with some text in area(as seen on the right side of screenshot below).
I tried to modify the background of my combobox as below(pardon the full imports- just for replication):
from tkinter import *
from tkinter.ttk import *
root = Tk()
style = ttk.Style(root)
root.tk.call("source", SYSTEM_DIR / "azure.tcl")
root.tk.call("set_theme", "dark")
style.configure("TCombobox", fieldbackground= "orange", background= "white")
g_combo = Combobox(root, style="TCombobox")
But, the above code does not have any effect on my interface. If someone has any idea on how I can handle this. I might have to modify the tcl file for this theme. Since, I have limited knowledge on tcl I am looking for answers/suggestions here.
Ahh, well, I am answering this question because I also tried using this theme yesterday. My idea was too something similar to yours. I wanted to change the default colors and stuff to get a better UI. Before getting into the solution, I have to tell you that this theme overrides the default values and designs to a custom-created one as set by the author. So here's what you can do to achieve what you want.
As far as I know, the only way to do this is to edit the TCL file, which manages the colors of the widgets. It would help if you had some idea about TCL language before you get into it so deep. So I will tell you step by step:
Go to dark.tcl file, and then find the widget's code where you want to change the background color. Say you want to change the combo box's background color. So if you are on windows, you can search "Combobox" by pressing ctrl+f after opening that file (I suggest using Notepad to edit it, it's more accessible).
Ok, so here are the codes where you want to change. As you can see in the third part of the code (ttk::style element create Combobox.field), it is used to create the combo box widget. You can keep trying changing different statements and customize the whole Combobox and its effects (If you know how to). But now lets focus on background color
So in there, you see that the default background is set to an image known as box-basic.
So now you have to go to Azure-ttk-theme/theme/dark folder and find out where that box-basic file is. Once you find it, you have to edit the colors of that image with respecting the same size and then replace the old one and make sure you set the same name. I suggest you to use figma to replicate another image. Its easy. Change it to any color you wish.
And you are done!
With some other theme fieldbackground would work, but not with Azure (or with any of my themes).
Tk handles PNG images containing transparency very badly, especially on Microsoft Windows.
So to reduce lagging, I removed the transparent areas of the image elements, and therefore where you'd expect fieldbackground to be, there's actually the images' background, which looks like as if it were fieldbg.
So the solution is to edit the images, as TechieGeeke suggested.

Changing font size of non 'plain text' and 'rich text' elements in Spyder interface

I'm new to Spyder, I have used the program several times but when I started it recently something seemed off. The font size of my file names and all the tabs are very big all of a sudden. In Tools -> Preferences -> Appearance, the font size of the 'plain text' and 'rich text' can be adjusted, but this doesn't affect the font size I try to alter.
Changing DPI settings also doesn't seem to help. Since I could not find anyone with the same question, I post it here. See attached screenshot, where I highlighted the text I want to make smaller.
Kind regards,
Billy
I had the same issue as you and it was solved by using Anaconda.
When you install Spyder via Anaconda, you can change the startup settings for Anaconda and they should propagate through to Spyder.
I found the answer by JarroVIGT (Spyder interface icons very small on high resolution screen in Windows 10) to be extremely helpful.
I tried both dpiawareness=0 and 1 and 1 worked for me.

HIGH DPI Tkinter re scaling when I run it in Spyder and when I run it direct in terminal

this is probably not much of a coding question.
I developed an application in Tkinter which consists pretty much in a canvas where I load images on (matplots).
When I run it from Spyder or Jupyter notebook I obtain 143 DPI and when I run it directly in terminal I obtain 95 DPI instead.
The most weird thing is that once I run it from terminal it shows as if it was a 143 DPI application but when I load the image the app decides to resize completely and then change the DPI of my screen. So the whole thing resizes, buttons, pop up boxes and etc...
It is very important to me that I can run it from terminal, because afterwards I will transform it into a .exe application.
My first approach was to use the tkinter method .winfo_fpixel() and try to ratio the DPIs and multiply it to every dimension in the application.
Later I tried to find python.exe and pythonw.exe in order to change the compatibility with HIGH DPI Scale.
Do you thing there is a way to solve this without resizing everything?
I would like to insist that I'm 100% sure this has nothing to do with the code, therefore I might not post any coding samples.
Thanks.
obs: I use Windows 10
ps: I tried to run the app with two screens, what happened was really funny, when I use it on an adequate screen it runs normally, but when I slide it to the other screen and make any action/event it will resize it automatically.
selbie's answer is correct.
Also,You could use winapi to set DPI aware in python directly(this could work in tkinter):
import ctypes, tkinter
try: # >= win 8.1
ctypes.windll.shcore.SetProcessDpiAwareness(2)
except: # win 8.0 or less
ctypes.windll.user32.SetProcessDPIAware()
root = tkinter.Tk()
....
MSDN doc: SetProcessDpiAwareness, MSDN doc: SetProcessDPIAware
And this is another answer which mentioned about DPI awareness.
DPI is largely influenced by your PC's resolution settings - specifically the setting on "Scale and layout". 100% is 96 DPI and 150% is 144 DPI. I'm guessing it's just a rounding error from your app that's showing 95 and 143. Laptops tend to have higher resolution screens, so OEM's default to >100% setting so that you don't have to squint to see your apps. Whereas, your typical 1080p display defaults to 100% DPI. But when you "remote desktop" into a PC, Windows may re-adapt and re-stretch the DPI settings to match the local display if its DPI and resolution are different.
Windows will auto-scale most applications that haven't explicitly set their "DPI awareness" with the OS. That's typically fine for most application (although they can appear "blurry"). Applications can be compiled to be dpi aware are not stretched except in certain multi-monitor situations. This is especially likely for graphics applications. And that's where bugs like the one you are seeing tend to show up. You can often change this behavior by right clicking on the EXE, clicking Properties, and finding the setting the compatibility tab:
The most weird thing is that once I run it from terminal it shows as if it was a 143 DPI application but when I load the image the app decides to resize completely and then change the DPI of my screen. So the whole thing resizes, buttons, pop up boxes and etc...
When you remoted into your PC, the system DPI changed. Applications can get confused - especially if they aren't adapting to a changing DPI setting. Or worse, the application registers with Windows that it is DPI aware, but doesn't handle the corner case of when the monitor is swapped out - which is effectively what happens when you remoted into it. You can however, override this behavior with some combination of the Properties dialog above and the available APIs to control dpi-awareness.
I don't much about TKinter (Does it use the Python process or is it its own exe?). If you can compile it yourself, you can use the various Windows APIs and manifest settings to get the DPI behavior you want. My shot in the dark guess is that TKinter( is declaring itself per-monitor dpi-aware, but has a bug that doesn't account for the DPI changing on the fly. Typical fix for this situation is to just restart the application.
Everything you need to know at the links below:
https://learn.microsoft.com/en-us/windows/desktop/hidpi/high-dpi-desktop-application-development-on-windows
https://learn.microsoft.com/en-us/windows/desktop/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness
https://msdn.microsoft.com/en-us/C9488338-D863-45DF-B5CB-7ED9B869A5E2
You can also read my previous answers regarding DPI awareness in Windows apps:
https://stackoverflow.com/search?q=user%3A104458+dpi

How do I configure Python IDLE's text font?

I've searched all over and can't seem to find a solution. Python's IDLE just looks terrible on my laptop (Lenovo Yoga 2 Pro) with a 3200x1800 display running 8.1
I've attached a screenshot so you can see what I'm talking about. Has anyone figured out how to configure this? Thanks for the help!
Add a file like %USERPROFILE%\.idlerc\config-main.cfg
Add the following lines:
[EditorWindow]
font-size = 14
font = monaco
Or pick your favorite font and size.
I presume 'terrible looking' applies to the old Courier (typewriter) font. IDLE's tk Text windows (Shell, Editor, and Output) default to using 10 point 'TkFixedFont'. On Windows, (and only on Windows), that resolves to 'Courier'. I believe that this is or at least used to be standard on Windows.
The best solution is to select Options on the top menu bar and then Configure IDLE. One is then presented with a dialog with the Fonts/Tabs tab selected and the current font selected in the Base Editor Font box and the current size next to Size. There is an example box showing some text in the current font and size. Change either the font or size and the example is updated. Select OK or Apply and current text windows are updated.
Choices other than default are written to config-main.cfg in directory %USERPROFILE%/.idlerc/. The directory and file are created if necessary.
I personally use the fixed-pitch Lucida Console. I occasionally use variable-pitch Lucida Sans Unicode when using strings with non-Latin characters. One can tell from the example in the box whether a font is fixed or variable in character width by whether characters line up neatly in columns or not. (One of my goals is to add examples from several other scripts so one can also see the unicode coverage offered by a font.)

Set the font size in pycharm's python console or terminal

There are terminal and python console in pycharm, which are very convenient. But I found that the font size was too small to recognize in terminal or python console. How can change the font size in the terminal or python console?
In PyCharm 2016.3, the console font setting is squirrelled away under Settings > Editor > Colors & Fonts > Console Font:
Note: Changes to the colors and font are not visible immediately, you have to restart the terminal session to apply them. It's not enough to just hide and reopen the terminal. Just click the red cross button on the terminal's toolbar (Close Terminal Session) and reopen it. The same is valid also for the Python Console.
The location of console font changed in the latest versions of Pycharm.
Settings -> Editor -> Color Scheme -> Console Font
Go to File\Settings\Editor\Color & Fonts and choose save as to save currently used schema by a new name in order to make changes on a new schema. Then in mentioned direction go to console font and set size.
I thought it doesn't work for me either but the problem was that:
you have to close all terminal windows to see the spacing effect.
A simple google search would have lead you here.
You just need to create a personal scheme under settings >Editor > color and fonts.
Edit:Here this further explanation may help more.
1.In color and fonts choose save as and give a scheme name.
2.Go to console font and change size and primary font, which will be inaccessible if you didn't choose the personal scheme you created earlier.

Categories