Closed Suresh-py closed 2 months ago
Tkinter module is the only builtin way to get the screen size without resorting to external dependencies. I avoided the approach because Tkinter is quite large to load for a single function. Also Tkinter is not packaged in some Linux python distributions.
I can conditionally import it on the first run and cache the screen size in the user.json. Conditional imports will affect performance on first run but subsequent runs will be smooth.
If Tkinter is not available, it will default to the old behavior and the user will be recommended to install Tkinter (only on first run).
Give me a day or two, I will provide a fix for this. :smiley:
Please update your repo and let me know if its working for you. I am closing this issue for timebeing
I tried with the latest code and it is not working for me. I am using Python Ver 3.12.5
Can you open user.json
and confirm if you see SCREEN_SIZE
.
Did you notice any change in the window size?
Also just curious, what sort of display do you have? 24 inch Desktop or 15 inch laptop etc.
On 29 August 2024 01:16:03 UTC, Suresh-py @.***> wrote:
I tried with the latest code and it is not working for me. I am using Python Ver 3.12.5
-- Reply to this email directly or view it on GitHub: https://github.com/BennyThadikaran/stock-pattern/issues/55#issuecomment-2316532955 You are receiving this because you modified the open/close state.
Message ID: @.***>
This is the info from the user.json. I didn't notice any change in the window size it is like the previous output only. I am using 24 inch Desktop
{ "DATA_PATH": "~\\Desktop\\eod2-main\\src\\eod2_data\\daily", "SYM_LIST": "~\\Desktop\\stock-pattern-main\\src\\data.csv", "POST_SCAN_PLOT": true, "SCREEN_SIZE": [ 14, 8 ] }
Ok this is clearly wrong. I use a 15 Inch laptop display and my screen size also shows 14, 8.
As a temporary fix, you can edit the SCREEN_SIZE
in user.json. (14 is the width and 8 is the height). Adjust till it fits your screen.
Meanwhile I'll see what can be done to fix it.
Recording 2024-08-29 125753.zip Please see this screen recording if it helps in understanding the problem. I tried with smaller size 10,10. Size of the chart window is reduced but it is still randomly moving across the desktop screen when i move to next tickers using "N". Thank you for the support
Ignore my previous comments. I tested on Windows and found a permanent fix to the problem.
plt.get_current_fig_manager().window.state('zoomed')
I'm not sure if its specific to Windows OS so need to test and make sure its cross platform. I release the update once I've tested it.
I have fixed this now. I used the plt.get_current_fig_manager().full_screen_toggle()
. This puts the window in full-screen mode (not maximized state). full_screen_toggle
is part of Matplotlib backend api and should be stable across all backends.
plt.get_current_fig_manager().window.state('zoomed')
also works, but is specific to TkAgg backend. If a different backend is in use, it will throw an error, which would have to be handled with backend specific code.
To toggle in/out of fullscreen mode, just press
f
key on the chart.
Let me know if it works for you.
And thanks for raising this issue. I'm sure all users will benefit from this change. :+1:
PS: I reverted my previous change, so SCREEN_SIZE
is no longer needed in user.json
In the latest version full screen is stable but the control keys are not working until I make the window active by selecting it with the mouse. If I don't select the window with the mouse then "N" Is not showing next scrip.
PS: I am using Windows 11
Thank you
This seems to be a windows specific issue. For windows, if using tkAgg backend it will maximize the window. For any other backend, it will fallback to full-screen mode.
I suppose, tkAgg is the default backend for Matplotlib. If anyone faces issues, I can add additional fallbacks.
if "win" in sys.platform:
try:
# Only works with tkAgg backend
window_manager.window.state("zoomed")
except AttributeError:
window_manager.full_screen_toggle()
else:
window_manager.full_screen_toggle()
For now, I have tested on Windows and Linux and its working well.
The issue is solved now and thank you
When running chart controls "N" The chart window is not auto adjusting to windows it is random for different tickers. I am clicking the maximum button to fit the chart window properly. Screenshot attached.