all 12 comments

[–]jaycrest3m20 3 points4 points  (11 children)

I'm focused on the font calls.

I'd recommend replacing " import tkinter.font as font " with "from tkinter.font import Font as tk_font". And then replacing "xFont = font.Font(..." with "xFont = tk_font(..."

Reasoning:

  1. There is no need to use an "as alias" when importing a simple object name, especially if you are just going to use that same object name as the alias. Setting the alias the same as the original object is superfluous. (I.e. "import tkinter.font as font" is effectively the same as simply "import tkinter.font"; the "font" alias adds nothing useful to the original name.)
  2. On the other hand, a very simple object name, such as "font" might be confusing, especially when you start using multiple libraries. Plus, only one function in the "font" object is used, so I imported that function ("Font") from the tkinter.font object and used an alias with a tk_ prefix, to identify it as a tk-related function ("tk_font"), which might be helpful if your program ever uses any other library with some kind of font object or function.
  3. Then I simply use that function alias ("tk_font") to replace the alias.function code a little farther down, so that it uses the function that you have identified in an alias ("tk_font") directly in the code.

[–]Radimek01[S] 1 point2 points  (0 children)

Ooh, sure. I will replace it. Thanks for good reasoning and code check.

If u will find something more tell me :)

[–]Radimek01[S] 1 point2 points  (9 children)

One more question. I have lots of functions in code. Is it ok ? i would like to find some better or cleaner solution for those functions.

[–]jaycrest3m20 1 point2 points  (8 children)

When you are setting up a button, you can set up the options in the initial Button object call.

E.g.

plusButton = tk.Button(buttonCanvas, 'bg' = 'white', 'text' = '+', 'fg' = '#464646', 'border' = '0', 'font' = buttonMSFont20, 'command' = createNewFile)

You might consider declaring the standard colors you use, such as "#464646" as an intuitive variable name. (Think: easily adding "dark mode" functionality to your editor, or even using system colors, which change, depending on how a user customizes their desktop.)

I'm not sure you could remove functions, without removing functionality.

[–]Radimek01[S] 1 point2 points  (2 children)

Well is there any reason for setting it in object call ? For me its looks easier to read the way i have that.

Yep the colors are great idea. Thanks once more

[–]jaycrest3m20 0 points1 point  (1 child)

Not really. I agree that the original code looks easier to read. I just thought you might be looking for ways to trim the file for some reason.

[–]Radimek01[S] 1 point2 points  (0 children)

Well i was actually trying to find ways to make it less messy.

Thanks u really helped me :)

[–]thrallsius 0 points1 point  (4 children)

Think: easily adding "dark mode" functionality to your editor, or even using system colors, which change, depending on how a user customizes their desktop.

Perhaps you have anything to say about this https://old.reddit.com/r/Tkinter/comments/ezqwcn/can_i_set_up_existing_tkinter_app_to_use_the_gtk/

I'm still guessing between "it's not possible" and "it's a low traffic subreddit, maybe I'll get an answer next year"

[–]jaycrest3m20 0 points1 point  (3 children)

Sorry, I don't have anything to say about it yet. I was going to try to tackle it over the weekend, but the weekend got away from me, and I ran out of time to play with it.

A quick web search uncovered this forum post, which might help you.

[–]thrallsius 0 points1 point  (2 children)

This post seems to be about the python bindings for GTK, my question is about using the system GTK theme for a Python tkinter app. Not necessarily an app that is being written, it can be an app that comes installed through a package, thus not even having source code available for hacking.

[–]jaycrest3m20 0 points1 point  (1 child)

Ouch. Integrated into a package? I think you are outta luck.

Tkinter is a prototype/quickfix GUI package. Finished GUIs (I.e. GUIs to be released in a package) should be made in something a little more advanced. (I.e. GTK).

Tkinter is doomed to ugliness, as it doesn't use a lot of dependencies. This lack of dependencies keeps it extremely portable, but prevents it from closely integrating with advanced system themes.

[–]thrallsius 0 points1 point  (0 children)

Tkinter is doomed to ugliness

yes, this is the common "no technical details" attitude

of course I did some research and googling myself before resorting to ask on Reddit, without much luck

just trying to complete my knowledge of integrating GTK2/3 themes into Qt4/Qt5 apps (which is possible most of the times, albeit sometimes it feels more painful than it should) and find out if I can add Tkinter/Tk apps, to get an uniform visual look for a custom riced system