ragardner / tksheet

Python tkinter table widget for displaying tabular data
https://pypi.org/project/tksheet/
MIT License
408 stars 50 forks source link

Higher resolution support #199

Closed fdsilva-centi closed 1 year ago

fdsilva-centi commented 1 year ago

So, I have a program (that uses this package) running in different computers, with different resolutions. I find it that people with higher resolutions have a problem with the size of the text (it's too small). I've done some testing, and in my computer (1920x1080), when I downsize it or scale it down, the text becomes bigger, but it doesn't seem to happen in computers with higher resolutions.

Is there a way around this? For example, force the text and cells to become bigger? How do you manage the resolution aspect? If there's noting on that, is this something you can implement? Thank you!

ragardner commented 1 year ago

I could add a zoom in / zoom out on ctrl mousewheel which would effectively do as you say, change the font and cell sizes

would this work for you?

if you need something more automated it would have to be some sort of auto scale based on resolution

fdsilva-centi commented 1 year ago

That would be great, thank you!

As for the second suggestion you made, an auto-scale would be perfect, but not really necessary. My first thought was like an initialization option, where you can define the scale of the table.

ragardner commented 1 year ago

It's taking a bit longer than expected to implement due to being a bit busy irl and having to code for correcting the positions of open windows such as a dropdown box upon zoom but I am working on it and hopefully nearly finished

ragardner commented 1 year ago

@fdsilva-centi Hello, I haven't added an initialization option yet but I have added zoom bindings on control (command on mac os) mousewheel or control + plus / control + minus

It does something very simple at the moment, just increases the font size which makes all the other stuff like dropdown arrows and checkboxes also increase in size

There's unfortunately no pop up to show scale or font size at the moment

It's in version 6.2.4

Let me know what you think of it

fdsilva-centi commented 1 year ago

Hey. Overall it's what I was looking for, thank you so much.

Are you planning on doing the pop up to show scale or font size as you mentioned? And the initialization option? Either way, great job, thanks again!

ragardner commented 1 year ago

I've added an initialization option named zoom which is an int font size multiplier, 100 is no multiplier aka 100% no zoom, 90 would be zoomed out 10%, 110 would be zoomed in 10%

At the moment I don't have plans to add the pop up to show the scale due to time constraints

Brazzelhuber commented 1 year ago

Hi,

I have a similar (double) problem: I develop on a pc with screen resolution 3840x2160. Although I define table width = frame width and table height = frame height, the table is much to small (see appendix1) Screenshot (186) when I transfer the app to a pc with 1920x1080 resolution, the table is much to big Screenshot2 here is the code: ` # Erstellen Sie das kleinere Fenster links unten self.bottom_frame_links = ctk.CTkFrame(master=self,width=self.bottom_frame_links_width, height=self.bottom_frame_links_height, corner_radius=0) self.bottom_frame_links.grid(row=1, column=1, padx=10, pady=10,sticky="nw") self.bottom_frame_links.grid_propagate(False) # Fixiert die Groesse des Frames self.anz_tab_cols = 7 self.table_width = int(self.bottom_frame_links_width) self.table_col_width = int(self.table_width/self.anz_tab_cols )

self.table_height = int(self.bottom_frame_links_height) self.anz_tab_rows = 5 self.table_row_height = int(self.table_height/self.anz_tab_rows )

self.table = Sheet(self.bottom_frame_links, theme="dark", header_height = "2",
show_y_scrollbar = False, show_x_scrollbar = False, show_row_index = False, width=self.table_width, # identisch mit frame-Breite (self.bottom_frame_links_width) height = self.table_height, column_width = self.table_col_width, row_height = self.table_row_height

                )

self.table.grid(row=0, column=0, sticky="nw")` it does't get better, if I change sticky to "nsew"

Thanks in advance

ragardner commented 1 year ago

@Brazzelhuber Hello,

Your issue is a separate one from text zoom but I will try to advise here briefly anyway

it does't get better, if I change sticky to "nsew"

This is because you have set a Sheet() width and height already so expansion of the Sheets dimensions is ignored

In theory your code should work but in practice perhaps it might not for example when the application window has its dimensions change

So I suggest trying out the removal of the following lines:

width=self.table_width, # identisch mit frame-Breite (self.bottom_frame_links_width)
height = self.table_height,

and then making following change:

change this:

self.table.grid(row=0, column=0, sticky="nw")

to this:

self.table.grid(row=0, column=0, sticky="nwse")

If that doesn't work let me know in a new issue, perhaps with a bit more of a minimal example so I can understand what's going on a bit better

Cheers

Brazzelhuber commented 1 year ago

Hi ragardner,

thank you for your fast response. In the meanwhile, I found out, that sticky="nwse" is indeed better and additionally i saw, that the problem was partially caused by the fact that the big screen had a scaling of 150%, the small one one of 100%. The screen shots were only test programs. In this environment it works, when I set the small screen to 150% scaling (altough the widgets are getting very big). I will reconfigure my main app (currently the frames are overlapping at 150%). I will be back with the results soon.

best regards

Brazzelhuber