Comments (4)
Hi Takamoto,
Your screenshots indicate that Windows DPI scaling is set to >100%, which is common for newer devices having a high pixel density display. Windows traditionally used a logical pixel density of 96 DPI (dots or pixels per inch), and many older programs contain behavior hardcoded for 96 DPI such that they have usability problems if run using a higher DPI value. So for compatibility, the default approach on more recent Windows versions is to instruct DPI-unaware programs to draw as if running at 96 DPI, and then Windows will automatically upscale the result, which will have a fuzzier appearance, but the program will at least be usable.
However, if a program works correctly at different DPI settings, it can declare itself as DPI-aware and avoid the fuzzy scaling effect. This is what is done when Tk is run from tclsh/wish, but this is not done when Tk is used through the Tcl C API, as is the case for Tcl::pTk. This is what your screenshots show.
Microsoft's recommended approach for declaring DPI awareness is to use an application manifest, which is what is done for tclsh/wish. This could potentially be done for a Tcl::pTk program packaged into a .exe, but so far my use of Tcl::pTk is limited to .pl scripts, so instead I declare DPI awareness programmatically. As I wrote at https://www.perlmonks.org/?node_id=11101747:
# Make sure to do this **before** calling MainWindow->new
if ($^O eq 'MSWin32') {
require Win32::API;
# See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setprocessdpiaware
my $SetProcessDPIAware = Win32::API::More->new('User32', 'BOOL SetProcessDPIAware()');
$SetProcessDPIAware->Call() or warn 'Failed to set process DPI awareness';
}
I think the scaling is the only important factor here, rather than any difference in TkDefaultFont.
Hope this helps
from perl-tcl-ptk.
Hi Christopher,
Yes, it helped! Thank you for pointing to the DPI issue which is the cause of my problem. After some testing, I opted for the script solution, at least for now. Not recommended, but working fine.
PS: I pack my App with pp and apparently there is no option available to set the manifest (I will ask the mantainer). Third parties app (Win32::Exe, Resource Tuner) did not yeld any success in changing the manifest of the exe. But, this is something that needs me to spend more time to properly investigate it.
from perl-tcl-ptk.
I will go ahead and close this issue, feel free to reopen it or open a new one if you need more help.
I don't know for sure what works, but I wonder if it works to add a separate .exe.manifest file in the same directory as and named after the packed exe.
from perl-tcl-ptk.
Something to be aware of: very recent versions of Windows support "per-monitor DPI awareness", meaning that separate displays can use different logical pixel densities; previously, all displays would use the same logical pixel density. Tcl/Tk does not support per-monitor DPI awareness on Windows, and I believe adding support for it would be difficult. Rescaling (fuzziness) will be observed for Tk programs when toplevels are moved between displays with differing logical pixel densities. One issue encountered is that this rescaling is not done correctly for overrideredirect toplevels (https://core.tcl-lang.org/tk/info/a9ee44102b); it is not clear if this is due to a Tk bug or a Windows bug.
from perl-tcl-ptk.
Related Issues (20)
- bare `Exists` not working under TkHijack HOT 1
- focusMethods.t fails
- Issues using Perl exit HOT 1
- macOS aqua: BrowseEntry dropdown appears behind window HOT 2
- method `Widget` unimplemented HOT 1
- warning when setting textvariable to undef HOT 2
- ROText: not read-only, missing bindings
- macOS segmentation fault by pasting "dβune" in Text widget HOT 4
- background color Entry widget 8.6.11 HOT 2
- trace callback not entered when variable accessed from Tcl
- Table widgets accessible with Tcl::pTk HOT 1
- messageBox.t not completing automatically under Tk Aqua 8.6.11 HOT 1
- `Attempt to call undefined import method with arguments via package "Tk::widgets"` HOT 3
- Widgets supported by Tk::widgets but not Tcl::pTk::widgets
- Tcl/pTk/Widget.pm: `$ptk_w_names` is unused
- dndlocal.t: test 1 isolated failure
- Cygwin tester FAIL: `couldn't connect to display ""`
- Request about support of ttk::labelframe HOT 2
- Test fail on macOS Monterey and Perl 5.38.2 HOT 2
- Add test which prints Tcl/Tk patchlevel
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perl-tcl-ptk.